-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex_while.py
More file actions
68 lines (48 loc) · 1.8 KB
/
ex_while.py
File metadata and controls
68 lines (48 loc) · 1.8 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
def my_program():
clear_screen()
printf()
printf('This program shows how "while" works')
printf('It will count from 1 to 10')
count = 0
while True:
count = count + 1
printf(count)
if count == 10:
break
###########################################################################
###########################################################################
# 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
# 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)
###########################################################################
###########################################################################