summaryrefslogtreecommitdiff
path: root/py03/ex6
diff options
context:
space:
mode:
authoryctct <yctct@yctct.com>2026-06-07 08:59:04 +0200
committeryctct <yctct@yctct.com>2026-06-07 08:59:04 +0200
commit15115b4c52bfda0d1cca9fa1155beecbb873ec35 (patch)
treeb3f0975e63eb04dcba732a78ce9bd9abda8acf01 /py03/ex6
First commit, add all files
Diffstat (limited to 'py03/ex6')
-rwxr-xr-xpy03/ex6/ft_data_alchemist.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/py03/ex6/ft_data_alchemist.py b/py03/ex6/ft_data_alchemist.py
new file mode 100755
index 0000000..c1d5794
--- /dev/null
+++ b/py03/ex6/ft_data_alchemist.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python3
+
+import random
+
+print("=== Game Data Alchemist ===")
+mixed = ['Alice', 'bob', 'Charlie', 'dylan',
+ 'Emma', 'Gregory', 'john', 'kevin', 'Liam']
+print("Initial list of player:", mixed)
+print()
+all_cap = [name.capitalize() for name in mixed]
+print("New list with all names capitalized", all_cap)
+print()
+cap_only = [name.capitalize() for name in mixed if name == name.title()]
+print("New list of capitalized names only", cap_only)
+print()
+# for name in all_cap:
+# score = random.randint(1,300)
+# d[name] = score
+d = {name: random.randint(1, 300) for name in all_cap}
+print("Score dict;", d)
+print()
+total_score = sum(d[name] for name in d)
+nb_names = len(all_cap)
+average = round(total_score / nb_names, 2)
+print("Score average is:", average)
+print()
+# ahigher = {}
+# for name in d:
+# if d[name] > average:
+# ahigher[name] = d[name]
+# print(ahigher)
+higher = {name: d[name] for name in d if d[name] > average}
+print("High scores:", higher)