pytheon code with all module def(): Design a change-counting game that gets the
ID: 3624222 • Letter: P
Question
pytheon code with all module def():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.
Use at least three modules in developing the logic…one can be the main().
Explanation / Answer
Dear,
# Main program:
def Main():
pennies=input("Enter number of Pennies: ")
nick= input("Enter number of Nickels: ")
dimes= input("Enter number of Dimes: ")
quat= input("Enter number of Quarters: ")
cents=calculate(nick,dimes,quart,pennies)
printMessage(cents)
#end main
#function definitions
def calculate(nick,dimes,quart,pennies):
return (Quart*25)+(dimes*10)+(nick*5)+pennies
def printMessage(cents):
if ( cents==100):
print "Congratulation You Won the Game"
else if(cents>100):
print" Amount Greater Than 1 Dollar"
else:
print" Amount Less than 1 Dollar"
return;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.