Answered step by step
Verified Expert Solution
Link Copied!

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
pie_1_votes =0
pie_2_votes =0
pie_3_votes =0
guests =0
def get_guests():
guests = int(input("How many people are coming to Thanksgiving Dinner?: "))
print("")
def get_pies():
pie_1= get_pie_1()
pie_2= get_pie_2()
pie_3= get_pie_3()
return pie_1, pie_2, pie_3
def get_pie_1():
pie_1= str(input("What is the first pie type that guests can choose from?: "))
return pie_1
def get_pie_2():
pie_2= str(input("What is the second pie type that guests can choose from?: "))
return pie_2
def get_pie_3():
pie_3= str(input("What is the last pie type that guests can choose from?: "))
return pie_3
def check_votes(pie_num_votes):
result = True
if int(pie_num_votes)<= int(guests):
result = True
else:
result = False
return result
def update_pie(pie_num_votes, pie_num):
while check_votes(pie_num_votes)== False:
print("The amount of votes for each pie may not exceed the total number of guests")
pie_num_votes = int(input("How many people vote for "+ pie_num +"?: "))
def get_votes():
print("")
print("There can only be one vote per person!")
pie_1_votes = int(input("How many people vote for "+ str(pie_1)+"?: "))
update_pie(pie_1_votes, pie_1)
pie_2_votes = int(input("How many people vote for "+ str(pie_2)+"?: "))
update_pie(pie_2_votes, pie_2)
pie_3_votes = int(input("How many people vote for "+ str(pie_3)+"?: "))
update_pie(pie_3_votes, pie_3)
total_votes = int(pie_1_votes)+ int(pie_2_votes)+ int(pie_3_votes)
not_voted = int(guests)- int(total_votes)
def check_total_votes():
if total_votes == guests:
print("The total votes match the the number of guests, it seems that everyone has cast their vote!")
elif total_votes > guests:
print("The total votes have exceeded the number of guests. Please retry.")
get_votes()
check_votes()
elif total_votes < guests:
print(str(not_voted)+" people have not voted. Their votes will be added to "+ pie_1)
return pie_1+ not_voted
def pie_order(pie_num_votes, pie_num_order):
if pie_num_votes >3:
pie_num_order = pie_num_votes//8
return pie_num_order
elif pie_num_votes <=3:
pie_num_order = int(0)
return pie_num_order
def final_order():
pie_order(pie_1_votes, pie_1_order)
pie_order(pie_2_votes, pie_2_order)
pie_order(pie_3_votes, pie_3_order)
print("----------------------")
print("Here's your pie order:")
print(pie_1+": "+ pie_1_order)
print(pie_2+": "+ pie_2_order)
print(pie_3+": "+ pie_3_order)
get_guests()
pie_1, pie_2, pie_3= get_pies()
get_votes()
check_total_votes()
pie_order()
final_order()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions

Question

In what research projects are your students currently involved?

Answered: 1 week ago

Question

=+5. What is your impression of the Carbon Principles?

Answered: 1 week ago