#Tomer's Python test1 #Help From: internet,Mom #What it does: #Program asks for your name #then asks you how many random numbers to pick # picks numbers # you guess three numbers between 0-20 #tells you the number he picked, what you guessed and how many you got right name=raw_input("Hello, what is your name?")#asks for your name num_of_nums=input("How many numbers should I pick?")#gets how many numbers to pick import random#gets the power to make random numbers randomnumber= range(num_of_nums)#makes an array with enough spaces for all numbers for i in range(0,num_of_nums,1):#Creates random numbers and captures them inside the array randomnumber[i] = random.randrange(20)+1 #makes you guess numbers and puts them into an array: b=1 while(b==1): c=0 guessed=[0,0,0] counter=0 while ( c<3): guessed[c]=input("Guess a number between 0-20 ") c=c+1 print name,",you guessed:",guessed[0],guessed[1],guessed[2] wrightorwrong=raw_input("right? (yes or no)") if(wrightorwrong=="yes"): print "ok good" b=2 elif(wrightorwrong=="no"): print "then lets try this agin" #check to see which of your guesses are correct for j in range(0,num_of_nums,1): if(guessed[0]==randomnumber[j]) or (guessed[1]==randomnumber[j])or(guessed[2]==randomnumber[j]): print randomnumber[j],"is correct" counter=counter+1 #prints out your results with some feedback print "you guessed",counter,"numbers correct" if(counter==0): print "better luck next time. I would have guessed",randomnumber[num_of_nums-1],randomnumber[num_of_nums-2],randomnumber[num_of_nums-3] elif(counter==1): print"could have been worse, but you should have guessed",randomnumber[num_of_nums-1] elif(counter==2): print " good job" else: print"excellent, perfect guess" print "the numbers were:" for h in range(0,num_of_nums,1): print randomnumber[h]
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question