I am in desperate need of help on my hw assignment. Below is the problem:
Using a 'for' loop, write a price guessing game that satisfies the following criteria.
Your program should store the name of the prize and the price of that prize in
variables/constants that you specify. Ask the user how many contestants there are and
store this in another variable. Use the number of contestants as your for loop range.
Using your for loop get input from each user as their guess for the price of the prize.
After all users have guessed the price, print out which contestant won the prize. The
winner is the person who is closest to the price without going over. If two users enter
the same price, the first contestant wins the prize.
Sample input/output would look like something like (user input in italics):
The Right Price!
---------------------------
The prize is: A new car!
How many players are there? 5
Contestant #1, What is your wager (in dollars): $12300
Contestant #2, What is your wager (in dollars): $21000
Contestant #3, What is your wager (in dollars): $12301
Contestant #4, What is your wager (in dollars): $1
Contestant #5, What is your wager (in dollars): $17500
The price of this prize was: $17490
Contestant #3 wins!
_______________________________________________
This is what i have so far but i don't know where to go from here.
print('The Right Price!')
print('--------------------------')
print('The Prize is a New Car!')
price = 1000
total = 0
players = int(input('How many players are there? '))
for i in range(players):
con = (input('Contestant #' + str(i + 1) +
', What is your wager (in dollars) '))
print('The price of the prize was: ' + str(price) + '!')
Anything would be helpful at this point. Thanks guys!
MOD EDIT: When posting code...USE CODE TAGS!!!
This post has been edited by JackOfAllTrades: 19 February 2011 - 03:18 PM

New Topic/Question
Reply




MultiQuote






|