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

  1. Thank you so much for sharing this great blog.Very inspiring and helpful too.Hope you continue to share more of your ideas.I will definitely love to read. buy dvd american horror story cult season 7

    ReplyDelete
  2. I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people. buy dvd rebecka martinsson season 1

    ReplyDelete

Post a Comment

Popular posts from this blog

USB Flash Drive Security Reminder:

USB Flash Drives have more than One Use
Do not trust unknown or free USB devices. It is recommended to look at purchasing more expensive USB sticks that have signed firmware. People have been using USB
devices to deploy malware through Trojan techniques. Either malware is copied to the device with the hope of people plugging the device in and clicking on the file or it automatically executes on insertion. BADUSB has also now afforded the opportunity to include payloads into modified USB firmware that execute on driver installation of the device. The malware payload cannot be scanned by traditional detection methods since it resides in firmware. Other techniques, also utilizing the failure to check for signed firmware, are to implement cross platform scripting to execute keyboard based commands on insertion. There are also USB devices being sold that are designed to destroy the device it is connected to. This is not an exhaustive listing and you should not live in FUD about usi…