-
Notifications
You must be signed in to change notification settings - Fork 0
/
Exercise 5 - Love Calculator.py
201 lines (172 loc) · 7.96 KB
/
Exercise 5 - Love Calculator.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
'''
A program that tests the compatibility between two people.
To work out the love score between two people:
Take both people's names and
check for the number of times the letters in the word TRUE occurs.
Then check for the number of times the letters in the word LOVE occurs.
Then combine these numbers to make a 2 digit number.
For Love Scores less than 10 or greater than 90, the message should be:
"Your score is **x**, you go together like coke and mentos."
For Love Scores between 40 and 50, the message should be:
"Your score is **y**, you are alright together."
Otherwise, the message will just be their score. e.g.:
"Your score is **z**."
e.g.
name1 = "Angela Yu"
name2 = "Jack Bauer"
T occurs 0 times
R occurs 1 time
U occurs 2 times
E occurs 2 times
TotalTRUE = 5
L occurs 1 time
O occurs 0 times
V occurs 0 times
E occurs 2 times
TotalLOVE = 3
Love Score = 53(i.e TotalTRUETotalLOVE)
'''
print("Welcome to the Love Calculator!\n")
print("""
.;;;, .;;;, .;;;, .;;;,
.;;;,;;;;;,;;;;;,.;;;, .;;;.,;;;;;,;;;;;,;;;.
;;;;oOOoOOoOOoOOoOOo;;;. .,. .;;;oOOoOOoOOoOOoOOo;;;;
.,,.`oOOo' `OoOOo,;;;;;,oOOoO' `oOOo;',,.
;;;;oOOo' ,;;;, `OoOOo;oOOoO' ,;;;, `oOOo;;;;
`;;OOoO' ;;;' `OOO' `;;; `OoOO;;'
,;;,OOoO ;; " ;; OoOO,;;,
;;;;OOoO `; ,;;. ;' OoOO;;;;
``.;OOoO, `; ` ;; .;;. ;; ;; .;;, ;' ,OoOO;,''
;;;;OOoO, ;; ; ; `; ;' ;..' ,OoOO;;;;
```.;OOoO, ;,;;, `;;' `;' `;;' ,OoOO;,'''
;;;;OOoO, ' ', , ,OoOO;;;;
```,;OOoO,. '' .,OoOO;,'''
;;;;OOoO,. .,OoOO;;;;
````,;OOoO,. .,OoOO;, '''
;;;;;OOoO,. .,OoOO;;;;
`````,;OOoO,. .,OoOO;,''''
;;;;;OOoOOoOO;;;;;
`````;;OO;;'''''
`;;;;'
""")
helpOrNot = input("If you need help, type 'help' else type any letter\n")
if helpOrNot == "help":
print("""
To work out the love score between two people:
Take both people's names and
check for the number of times the letters in the word TRUE occurs.
Then check for the number of times the letters in the word LOVE occurs.
Then combine these numbers to make a 2 digit number.
e.g.
name1 = "Angel Yuan"
name2 = "Jack Bauer"
T occurs 0 times
R occurs 1 time
U occurs 2 times
E occurs 2 times
TotalTRUE = 5
L occurs 1 time
O occurs 0 times
V occurs 0 times
E occurs 2 times
TotalLOVE = 3
Love Score = 53
""")
name1 = input("\nWhat is your name? \n")
name2 = input("What is their name? \n")
else:
name1 = input("\nWhat is your name? \n")
name2 = input("What is their name? \n")
#Write your code below this line 👇
combined_string = name1 + name2
lowercase_string = combined_string.lower()
# check for the number of times the letters in the word TRUE occurs in both names.
t = lowercase_string.count('t')
r = lowercase_string.count('r')
u = lowercase_string.count('u')
e = lowercase_string.count('e')
true = t + r + u + e
# check for the number of times the letters in the word LOVE occurs.
l = lowercase_string.count('l')
o = lowercase_string.count('o')
v = lowercase_string.count('v')
e = lowercase_string.count('e')
love = l + o + v + e
# combine true_count and love_count to form 2 digit number
truelove = str(true) + str(love)
love_score = int(truelove)
if love_score < 10 or love_score > 90:
print(
f"\nYour score is {love_score}, \nyou go together like coke and mentos.")
print("""
\\ ___/________
___ ) , @ / \\ \\
@___, \ / @__\ /\ @___/ \@/
/\__, | /\_, \/ / /\__/ |
/ \ / @\ / \ ( / \ / / \\
_/__|___/___/______/__|____\\_______/__/__________|__\__
""")
elif love_score < 50 and love_score > 40:
print(f"\nYour score is {love_score}, \nyou are alright together.")
print("""
O ~O
<|\ /|\\
| ~o/ | \\o ~o/ _o
|\ /| |\ |\ /| |\\
/ | / \ |// > / \ / >
""")
else:
print(f"\nYour score is {love_score}. You can be best partners.")
print("""
.,;;x+nxnnnn,,.
.;XXHHMM!!%M??!!?MXMX;,
;!X?XXXXdXXTS!!!?MM!HXMX.
.<!MH@MM??????M88BB8$$MURMM!;
.!XMM!!!!MMMMXWWW@@H?????R$U?$Xx
;!!??!!!!"';!XX?M$$NWX'<:<'??M!R5!;
<!!!!'' ;;!!!!!!??T$$$$H!!!!!:':`!M!!;
<!!!!';XH!!!!!!'!!!!XMRT?!!'<'':. 4H!';
!'''<';X!!!'' .. `'"TTM%!':<>.XXh .!' <;;
!! '<''J!!!' :Xx ! ..:<!!!!!'' X$$5X'</'!!!!
<'`''' '' !!XxL<!H!!!!!!!''X$$$$X:;<X!!!!'
' <'' .X! !!>XX'' '!'uuuid$$$$$5P:?M!>!-'
'!!''` .id$d5XL`X%!?XsuJJ$$$$F????XX!`<!'!'';>));<!!!!;;-.
':''.<X55$$$$$X!:!!Xd3$$$$$$$$X-x> `!' .;!!?;;<XXX!!!!!!!:
.;!XX5$$$$$$$X?!!HX$$$$33X$$$F;,,;!" :);,,,`''<!!!!!!!!!!!:.
:sL :!XXXd$$$$$$$$F'!!X53XXX3JJJXSX!XXX <:JX$$$$$$o.';<<!XX!!X!!!!
xX$3`!5$$55$$$$$$$5!`!!3$$3333X??SX!XX$! .XYX$$$$$$$$$h <;<!!?!!!!X!!
'!X3$%<555XX55$$$$$!!:`!?X$3XXt3$3XXL?"?> 'XF""?$$$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