forked from fenyx-it-academy/VIT-Python-4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhalil_Week4_odev.py
115 lines (85 loc) · 2.98 KB
/
halil_Week4_odev.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
#Soru1
liste = [1, 2, 3, 41, 2, 2, 4, 4, 5, 6, 76, 34, 1, 2]
tekrarlanan = set()
listem = {}
for i in liste:
if liste.count(i) > 1:
tekrarlanan.add(i)
listem[i] = liste.count(i)
for i, j in listem.items():
print(i, "sayisi", j, "kere")
print(
f"tekrar etmistir.\nTekrar eden sayilarin listesi:\t{list(listem.keys())}")
#################################
#Soru2
menu = {'kebap': 20, 'salata': 13, 'ayran': 4, 'kola': 6, 'tatli': 14,
}
print(
"""ABC Lokantasina Hos Geldiniz
1--Kebap : 20 $
2--Salata : 13 $
3--Ayran : 4 $
4--Kola : 6 $
5--Tatli : 14 $
Cikmak icin "q" giriniz""")
siparis_ve_sayisi = {}
while True:
musteri = input("Lutfen Siparisinizi giriniz : ")
if musteri == "1":
musteri = "kebap"
elif musteri == "2":
musteri = "salata"
elif musteri == "3":
musteri = "ayran"
elif musteri == "4":
musteri = "kola"
elif musteri == "5":
musteri = "tatli"
if musteri in siparis_ve_sayisi:
siparis_ve_sayisi[musteri] += 1
elif musteri not in siparis_ve_sayisi and musteri in menu:
siparis_ve_sayisi[musteri] = 1
if musteri == "q":
break
elif musteri not in menu:
pass
total = 0
for i, j in menu.items():
for k in siparis_ve_sayisi.keys():
if k == i:
total += j
print("""
*************____________SIPARISLER____________*************""")
for i, j in siparis_ve_sayisi.items():
print(f"{j} adet\t {i}")
print("Toplam ucret : ", total, "dolar")
#################
#Bonus
MORSE_CODE_DICT = {'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--',
'X': '-..-', 'Y': '-.--', 'Z': '--..', '1': '.----', '2': '..---', '3': '...--', '4': '....-', '5': '.....', '6': '-....', '7': '--...', '8': '---..', '9': '----.', '0': '-----', ', ': '--..--', '.': '.-.-.-', '?': '..--..', '/': '-..-.', '-': '-....-', '(': '-.--.', ')': '-.--.-'}
print("""
Morstan Latin alfabesine cevirmek icin 1
Yazidan Mors alfabesine cevirmek icin 2""")
secim = int(input("Secim yapiniz 1^2 "))
while True:
if secim == 1:
morse_to_name = input("Mors giriniz")
morse_to_name = morse_to_name.split()
result_mors = []
for i in morse_to_name:
for j, k in MORSE_CODE_DICT.items():
if i == k:
result_mors.append(j)
print("".join(result_mors))
break
elif secim == 2:
name_to_morse = input("Isim giriniz: ").upper()
result_name = []
for k in name_to_morse:
for i, j in MORSE_CODE_DICT.items():
if k == i:
result_name.append(j)
print(*result_name)
break
else:
print("Hatali giris yaptiniz tekrar deneyiniz!")