Adding as many examples as I've converted so far.
This commit is contained in:
1 parent
0aa0875c42
commit
543bc78e51
21 files changed
+161
-3
No files matched your search
@@ -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")
|
||||
|
||||
Whitespace-only changes.
@@ -0,0 +1,19 @@
|
||||
for i in range(10):
|
||||
if i == 2 or i == 5:
|
||||
continue
|
||||
elif i == 7:
|
||||
break
|
||||
|
||||
print("For Index Number: " + str(i))
|
||||
|
||||
counter = 0
|
||||
|
||||
while counter < 10:
|
||||
if counter == 2 or counter == 5:
|
||||
counter += 1
|
||||
continue
|
||||
elif counter == 7:
|
||||
break
|
||||
|
||||
print("While Index Number: " + counter)
|
||||
counter += 1
|
||||
Reference in new issue
Block a user