-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex_random.py
More file actions
73 lines (56 loc) · 2.19 KB
/
ex_random.py
File metadata and controls
73 lines (56 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
def my_program():
clear_screen()
printf('This program shows how to generate random numbers')
while True:
answer = input('Do you want a random FLOAT number between 0 and 1? ', color='yellow')
if answer == 'N':
break
number = random.random()
printf(number, color='light-green')
while True:
answer = input('Do you want a random INTEGER number between 0 and 10? ', color='yellow')
if answer == 'N':
break
number = random.randint(0,10)
printf(number, color='light-green')
printf('Bye!!', color='light-red')
###########################################################################
###########################################################################
# The next lines are needed to run compy, don't mind them,
# but keep them, don't get rid of these lines
###########################################################################
###########################################################################
import compy
import time
import datetime as dt
now = dt.datetime.utcnow
import random
# define commands of compy, so IDE's will recognize them
def clear_screen(): pass
def set_bg_color(color): pass
def set_fm_color(color): pass
def printf(to_print='', color=None, stay=False, reverse=False): pass
def xyprintf(x, y, *args): pass
def poke(x, y, code, color = None, reverse=False): pass
def peek(self, x, y): pass
def input(message = '', color=None): return None
def wait_key(): pass
def check_key(): pass
def redefine_commands_and_run(screen):
global clear_screen, set_bg_color, set_fm_color, printf, xyprintf
global poke, peek, input, wait_key, check_key
clear_screen = screen.clear_screen
set_bg_color = screen.set_bg_color
set_fm_color = screen.set_fm_color
printf = screen.printf
xyprintf = screen.xyprintf
poke = screen.poke
peek = screen.peek
input = screen.input
wait_key = screen.wait_key
check_key = screen.check_key
my_program()
if __name__ == '__main__':
compy.run(redefine_commands_and_run)
###########################################################################
###########################################################################