Skip to content

Instantly share code, notes, and snippets.

@danielpclark
Created September 1, 2012 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielpclark/3574118 to your computer and use it in GitHub Desktop.
Save danielpclark/3574118 to your computer and use it in GitHub Desktop.
Discount Wiz - first program I ever wrote.
# This is the first program I ever wrote.
# I never expected anyone to support me for writing it. ... But hey I tried.
#------------------------------DISCOUNT WIZ---------------------------
def op(): # ask for and set original price
original_price_str = raw_input("What is the price? $ ")
if original_price_str in ("", "exit", "close", "quit", "EXIT", "CLOSE", "QUIT"):
return "close"
else:
return float(original_price_str)
def po(): # ask for and set percent off
percent_off_str = raw_input("What is the percent off? (no % symbol please) ")
if percent_off_str in ("", "exit", "close", "quit", "EXIT", "CLOSE", "QUIT"):
return "close"
else:
return float(percent_off_str)
def dp(): # ask for and set discount price
discount_price_str = raw_input("What is discount price? $ ")
if discount_price_str in ("", "exit", "close", "quit", "EXIT", "CLOSE", "QUIT"):
return "close"
else:
return float(discount_price_str)
#--------------------------------------------------------------------
def original(): # find original price
discount_price_f = dp()
if discount_price_f == "close":
print string.center('\nThank you for using "Discount Wiz"!', 79)
return 0
percent_off_f = po()
if percent_off_f == "close":
print string.center('\nThank you for using "Discount Wiz"!', 79)
return 0
original_price_f = discount_price_f / (1 - percent_off_f / 100)
print "The original price is $", round(original_price_f, 2)
print ""
time.sleep(7)
def percent(): # find the percent off
original_price_f = op()
if original_price_f == "close":
print string.center('\nThank you for using "Discount Wiz"!', 79)
return 0
discount_price_f = dp()
if discount_price_f == "close":
print string.center('\nThank you for using "Discount Wiz"!', 79)
return 0
percent_off_f = 100 - discount_price_f / original_price_f * 100
percent_off_s = str(round(percent_off_f, 0))
print "The percent off the price is ", percent_off_s[:-2] , "\b%"
print ""
time.sleep(7)
def discount(): # find discount price
original_price_f = op()
if original_price_f == "close":
print string.center('\nThank you for using "Discount Wiz"!', 79)
return 0
percent_off_f = po()
if percent_off_f == "close":
print string.center('\nThank you for using "Discount Wiz"!', 79)
return 0
discount_price_f = original_price_f - percent_off_f / 100 * original_price_f
print "The discount price is $", round(discount_price_f, 2)
print ""
time.sleep(7)
#--------------------------------------------------------------------
# program prints this menu
import time, string
while 1:
print string.center("Version 1.6.2 Stable Copyright(c) 2000, 6ft dan(TM)", 79)
print string.center("==============================================================", 79)
print string.center("| DDDD IIII SSSS CCCC OOOO UU UU NN NN TTTTTT |", 79)
print string.center("| DD D II SS CC OO OO UU UU NNN NN TT |", 79)
print string.center("| DD D II SSS CC OO OO UU UU NN N NN TT |", 79)
print string.center("| DD D II SS CC OO OO UU UU NN NNN TT |", 79)
print string.center("| DDDD IIII SSSS CCCC OOOO UUUU NN NN TT |", 79)
print string.center("| $$ |", 79)
print string.center("| ()()()) WW WW IIIIII ZZZZZZZ $$$$$ |", 79)
print string.center("| / \\ WW WW II ZZ $ $$ |", 79)
print string.center("| | !_! | WW W WW II ZZ $$$$$ |", 79)
print string.center("| | \___/ | WW W W WW II ZZ $$ $ |", 79)
print string.center("| \\ ___ / WWW WWW IIIIII ZZZZZZZ $$$$$ |", 79)
print string.center("=====================================================$$=======", 79)
print string.center("__/\\__/\\__/\\__/\\__/\\__/\\__/\\__/\\__/\\__/\\__/\\__/\\__/\\__/\\__/\\__", 79)
print string.center("~~\\/~~\\/~~\\/~~\\/~~\\/~~\\/~~\\/~~\\/~~\\/~~\\/~~\\/~~\\/~~\\/~~\\/~~\\/~~", 79)
print string.center("-----------------INSTRUCTIONS FOR DISCOUNT WIZ----------------", 79)
print string.center("| Type: o :to find original price |", 79)
print string.center("| Type: p :to find percent off |", 79)
print string.center("| Type: d :to find discount price |", 79)
print string.center("| Type: exit :to exit |", 79)
print string.center("--------------------------------------------------------------", 79)
userinput = raw_input("Enter your choice now please: ")
if userinput == "o":
if original() == 0:
break
else: pass
elif userinput == "p":
if percent() == 0:
break
else: pass
elif userinput == "d":
if discount() == 0:
break
else: pass
else:
print '\n' * 7
print string.center('Thank you for using "Discount Wiz"!', 79)
break
#----------------------------CopyRight!-----------------------
print string.center("____________________________________________________________", 79)
print string.center("Hope you enjoyed Discount Wiz. This is not freeware, there ", 79)
print string.center("is a young teen who really could use some cash. Please send", 79)
print string.center("a check of at least $5.00 to ", 79)
print ""
print string.center("Daniel P. Clark ", 79)
print string.center("ADDRESS VOID ", 79)
print string.center("Front Royal, VA 22630", 79)
print ""
print string.center("Thank you, include your E-mail and I can give you an update ", 79)
print string.center("that doesn't have this shareware pause or notice. I think ", 79)
print string.center("you'll like it that way. ", 79)
print ""
print string.center("Copyright(c) -Currently (Unregistered)- Use it, Support it! ", 79)
print string.center("____________________________________________________________", 79)
# copyright notice and message saying that it's not freeware
time.sleep(22)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment