Last active
June 21, 2022 18:45
-
-
Save muhammedfurkan/e4c193eeaa1aeee999f91c3fa933117b to your computer and use it in GitHub Desktop.
odev 1 çözüm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = { | |
"pazartesi": 0, | |
"sali": 0, | |
"carsamba": 0, | |
"persembe": 0, | |
"cuma": 0, | |
"cumartesi": 0, | |
"pazar": 0, | |
"toplam": 0, | |
} | |
for my_data in data: | |
if my_data == "toplam": | |
continue | |
data[my_data] = int(input(f"{my_data} günü için sayı giriniz: ")) | |
toplam = sum(data.values()) | |
data['toplam'] = toplam | |
with open("85_odev\dataNew.txt", "w") as file: | |
for my_data, value_ in data.items(): | |
file.write(f"{my_data} : {value_}\n") | |
with open("85_odev\dataNew.txt", "r") as file: | |
for line in file: | |
if line.startswith("toplam"): | |
print(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = { | |
"ocak": 0, | |
"şubat": 0, | |
"mart": 0, | |
"nisan": 0, | |
"mayıs": 0, | |
"haziran": 0, | |
"temmuz": 0, | |
"ağustos": 0, | |
"eylül": 0, | |
"ekim": 0, | |
"kasım": 0, | |
"aralık": 0 | |
} | |
def getKeysByValue(dictOfElements, valueToFind): | |
listOfItems = dictOfElements.items() | |
return [item[0] for item in listOfItems if item[1] == valueToFind] | |
for my_data in data: | |
data[my_data] = int(input(f"{my_data} ayı için yagis miktarını giriniz: ")) | |
toplam = sum(data.values()) | |
data['toplam'] = toplam | |
ortalama = toplam / len(data) | |
en_dusuk = min(data.values()) | |
en_yuksek = max(data.values()) | |
print(f"toplam yağış miktarı: {toplam}") | |
print(f"ortalama yağış miktarı: {ortalama}") | |
print(f"en düşük yağış alan ay: {getKeysByValue(data, en_dusuk)[0]}") | |
print(f"en yüksek yağış alan ay: {getKeysByValue(data, en_yuksek)[0]}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
count = 1 | |
user_list = [] | |
while count <= 20: | |
user_input = input(f"{count}. sayı giriniz: ") | |
try: | |
if user_input.isdigit(): | |
user_list.append(int(user_input)) | |
count += 1 | |
else: | |
print("Lütfen sayı giriniz.") | |
except: | |
print("Lütfen sayı giriniz.") | |
continue | |
list_max = max(user_list) | |
list_min = min(user_list) | |
list_sum = sum(user_list) | |
list_avg = list_sum / len(user_list) | |
print(f"En büyük sayı: {list_max}") | |
print(f"En küçük sayı: {list_min}") | |
print(f"Toplam: {list_sum}") | |
print(f"Ortalama: {list_avg}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment