def exit_program(): exit_program = raw_input("Would you like to calculate price per serving again?\n") if exit_program == 'Yes' or exit_program == 'yes': print "Rerunning program\n" + "..." priceperservingg() elif exit_program == 'No' or exit_program == 'no': exit_confirmmmmm() def exit1(): raw_input("Press enter to exit\n") def exit_confirmmmmm(): confirmation_exit = raw_input("Are you sure?\n") if confirmation_exit == 'Yes' or confirmation_exit == 'yes': exit1() elif confirmation_exit == 'No' or confirmation_exit == 'no': print "Rerunning program\n" + "..." priceperservingg() else: print "I'm sorry what was that? Please enter Yes or No." exit_confirmmmmm() def priceperservingg(): price = float(raw_input("How much is this item?\n" + "$")) servings = int(raw_input("How many servings are there?\n" + "Servings: ")) priceperfood = price / servings totalpriceperfood = round(priceperfood,2) if totalpriceperfood <= 0.99 and not 0.1: print "Price per serving is " + str(totalpriceperfood) + " cents." elif totalpriceperfood == 0.1: print "Price per serving is " + str(totalpriceperfood) + " cent." else: print "Price per serving is " + "$" + str(totalpriceperfood) exit_program() priceperservingg()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question