• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled Dusernajder  Jan 28th, 2020 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import random
2.
3. """ You have to guess the number from a list of random integers """
4.
5. a = []
6. a.append(random.randint(1, 99))
7. a.append(random.randint(1, 99))
8. a.append(random.randint(1, 99))
9. a.append(random.randint(1, 99))
10. a.append(random.randint(1, 99))
11. a.append(random.randint(1, 99))
12. a.append(random.randint(1, 99))
13. a.append(random.randint(1, 99))
14. a.append(random.randint(1, 99))
15. a.append(random.randint(1, 99))
16.
17. for i in range(10):
18.     g = int(input("Enter an integer from 1 to 99: "))
19.     while a[i] != g:
20.         if g < a[i]:
21.             print("guess is low")
22.             g = int(input("Enter an integer from 1 to 99: "))
23.         elif g > a[i]:
24.             print("guess is high")
25.             g = int(input("Enter an integer from 1 to 99: "))
26.         else:
27.             break
28.     print("you guessed it!")
29.
30. """ ############## """
31.
32. numbers_array = [random.randint(1, 49) for i in range(10)]
33. for elt in numbers_array:
34.     guess = -1
35.     while elt != guess:
36.         guess = int(input("Enter an integer from 1 to 49: "))
37.         if elt == guess: break
38.         print("guess is low") if guess < elt else print("guess is high")
39.     print("you guessed it!")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Top