Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Here is my code, when I run it , it seems to think that the user entered a vote that is above the total number
Here is my code, when I run it it seems to think that the user entered a vote that is above the total number of guests, and keeps prompting for a different vote. Here is my full code pievotes pievotes pievotes guests def getguests: guests intinputHow many people are coming to Thanksgiving Dinner?: print def getpies: pie getpie pie getpie pie getpie return pie pie pie def getpie: pie strinputWhat is the first pie type that guests can choose from?: return pie def getpie: pie strinputWhat is the second pie type that guests can choose from?: return pie def getpie: pie strinputWhat is the last pie type that guests can choose from?: return pie def checkvotespienumvotes: result True if intpienumvotes intguests: result True else: result False return result def updatepiepienumvotes, pienum: while checkvotespienumvotes False: printThe amount of votes for each pie may not exceed the total number of guests" pienumvotes intinputHow many people vote for pienum : def getvotes: print printThere can only be one vote per person!" pievotes intinputHow many people vote for strpie: updatepiepievotes, pie pievotes intinputHow many people vote for strpie: updatepiepievotes, pie pievotes intinputHow many people vote for strpie: updatepiepievotes, pie totalvotes intpievotes intpievotes intpievotes notvoted intguests inttotalvotes def checktotalvotes: if totalvotes guests: printThe total votes match the the number of guests, it seems that everyone has cast their vote!" elif totalvotes guests: printThe total votes have exceeded the number of guests. Please retry." getvotes checkvotes elif totalvotes guests: printstrnotvoted people have not voted. Their votes will be added to pie return pie notvoted def pieorderpienumvotes, pienumorder: if pienumvotes : pienumorder pienumvotes return pienumorder elif pienumvotes : pienumorder int return pienumorder def finalorder: pieorderpievotes, pieorder pieorderpievotes, pieorder pieorderpievotes, pieorder print printHeres your pie order:" printpie: pieorder printpie: pieorder printpie: pieorder getguests pie pie pie getpies getvotes checktotalvotes pieorder finalorder
Here is my code, when I run it it seems to think that the user entered a vote that is above the total number of guests, and keeps prompting for a different vote.
Here is my full code
pievotes
pievotes
pievotes
guests
def getguests:
guests intinputHow many people are coming to Thanksgiving Dinner?:
print
def getpies:
pie getpie
pie getpie
pie getpie
return pie pie pie
def getpie:
pie strinputWhat is the first pie type that guests can choose from?:
return pie
def getpie:
pie strinputWhat is the second pie type that guests can choose from?:
return pie
def getpie:
pie strinputWhat is the last pie type that guests can choose from?:
return pie
def checkvotespienumvotes:
result True
if intpienumvotes intguests:
result True
else:
result False
return result
def updatepiepienumvotes, pienum:
while checkvotespienumvotes False:
printThe amount of votes for each pie may not exceed the total number of guests"
pienumvotes intinputHow many people vote for pienum :
def getvotes:
print
printThere can only be one vote per person!"
pievotes intinputHow many people vote for strpie:
updatepiepievotes, pie
pievotes intinputHow many people vote for strpie:
updatepiepievotes, pie
pievotes intinputHow many people vote for strpie:
updatepiepievotes, pie
totalvotes intpievotes intpievotes intpievotes
notvoted intguests inttotalvotes
def checktotalvotes:
if totalvotes guests:
printThe total votes match the the number of guests, it seems that everyone has cast their vote!"
elif totalvotes guests:
printThe total votes have exceeded the number of guests. Please retry."
getvotes
checkvotes
elif totalvotes guests:
printstrnotvoted people have not voted. Their votes will be added to pie
return pie notvoted
def pieorderpienumvotes, pienumorder:
if pienumvotes :
pienumorder pienumvotes
return pienumorder
elif pienumvotes :
pienumorder int
return pienumorder
def finalorder:
pieorderpievotes, pieorder
pieorderpievotes, pieorder
pieorderpievotes, pieorder
print
printHeres your pie order:"
printpie: pieorder
printpie: pieorder
printpie: pieorder
getguests
pie pie pie getpies
getvotes
checktotalvotes
pieorder
finalorder
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started