lundi 27 juin 2016

How do you make a list of random numbers

I'm working with python to create a game that the computer will pick numbers from 1 to 10 and the player can choose which numbers they want to keep or delete..The sum of the random numbers must add up to 21 and the player has only 10 tries.What would be the code I use to create the list of random numbers to equal 21 and let the player delete numbers they want.Thank you!!!

I've already started on some of it..The program I use Python 2.7.5 on Mac...

import random
import time
name = raw_input("Hello, What's your name?")
print "Welcome," ,name, "Time to play Catch 21!"
time.sleep(1)
tries = 0
tries_remaining = 10
while tries < 10:
          tries += 1
          tries_remaining -= 1
from time import sleep
total = 0
for i in range(10):
    total = total + random()
print total
while True:
    print "Your card is"
    values = ["2","3","4","5","6","7","8","9","10"]
    print(random.randint(1,10))
    print"Do you want to keep or delete this card?"
    card = raw_input("K = Keep.  D = Delete. ")
    from time import sleep
    time.sleep(1)




Aucun commentaire:

Enregistrer un commentaire