Adding as many examples as I've converted so far.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Write a program that generates a random number, and repeatedly asks the user to guess the number, telling them if they're too low, too high, or if they guess correctly. The program should end once they guess the correct number.
|
||||
@@ -0,0 +1,16 @@
|
||||
import random
|
||||
|
||||
randomValue = random.randint(1, 100)
|
||||
|
||||
guess = -1
|
||||
|
||||
while randomValue != guess:
|
||||
guess = int(input("Guess the number: "))
|
||||
|
||||
if guess < randomValue:
|
||||
print("You're too low")
|
||||
elif guess > randomValue:
|
||||
print("You're too high")
|
||||
else:
|
||||
print("You guessed the right number")
|
||||
|
||||
Reference in New Issue
Block a user