-
Notifications
You must be signed in to change notification settings - Fork 9
/
display_7segments.py
117 lines (101 loc) · 1.91 KB
/
display_7segments.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# 7 SEGMENTS DISPLAY
# This program shows a numbers string like a 7 segments display
# By Alessandro Silvestri, assignement solved for Python Institute
one = [
[' ', ' ', '#'],
[' ', ' ', '#'],
[' ', ' ', '#'],
[' ', ' ', '#'],
[' ', ' ', '#'],
]
two = [
['#', '#', '#'],
[' ', ' ', '#'],
['#', '#', '#'],
['#', ' ', ' '],
['#', '#', '#'],
]
three = [
['#', '#', '#'],
[' ', ' ', '#'],
['#', '#', '#'],
[' ', ' ', '#'],
['#', '#', '#'],
]
four = [
['#', ' ', '#'],
['#', ' ', '#'],
['#', '#', '#'],
[' ', ' ', '#'],
[' ', ' ', '#'],
]
five = [
['#', '#', '#'],
['#', ' ', ' '],
['#', '#', '#'],
[' ', ' ', '#'],
['#', '#', '#'],
]
six = [
['#', '#', '#'],
['#', ' ', ' '],
['#', '#', '#'],
['#', ' ', '#'],
['#', '#', '#'],
]
seven = [
['#', '#', '#'],
[' ', ' ', '#'],
[' ', ' ', '#'],
[' ', ' ', '#'],
[' ', ' ', '#'],
]
eight = [
['#', '#', '#'],
['#', ' ', '#'],
['#', '#', '#'],
['#', ' ', '#'],
['#', '#', '#'],
]
nine = [
['#', '#', '#'],
['#', ' ', '#'],
['#', '#', '#'],
[' ', ' ', '#'],
['#', '#', '#'],
]
zero = [
['#', '#', '#'],
['#', ' ', '#'],
['#', ' ', '#'],
['#', ' ', '#'],
['#', '#', '#'],
]
def print_line(num, numline):
print(num[numline][0] + num[numline][1] + num[numline][2], end=' ')
txt = input('Insert a number: ')
print()
for j in range(5):
for i in range(len(txt)):
if txt[i] == '1':
print_line(one, j)
elif txt[i] == '2':
print_line(two, j)
elif txt[i] == '3':
print_line(three, j)
elif txt[i] == '4':
print_line(four, j)
elif txt[i] == '5':
print_line(five, j)
elif txt[i] == '6':
print_line(six, j)
elif txt[i] == '7':
print_line(seven, j)
elif txt[i] == '8':
print_line(eight, j)
elif txt[i] == '9':
print_line(nine, j)
elif txt[i] == '0':
print_line(zero, j)
print()
print()