File: guess

package info (click to toggle)
sugar-pippy-activity 75-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,660 kB
  • sloc: python: 5,786; makefile: 16; sh: 6
file content (19 lines) | stat: -rw-r--r-- 432 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import random
import pippy
R = random.randrange(1, 100)

print('Guess a number between 1 and 100!')
N = eval(input('Enter a number: '))
i = 1
while (N != R):
    if N > R:
        pippy.console.red()
        print('Too big... try again')
    else:
        pippy.console.blue()
        print('Too small.. try again')
    pippy.console.black()
    N = eval(input('Enter a number: '))
    i = i + 1

print('You got it in', i, 'tries')