-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtraffic lights.py
96 lines (90 loc) · 1.65 KB
/
traffic lights.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#matthew dove
#traffic lights
#16/09/2015
import time
import random
A= "green"
B= "green"
C= "red"
D= "red"
x=0
button=0
Buttonpressed = False
while Buttonpressed == True:
A = "red"
B = "red"
C = "red"
D = "red"
print("")
print("a is",A)
print("b is",B)
print("c is",C)
print("d is",D)
print("")
time.sleep(2)
Buttonpressed = False
for x in range (1,10):
A = "green"
B = "green"
C = "red"
D = "red"
print("")
print("a is",A)
print("b is",B)
print("c is",C)
print("d is",D)
print("")
button = random.randint(1,5)
if button==5:
A = "red"
B = "red"
C = "red"
D = "red"
print("")
print("a is",A)
print("b is",B)
print("c is",C)
print("d is",D)
print("")
time.sleep(2)
x=x+1
else:
time.sleep(5)
A = "red"
B = "red"
C = "red_and_amber"
D = "red_and_amber"
print("")
print("a is",A)
print("b is",B)
print("c is",C)
print("d is",D)
print("")
button = random.randint(1,5)
if button==5:
A = "red"
B = "red"
C = "red"
D = "red"
print("")
print("a is",A)
print("b is",B)
print("c is",C)
print("d is",D)
print("")
time.sleep(2)
x=x+1
else:
time.sleep(2)
A = "red"
B = "red"
C = "green"
D = "green"
print("")
print("a is",A)
print("b is",B)
print("c is",C)
print("d is",D)
print("")
time.sleep(5)
x= x+1