-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfriend_calc.py
More file actions
48 lines (39 loc) · 1.33 KB
/
friend_calc.py
File metadata and controls
48 lines (39 loc) · 1.33 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
# Function to calculate friendship score
def calculate_friendship_score(name1, name2):
# Define rules for awarding points
vowel_points = 1
friend_points = 2
# Define vowels and characters in the word "friend"
vowels = "AEIOUaeiou"
friend_chars = "FRIENDfriend"
# Initialize score variables
score1 = 0
score2 = 0
# Loop through characters in name1 and name2
for char in name1:
if char in vowels:
score1 += vowel_points
if char in friend_chars:
score1 += friend_points
for char in name2:
if char in vowels:
score2 += vowel_points
if char in friend_chars:
score2 += friend_points
# Calculate total score
total_score = score1 + score2
return total_score
# Get names from user input
name1 = input("Enter name 1: ")
name2 = input("Enter name 2: ")
# Calculate friendship score
friendship_score = calculate_friendship_score(name1, name2)
# Display personalized message based on score
if friendship_score <= 5:
print("Not very compatible. Keep working on your friendship!")
elif friendship_score <= 10:
print("Moderately compatible. There's room for improvement!")
elif friendship_score <= 15:
print("Very compatible! You make great friends!")
else:
print("Extremely compatible! You're the best of friends!")