Design a change-counting game that gets the user to enter the number of coins re
ID: 3629358 • Letter: D
Question
Design a change-counting game that gets the user to enter the number of coins required to make exactly one dollar. The program should ask the user to enter the number of pennies, nickels, dimes, and quarters. If the total value of the coins entered is equal to one dollar, the program should congratulate the user for winning the game. Otherwise, the program should display a message indicating whether the amount entered was more or less than one dollar.
Write the Python code for the following programming problem.
Use at least three modules in developing the logic…one can be the main().
Explanation / Answer
def Input():
pennis =int(input('Enter pennis: '))
nickels = int(input('Enter nickels : '))
dimes = int(input('Enter dimes: '))
quart=int(input('Enter quarter:'))
tot=calculate(pennis ,nickels,dimes,quart)
Game(tot)
def calculate(pen,nic,dim,qt): return pen+(nic*5)+(dim*10)+(qt*25)
def Game(total):
if total==10:
print "Cograts!!"
else if total<100:
print "Amount less then dollar"
else
print "Amount greater than dollar"
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.