Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Starting program...
- #Importing time module for title screen:
- import time
- import sys
- #Define some variables
- a1= 0
- a2= 0
- #Making 'on' and 'off' switches for result outputs:
- Result_2= 0
- Result_3= 0
- #Title screen:
- #Made up of 0.1 sec delays and layers of text 'stacked' on eachother
- print('/$$$$$$$ /$$ /$$ /$$$$$$$ /$$ /$$')
- time.sleep(0.1)
- print('| $$__ $$ | $$ | $$ | $$__ $$ | $$ | $$')
- time.sleep(0.1)
- print('| $$ \ $$/$$ /$$ /$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ | $$ \ $$/$$ /$$/$$$$$$ | $$$$$$$ /$$$$$$ /$$$$$$$')
- time.sleep(0.1)
- print('| $$$$$$$| $$ | $$/$$__ $$/$$__ $$/$$__ $|_ $$_/ | $$$$$$$| $$ | $|_ $$_/ | $$__ $$/$$__ $| $$__ $$')
- time.sleep(0.1)
- print('| $$__ $| $$ | $| $$ | $| $$ \ $| $$$$$$$$ | $$ | $$____/| $$ | $$ | $$ | $$ \ $| $$ \ $| $$ \ $$')
- time.sleep(0.1)
- print('| $$ \ $| $$ | $| $$ | $| $$ | $| $$_____/ | $$ /$$ | $$ | $$ | $$ | $$ /$| $$ | $| $$ | $| $$ | $$')
- time.sleep(0.1)
- print('| $$$$$$$| $$$$$$| $$$$$$| $$$$$$| $$$$$$$ | $$$$/ | $$ | $$$$$$$ | $$$$| $$ | $| $$$$$$| $$ | $$')
- time.sleep(0.1)
- print('|_______/ \______/ \_______/\____ $$\_______/ \___/ |__/ \____ $$ \___/ |__/ |__/\______/|__/ |__/')
- time.sleep(0.1)
- print(' /$$ \ $$ /$$ | $$')
- time.sleep(0.1)
- print(' | $$$$$$/ | $$$$$$/')
- time.sleep(0.1)
- print(' \______/ \______/')
- print('')
- print('_________________________________________________________')
- print('IF YOU WISH TO EXIT THE PROGRAM AT ANY TIME PRESS CTRL+C')
- print('---------------------------------------------------------')
- print('')
- input('[BEGIN?]') #Makeshift 'Begin' button
- while True:
- print('')
- print('[ITEM A COST]') #Code Subheading
- #Start Infinite loop
- while True:
- try:
- #Input prompt
- temp_a1= float(input("What is the cost of item [a]: $")) #Save input float as 'temporary'
- except ValueError: #Error exception:
- print('')
- #Error prompt
- print('Please Enter a Number')
- #Returns to start of the loop
- else:
- #Code is parsed
- break
- #Break and exit loop
- #Start Infinite loop
- while True:
- #Input prompt
- discount1= input("Does item [a] have a discount? (y/n): ")
- #'y' or 'n' Input
- if discount1 == 'y' or discount1 == 'n':
- #Code is parsed
- break
- #Break and exit loop
- else:
- print('')
- #Error prompt
- print('Please type in "y" to answer "Yes" and type in "n" to answer "No"')
- if discount1 == 'n': #Inputted 'n'
- a1= temp_a1 #Make temporary value 'real' value
- if discount1 == 'y': #Inputted 'y'
- print('')
- print('[ITEM A DISCOUNT]') #Code Subheading
- #Input prompt
- q1 = input("Is the discount for item [a] percentage or a 'before and after' discount? (%/$): ")
- #'%' or '$' Input
- if q1 == '%': #Inputted '%'
- #Start Infinite loop
- while True:
- try:
- #input prompt
- p1= float(input('What is the percentage discount?: %')) #Input float for percentage discount
- except ValueError: #Error exception:
- print('')
- #Error prompt
- print('Please Enter a Number from 0-100')
- if p1 > 100 or p1 < 0: #Incorrect input
- print('')
- #Error prompt
- print('Please Enter a Number from 0-100')
- else:
- d1= (p1/100)*temp_a1 #Divide inputted percentage by 100 and multiply by item price to find discount amount
- a1= temp_a1-d1 #Take discount from inputted price to get actual price
- Result_3= 1 #Allows output for result 3
- Result_2= 1 #Allows output for result 2
- #Rounding values
- d1= round(d1, 2)
- a1= round(a1, 2)
- print('You have saved $' + str(d1))
- print('Item [a] is now $' + str(a1))
- break
- #Break and exit loop
- if q1 == '$': #Inputted '$'
- #Start Infinite loop
- while True:
- try:
- #input prompt
- b4_price1= float(input('What was the price of item [a] before the discount?: $')) #Input float for before price
- except ValueError:
- print('')
- print('Please Enter a Number')
- else:
- break
- while True:
- try:
- #input prompt
- after_price1= float(input('What was the price of item [a] after the discount?: $')) #Input float for after price
- except ValueError: #Error exception:
- print('')
- #Error prompt
- print('Please Enter a Number')
- else:
- break
- #Break and exit loop
- temp_a1= a1
- #Rounding values
- a1= round(a1, 2)
- p1= (after_price1/b4_price1)*100
- d1= after_price1-b4_price1
- d1= round(d1, 2)
- print('The percentage discount on item [a] is %' + str(round(p1, 2)))
- print('')
- print('[ITEM B COST]') #Code Subheading
- #Start Infinite loop
- while True:
- try:
- #Input prompt
- temp_a2= float(input("What is the cost of item [b]: $")) #Save input float as 'temporary'
- except ValueError: #Error exception:
- print('')
- #Error prompt
- print('Please Enter a Number')
- #Returns to start of the loop
- else:
- #Code is parsed
- break
- #Break and exit loop
- #Start Infinite loop
- while True:
- #Input prompt
- discount2= input("Does item [b] have a discount? (y/n): ")
- #'y' or 'n' Input
- if discount2 == 'y' or discount2 == 'n':
- #Code is parsed
- break
- #Break and exit loop
- else:
- print('')
- #Error prompt
- print('Please type in "y" to answer "Yes" and type in "n" to answer "No"')
- if discount2 == 'n': #Inputted 'n'
- a2= temp_a2 #Make temporary value 'real' value
- if discount2 == 'y': #Inputted 'y'
- print('')
- print('[ITEM B DISCOUNT]') #Code Subheading
- #Input prompt
- q2 = input("Is the discount for item [b] percentage or a 'before and after' discount? (%/$): ")
- #'%' or '$' Input
- if q2 == '%': #Inputted '%'
- #Start Infinite loop
- while True:
- try:
- #input prompt
- p2= float(input('What is the percentage discount?: %')) #Input float for percentage discount
- except ValueError: #Error exception:
- print('')
- #Error prompt
- print('Please Enter a Number from 0-100')
- if p2 > 100 or p2 < 0: #Incorrect input
- print('')
- #Error prompt
- print('Please Enter a Number from 0-100')
- else:
- d2= (p2/100)*temp_a2 #Divide inputted percentage by 100 and multiply by item price to find discount amount
- a2= temp_a2-d2 #Take discount from inputted price to get actual price
- Result_3= 1 #Allows output for result 3
- Result_2= 1 #Allows output for result 2
- #Rounding values
- d2= round(d2, 2)
- a2= round(a2, 2)
- print('You have saved $' + str(d2))
- print('Item [b] is now $' + str(a2))
- break
- #Break and exit loop
- if q2 == '$': #Inputted '$'
- #Start Infinite loop
- while True:
- try:
- #input prompt
- b4_price2= float(input('What was the price of item [b] before the discount?: $')) #Input float for before price
- except ValueError:
- print('')
- print('Please Enter a Number')
- else:
- break
- while True:
- try:
- #input prompt
- after_price2= float(input('What was the price of item [b] after the discount?: $')) #Input float for after price
- except ValueError: #Error exception:
- print('')
- #Error prompt
- print('Please Enter a Number')
- else:
- break
- #Break and exit loop
- #Rounding values
- a2= round(a2, 2)
- temp_a2= a2
- p2= (after_price2/b4_price2)*100
- d2= after_price2-b4_price2
- d2= round(d2, 2)
- print('The percentage discount on item [a] is %' + str(round(p1, 2)))
- print('')
- print('[QUANTITY]') #Code Subheading
- while True: #Start Infinite loop
- try:
- #Input prompt
- b1= float(input("How many units does item [a] have?: ")) #Input float for unit quantity
- except ValueError: #Error exception:
- #Error prompt
- print('Please Enter a Number')
- else:
- break
- #Break and exit loop
- while True: #Start Infinite loop
- try:
- #Input prompt
- b2= float(input("How many units does item [b] have?: ")) #Input float for unit quantity
- except ValueError: #Error exception:
- print('Please Enter a Number')
- #Error prompt
- else:
- break
- #Break and exit loop
- #Division to get value of both products
- a3= a1/b1
- b3= a2/b2
- #Outputs:
- if a3 > b3:
- print('')
- print('[BEST BUY]')
- print('Item [b] is cheaper than item [a].')
- if b3 > a3:
- print('')
- print('[BEST BUY]')
- print('Item [a] is cheaper than item [b].')
- if b3 == a3:
- print('')
- print('[BEST BUY]')
- print('Item [a] and item [b] are the same price.')
- if Result_2 == 1:
- if d1 > d2:
- print('Item [a] saves you more money than item [b].')
- if d1 < d2:
- print('Item [b] saves you more money than item [a].')
- if d1 == d2:
- print('Item [a] and item [b] save you the same amount of money.')
- if Result_3 == 1:
- if p1 > p2:
- print('Item [a] saves you a bigger percentage than item [b].')
- if p1 < p2:
- print('Item [b] saves you a bigger percentage than item [a].')
- if p1 == p2:
- print('Item [a] and item [b] will save you the same percentage.')
- while True:
- #Input prompt
- print('')
- terminate1= input("Do wish to terminate the program? (y/n): ")
- #'y' or 'n' Input
- if terminate1 == 'y' or terminate1 == 'n':
- #Code is parsed
- break
- #Break and exit loop
- else:
- print('')
- #Error prompt
- print('Please type in "y" to answer "Yes" and type in "n" to answer "No"')
- if terminate1 == 'y': #Inputted 'y'
- print('')
- print('[PROGRAM TERMINATING]...')
- sys.kill()
- if terminate1 == 'n': #Inputted 'n'
- print('[PROGRAM REPEATING]...')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement