O‘ZBEKISTON RESPUBLIKASI SOLIQ QO‘MITASI
HUZURIDAGI FISKAL INSTITUT
“Iqtisodiyotda dasturlash”
fanidan
№4 - laboratoriya ishi
Bajardi: SST-03-22 guruh talabasi
Murodov Shaxriyor
Qabul qildi: Sotvoldiyev D.M
Toshkent – 2023
Mavzu: Modullar va Fayllar bilan ishlash funksiyalarini o’rganish
Variant №13.
Toshkent shaxri tumanlari nomlaridan iborat kortej berilgan bo’lsin. Berilgan matn faylida qaysi tuman nomi necha marta yozilganligini aniqlash dasturini tuzing.
Dastur kodi:
districts = ["Mirzo Ulugbek", "Yashnobod", "Yakkasaroy", "Mirobod", "Shayhontohur", "Chilonzor", "Hamza"]
with open("tumanlar.txt", "r") as file:
text = file.read()
counts = {}
for district in districts:
count = text.count(district)
counts[district] = count
for district, count in counts.items():
print("{0}: {1}".format(district, count))
Do'stlaringiz bilan baham: |