Simple Gratuities Calculator (Python 3.4)

All new tutorial are submitted here.
They will be moved to the main Tutorials section once they have been approved by mods and admins.

Simple Gratuities Calculator (Python 3.4)

Postby anybloodyid » Sat Jan 09, 2016 12:31 pm

By a beginner for other beginners.

Code: Select all
print ("\t\t\tGratuities Calculator") #Title
bill = float(input("\nPlease enter the amount of your bill £")) #User input

big_tip = bill + 20/100 * bill #Calculation to add 20%
bt = '{:.2f}' .format(big_tip) #Result to 2 decimal places

small_tip = bill + 15/100 * bill #Calculation to add 15%
st= '{:.2f}' .format(small_tip) #Result to 2 decimal places

tiny_tip = bill + 5/100 * bill #Calculation to add 5%
tt= '{:.2f}' .format(tiny_tip) #Result to 2 decimal places

print ("\n\tTotal including 20% tip = £", bt) #---------

print ("\n\tTotal including 15% tip = £", st)   #Print results

print ("\n\tTotal including  5% tip = £", tt) #----------

input("\n\n Press Enter to exit") #Wait for user to end program
Coding to pass the time.
User avatar
Posts: 22
Joined: Wed Jul 23, 2014 7:12 am
Location: Cheshire, England

Re: Simple Gratuities Calculator (Python 3.4)

Postby micseydel » Sat Jan 09, 2016 8:23 pm

This is sample code, which would be fine in the Completed Scripts section, but a tutorial typically has some explanatory component.
Due to the reasons discussed here we will be moving to on October 1, 2016.

This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
Posts: 3000
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Return to Tutorial Submissions

Who is online

Users browsing this forum: No registered users and 1 guest