Skip to main content

Python Tip Calculator



I was reviewing some fundamental tutorials covering Python programming and used this code below to create a simple Tip Calculator.  (https://www.codecademy.com/learn)

Nothing Fancy!! This was just for learning, but was kind of fun.  You can easily elaborate on what is provided by adding some additional conditionals with elif and/or else.

**Code provided below for easy copy/paste.










########################################################
import sys
import datetime

meal = float(input('Please Enter the Meal Cost:  '))
tax = float(input('Please Enter the Tax %:  '))
tip = float(input('Please Enter the Tip Percentage %:  '))

date = datetime.datetime.now()

if tax >= 0:
    tax = tax * .01
if tip >= 0:
    tip = tip * .01

meal = meal + meal * tax
total = meal + meal * tip

output = round(total,2)
print("\nTOTAL\n")
print(date.strftime("%I:%M:%S %m/%d/%Y"),'\n$',output,'\n')



Comments

Post a Comment

Popular posts from this blog

Password Complexity and Length: We all know we should be making passwords 16 characters in length with uppercase, lowercase, numeric, special character, and ending in a letter.   Example:  Tdkhg#8fjw*jf2h Problem is that with today's computational power along with the available pre-built dictionaries, this is not as strong as once thought.  Pre-built dictionaries are easily obtainable that are being constantly updated with the 100's of millions of passwords obtained through data breaches.  
Users should be at least using a password manger such as "Lastpass.com" or "1password.com".  Offline password manager recommended is "Password Safe", designed by renowned security technologist Bruce Schneier.  
When creating a new password today, use passwords that are 30+ characters in length to make bruteforce password cracking exponentially more difficult.  This can easily be done when using a password manger.  What about the password used to access the passw…
With Windows Media Center having taken the last death blow from Microsoft, the Roku 4 might make switching less painless.  
Roku 4 pre-order.  Expected Ship Date 10/21/2015.



https://www.roku.com/products/roku-4