求解答此python!
WelcometoWheelofFortune!Thereare10slotsinyourwheel.Spinyourwheelbyenteringanintegernu...
Welcome to Wheel of Fortune!
There are 10 slots in your wheel.
Spin your wheel by entering an integer number: hello
This is not an integer greater than 0.
please enter an integer: 0
This is not an integer greater than 0.
please enter an integer: 22
The wheel is
[100, 800, 700, 200, 400, 400, 600, 700, 0, 0]
You won $700 in the Wheel of Fortune!
press enter to exit:
输出如上。
ps:这是作业要求。。。编程渣求大家解答!!谢谢!
Your program should first import the random module. Right after that, you must put in this line of code (in red): random.seed(1)
2. You must check the input is actually an integer greater than 0. It cannot be 0 or any character. You can do this by using a while loop to keep asking the user until he/she enters the correct input.
3. You may use the randrange() function in the random module to generate an integer. How do you use randrange()? You do the following: random.randrange(11).
This will randomly generate an integer number less than 11. You can multiple this number by 100 to generate the award on each slot on the wheel.
4. To generate 10 awards, one for each slot, you may use a for loop. Inside the for loop, you should call randrange to generate a random number and add that to your sequence.
5. You need to use remainder to decide which award the player should get. For example, if the player’s number is 11, it means one round and 1 more slot. So the award is the second number in your sequence.
6. You need to write comments for your code (line by line). 展开
There are 10 slots in your wheel.
Spin your wheel by entering an integer number: hello
This is not an integer greater than 0.
please enter an integer: 0
This is not an integer greater than 0.
please enter an integer: 22
The wheel is
[100, 800, 700, 200, 400, 400, 600, 700, 0, 0]
You won $700 in the Wheel of Fortune!
press enter to exit:
输出如上。
ps:这是作业要求。。。编程渣求大家解答!!谢谢!
Your program should first import the random module. Right after that, you must put in this line of code (in red): random.seed(1)
2. You must check the input is actually an integer greater than 0. It cannot be 0 or any character. You can do this by using a while loop to keep asking the user until he/she enters the correct input.
3. You may use the randrange() function in the random module to generate an integer. How do you use randrange()? You do the following: random.randrange(11).
This will randomly generate an integer number less than 11. You can multiple this number by 100 to generate the award on each slot on the wheel.
4. To generate 10 awards, one for each slot, you may use a for loop. Inside the for loop, you should call randrange to generate a random number and add that to your sequence.
5. You need to use remainder to decide which award the player should get. For example, if the player’s number is 11, it means one round and 1 more slot. So the award is the second number in your sequence.
6. You need to write comments for your code (line by line). 展开
1个回答
推荐于2016-02-05
展开全部
import random
print "Welcome to Wheel of Fortune!"
print "There are 10 slots in your wheel"
num=int(raw_input("Spin your wheel by entering an interger number: "))
while num<=0:
print "This is not an interger greater than 0"
num=int(raw_input("Spin your wheel by entering an interger number: "))
else:
list1=[]
for i in range(11):
list1.append(random.randint(1,11)*100)
print list1
后边的打分没看明白,,,
print "Welcome to Wheel of Fortune!"
print "There are 10 slots in your wheel"
num=int(raw_input("Spin your wheel by entering an interger number: "))
while num<=0:
print "This is not an interger greater than 0"
num=int(raw_input("Spin your wheel by entering an interger number: "))
else:
list1=[]
for i in range(11):
list1.append(random.randint(1,11)*100)
print list1
后边的打分没看明白,,,
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询