-
Notifications
You must be signed in to change notification settings - Fork 4
/
functions.py
55 lines (40 loc) · 1.4 KB
/
functions.py
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
from modules import createfunction
def while_loop(condition:str,commands:list):
condition.split()[0]
boolean_ =exec(condition)
while boolean_:
for command in commands:
exec(command)
boolean_ = eval(condition)
# a = 1
# while_loop('a<4',['print("hello")','a+=2'])
# print(a)
def for_loop(start:int,stop:int,step:int,commands:list,identifier:str="_________"):
for __i in range(start,stop+1,step):
exec(f'{identifier}={__i}')
for command in commands:
exec(command)
def do_while_loop(condition:str,commands:list):
for_loop(0,0,1,commands=commands)
while_loop(condition=condition,commands=commands)
# for_loop(0,5,2,['print("hi")','print("hi")','a=a+1'])
# do_while_loop('a>5',['print("hello")','a+=2'])
def switch(*case):
__increment = 0
while __increment < len(case):
conditions_commands = case[__increment]
condition = conditions_commands[0]
commands = conditions_commands[1]
__increment +=1
# print(condition,commands)
if eval(condition):
for command in commands:
exec(command)
__increment = len(case)
# c1 = ['a>4',['print("1")']]
# c2 = ['a==4',['print("2")']]
# c3 = ['a>4',['print("3")']]
# switch(c3,c2,c1)
# # output('"hello"')
# def inputVar(*vars):
# for var in vars: