Append metodining vazifasi qanday?
Download 37.76 Kb.
|
test.txt
3###1.
+++ ro'yxat oxiridan yangi element qo'shadi %%% ###2.
+++ satrdagi bir so'z yoki harfni boshqasi bilan almashtiradi %%% ###3.
+++ satrni ko'rsatilgan belgi bo'yicha qismlarga bo'ladi va list sifatida qaytaradi %%% ###4.
+++ Satrda raqamlar ishtirok etganligini tekshirish %%% ###5.
+++ ro'yxatni tartiblaydi %%% ###6.
+++ bir nechta stringlarni birlashtirish yoki bir ro'yxatni bir stringga aylantirish %%% ###7.
+++ belgilangan elementning indeksini aniqlaydi %%% ###8.
+++ belgilangan qiymatga teng elementlar sonini aniqlaydi %%% ###9.
+++ matning birinchi harfini katta qilish va qolgan barcha harflarni kichik qilishdir %%% ###10.
+++ satrdagi barcha so'zlarni katta harflar bilan yozadi: %%% ###11.
+++ stringning butun harflarining katta harf (bosh harf) bo'lishini tekshiradi va shunchaki, agar barcha harflar katta harf bo'lsa True qiymatini qaytaradi, aks holda False qiymatini qaytaradi. %%% ###12.
+++ funksiyasi satrning boshi va oxirida bo'shliqlar bo'lsa, olib tasdiqlaydi %%% ###13.
+++ stringning faqat sonlar (0-9) yoki boshqa raqam ko'rinishidagi belgilarni (masalan, ½, ⅓, ⅕, ², ³, ¼, ¾ kabi) o'z ichiga olganligini tekshiradi. Agar string faqat sonlar yoki raqam ko'rinishidagi belgilar o'z ichiga olsang, isnumeric() metodi True qiymatini qaytaradi, aks holda False qiymatini qaytaradi. %%% ###14.
+++ Ro'yxatda nechta element borligini aniqlash uchun len() funksiyasi ishlatiladi %%% ###15.
+++ stringning berilgan boshlang'ich substring bilan boshlanishini tekshiradi. %%% ###16.
+++ stringda berilgan substringni qidiradi va uni topganda substringning boshlang'ich indeksini qaytaradi. Agar substring topilmasa, find() metodi -1 qiymatini qaytaradi. %%% ###17.
+++ Satr harf yoki raqamlardan iboratligini tekshiradi. %%% ###18.
+++ stringdagi barcha harflarni kichik harflarga o'zgartiradi va yangi stringni qaytaradi. %%% ###19.
+++ stringda barcha harflarning kichik harf bo'lishini tekshiradi(true yoki false qaytaradi) %%% ###20.
+++ matndagi har bir so'zning bosh harfini katta harf bilan yozishga imkon beradi %%% ###21.
+++ matndagi bo'sh joylarni (o'ng tomondagi bo'shliqlarni) olib tashlaydi %%% ###22.
+++ matndagi format bog'liq o'rniga kerakli qiymatlarni joylashishga imkon beradi %%% ###23.
+++ matnni qatorlarga bo'lib ajratadi va natijada qatorlarni ro'yxat sifatida qaytaradi %%% ###24.
+++ lstrip() metodi, bir stringning chap tomondagi bo'shliklarni olib tashlaydi va natijadagi yangi stringni qaytaradi. %%% ###25.
+++ isalpha() metodi, bir stringning faqat harflardan iborat bo'lishini tekshiradi. Agar string faqat harflardan tashkil topgan bo'lsa (a-z yoki A-Z), True qiymatini qaytaradi; aks holda False qiymatini qaytaradi. %%% ###26.
+++ reverse() funksiyasi ro'yxatning joriy holatdagi tartibini teskarisiga o'zgartiradi. %%% ###27.
+++ isdecimal() metodi, bir stringning faqat raqamlardan iborat bo'lishini tekshiradi. Agar string faqat sonlardan tashkil topgan bo'lsa (0 dan 9 gacha raqamlar), True qiymatini qaytaradi; aks holda False qiymatini qaytaradi. %%% ###28.
+++ swapcase() metodi, bir stringdagi harflarni katta harflardan kichik, kichik harflardan esa katta harflarga o'zgartiradi. Bu metoddan foydalanilgan natijadagi yangi string qaytariladi. Boshqa belgilar (raqamlar, belgilar, bo'shliklar) o'zgartirilmaydi. %%% ###29.
+++ istitle() - Satrda so'zlar bosh harf bilan boshlanishini tekshirish %%% ###30.
+++ encode() metodi, bir stringni belgilarni Unicode kodlariga asoslangan byte-lar qatoriga aylantiradi. Bu metoddan foydalanarak stringni byte-lar sifatida kodlash va xotiradan jo'natish imkoniyatiga ega bo'lasiz. %%% ###31.
+++ satir identifikator talablariga mos kelishini tekshiradi ya'ni arflar raqamlardan iborat bo'lib raqambilan boshlanmagan va past chiziqcha ishlatish hamda bo'sh joy ishlatilamgan satir bo'lsa True aks holda False %%% ###32.
+++ rfind() metodi, berilgan bir qator (string) ichida berilgan bir boshlang'ich indeksdan boshlab qidirishni boshlab, berilgan bir satrni (substring) qidiradi va uning indeksini qaytaradi. %%% ###33.
+++ clear() metodi, bir lug'atdagi barcha elementlarni o'chiradi. %%% ###34.
+++ Ro'txatning nusxalaydi %%% ###35.
+++ Oxiriga hamma elementlarni qo'shib list ro'yxatini kengaytiradi %%% ###36.
+++ insert() metodi, bir ro'yxatning (list) berilgan indeksiga yangi bir element qo'shadi. %%% ###37.
+++ remove() metodi, bir ro'yxatning (list) ichidan berilgan elementni o'chiradi. %%% ###38.
+++ Funktsiya ketma-ketlikdagi eng kichik elementni topadi. %%% ###39.
+++ Funktsiya ketma-ketlikdagi eng katta elementni topadi. %%% ###40.
+++ qiymatlarni yig'ish uchun sum() funktsiyasidan foydalaniladi. %%% ###41.
+++ Ro'yxatning i-elementini o'chiradi va qaytaradi. Agarda indeks ko'rsatilmagan bo'lsa oxirgi element o'chiriladi %%% ###42.
+++ update() %%% ###43.
+++ pop() metodi yoki del operatoridan foydalaniladi %%% ###44.
+++ keys() %%% ###45.
+++ values() %%% ###46.
+++ items() %%% ###47.
+++ pop() metodi yoki del operatoridan foydalaniladi %%% ###48.
+++ update() %%% ###49.
+++ Lug'atda berilgan kalitni (key) tekshirish uchun in operatoridan foydalaniladi. %%% ###50.
+++ Lug'atda berilgan qiymatni (value) tekshirish uchun values() metodi yordamida lug'atdagi barcha qiymatlarni olish kerak. %%% ###51.
+++ Lug'atdagi elementlar sonini qaytaruvchi metod len() funksiyasi yordamida amalga oshiriladi. %%% ###52.
+++ Lug'atni bo'shatingiz uchun clear() metodi yordamida lug'atdagi barcha elementlarni o'chirishingiz mumkin. %%% ###53.
+++ Lug'atdagi barcha elementlarni matnlardan iborat ro'yxatga o'girish uchun items() metodi yordamida lug'atdagi barcha elementlarni olish va ro'yxatga o'girish kerak. %%% ###54.
+++ Lug'atdagi kalitlarni matnlardan iborat ro'yxatga o'girish uchun keys() metodi yordamida lug'atdagi kalitlarni olish va ro'yxatga o'girish kerak. %%% ###55.
+++ Lug'atdagi barcha qiymatlarni ro'yxatga olish uchun values() metodi yordamida lug'atdagi barcha qiymatlarni olish va ro'yxatga o'girish kerak. %%% ###56.
+++ Lug'atdagi biror kalitani (key) qiymatini olish uchun get() metodi yordamida lug'atdagi kalitning qiymatini olish kerak. %%% ###57.
+++ Lug'atdagi biror kalitani (key) qiymatini o'zgartirish uchun lug'atning o'sha kalitini chaqirib, yangi qiymatni yuklash kerak. Agar kalit mavjud bo'lmasa, yangi element qo'shish yordamida ham o'zgartirish amalga oshirilishi mumkin. %%% ###58.
+++ Lug'atdagi biror elementni (kalita va qiymat) olib tashlash uchun pop() metodi yordamida berilgan kalitga mos keluvchi elementni o'chirib, elementni qaytaradi. %%% ###59.
+++ Lug'atdagi elementlarning sonini qaytaruvchi metod len() funksiyasi yordamida amalga oshiriladi. %%% ###60.
+++ Berilgan kalitani (key) lug'atda tekshirib borish uchun in operatoridan foydalanish mumkin. %%% ###61.
+++ i in dct.values() %%% ###62.
+++ keys = list(a.keys()) %%% ###63.
+++ values = list(a.values()) %%% ###64.
+++ keys_and_values = list(a.items()) %%% ###65.
+++ dct.pop('a') # dct lug'at nomi, 'a' key %%% ###66.
+++ dct.pop('a') # dct lug'at nomi, 'a' key %%% ###67.
+++ dct.update({"key": "value"}) %%% ###68.
+++ Faylni o'qish uchun asosan open() funktsiyasidan foydalaniladi %%% ###69.
+++ Faylni yaratish uchun open() funktsiyasidan ham foydalanish mumkin, ammo u yaratilgan faylni ochish uchun va fayl ustida amallar bajarish uchun xizmat qiladi. Faylni yaratish uchun esa open() funktsiyasi "x" (write mode) parametri bilan ishlatiladi. %%% ###70.
+++ # faylga ma'lumot yozish file.write('Assalomu alaykum, dunyo!') %%% ###71.
+++ # faylni yopish file.close() %%% ###72.
+++ # faylga qo'shish file.write(' Assalomu alaykum, Python!') %%% ###73.
+++ os.path.exists() %%% ###74.
+++ os.path.getsize() %%% ###75.
+++ read() yoki readline() %%% ###76.
+++ readlines() %%% ###77.
+++ read() %%% ###78.
+++ write() yoki writelines() %%% ###79.
+++ write() %%% ###80.
+++ shutil.copy() yoki shutil.copyfile() %%% ###81.
+++ Faylni o'qish uchun ochganidan so'ng, faylni o'qish uchun "read()" funksiyasidan foydalanish mumkin. %%% ###82.
+++ import os os.rename("eski_nomi.txt", "yangi_nomi.txt") %%% ###83.
+++ os.remove("filename.txt") yoki os.unlink("filename.txt") %%% ###84.
+++ Fayldagi ma'lumotlarni faylning boshiga yozish uchun "seek()" metodi yordamida faylning indeksini o'zgartirish mumkin. %%% ###85.
+++ open() %%% ###86.
+++ read() %%% ###87.
+++ Faylning barcha qatorlarini o'qish uchun, faylni ochish va readlines() metodi yordamida fayldagi har bir qatorni ro'yxatga olish mumkin. readlines() metodi, fayldagi ma'lumotlarni qatorma-qatorma o'qib, har bir qatorni ro'yxatga olib, ro'yxatni qaytaradi. Masalan, quyidagi kod fayldagi hamma qatorlarni ro'yxatga olib lines o'zgaruvchisiga yuklaydi: %%% ###88.
+++ close() %%% ###89.
+++ exists() %%% ###90.
+++ write() %%% ###91.
+++ Guido van Rossum tomonidan 1989-yilda yaratilgan %%% ###92.
+++ 1991 yil %%% ###93.
+++ o'zgaruvchilar ularga bir qiymat tayinlanishi bilan avtomatik ravishda yaratiladi./ ixtiyoriy joyda %%% ###94.
+++ Python tilida matnlar string, ' ' yoki " " da ifodalanadi %%% ###95.
+++ len() %%% ###96.
+++ 3 ta integers,floats,complex numbers %%% ###97.
+++ ' ' va " " %%% ###98.
+++ list %%% ###99.
+++ sort() %%% ###100.
+++ pop() %%% ###101.
+++ if shart operatori bilan %%% ###102.
+++ and %%% ###103.
+++ while %%% ###104.
+++ def belgisi %%% ###105.
+++ Funksiya ichida if operatori orqali sonlarni solishtiriladi va katta son return kalit so'zi yordamida qaytariladi. %%% ###106.
+++ if %%% ###107.
+++ else %%% ###108.
+++ elif %%% ###109.
+++ and %%% ###110.
+++ or %%% ###111.
+++ not %%% ###112.
+++ Python tilida "in" belgisi biror qiymatning boshqa qiymat ichida bo'lishini tekshirish uchun ishlatiladi %%% ###113.
+++ Python tilida range() funktsiyasi biror oralikdagi butun sonlarni generatsiya qilish uchun ishlatiladi. %%% ###114.
+++ Python tilida "break" kalit so'zi tsikldan chiqish uchun ishlatiladi. %%% ###115.
+++ Python tilida "continue" kalit so'zi tsiklni davom ettirish uchun ishlatiladi. "continue" tsiklning ichida ishlatiladi va tsiklni to'xtatmay, keyingi qadamga o'tishni boshqaradi. %%% ###116.
+++ Python tilida "try-except" operatori xatolarni qayta ishlash uchun ishlatiladi. %%% ###117.
+++ Python tilida "import" belgisi modullarni dasturning ichiga chaqirish uchun ishlatiladi. Modul Pythonda funksiyalar, sinflar va boshqa qo'shimcha funksiyalarni o'z ichiga oladi va ularni dasturning boshqa qismlari bilan ulashishga yordam beradi. Modul import operatori yordamida import qilinadi. Modul nomi import qilinadigan dasturda ishlatilgan bo'lishi kerak %%% ###118.
+++ Python tilida "for" tsikli ro'yxatlar (list, tuple, range) yoki boshqa turdagi obyektlar ustida yurish uchun ishlatiladi. %%% ###119.
+++ Python tilida "while" tsikli belgilangan shart bajarilguncha amalga oshirish uchun ishlatiladi. %%% ###120.
+++ Python tilida "def" kalit so'zi funktsiyalarni yaratish uchun ishlatiladi. %%% ###121.
+++ Python tilida faylni yaratish uchun "open()" funksiyasidan foydalaniladi. %%% ###122.
+++ open() %%% ###123.
+++ Python tilida faylni yozish rejimida ochish uchun "w" ("write" yoki "yozish" deb ataluvchi) parametridan foydalaniladi. %%% ###124.
+++ Python tilida faylni qo'shish rejimida ochish uchun "a" ("append" yoki "qo'shish" deb ataluvchi) parametridan foydalaniladi. %%% ###125.
+++ read() %%% ###126.
+++ readlines() %%% ###127.
+++ "w" rejimida ochiladi va write() metodi qo'llaniladi. %%% ###128.
+++ "a" rejimida ochiladi va write() metodi qo'llaniladi. %%% ###129.
+++ open(fayl_nomi, "a") %%% ###130.
+++ close() %%% ###131.
+++ open() ---- variantga qarab %%% ###132.
+++ shutil.move() %%% ###133.
+++ os.rename() %%% ###134.
+++ os.path.exists() %%% ###135.
+++ os.path.getsize() %%% ###136.
+++ os.path.getmtime() %%% ###137.
+++ read() %%% ###138.
fayl = open("test.txt", "w") fayl.write("Salom, Dunyo!") fayl.close() +++ test.text faylga "Salom, Dunyo!" matni yoziladi. %%% ###139.
fayl = open("test.txt", "r") malumot = fayl.read() fayl.close() print(malumot) +++ Fayldagi ma'lumotlar malumot o'zgaruvchisida saqlanadi va ekranga chiqariladi %%% ###140.
fayl = open("test.txt", "a") fayl.write("Salom, Python!") fayl.close() +++ test.txt fayliga "Salom, Python!" matni qo'shiladi %%% ###141.
import os fayljoyi = "test.txt" if os.path.isfile(fayljoyi): print("Fayl mavjud") else: print("Fayl mavjud emas") +++ Fayl mavjud %%% ###142.
import os os.mkdir("testjayiz") +++ 'testjayiz' nomli direktoriya yaratiladi. %%% ###143.
import os os.rmdir("testjayiz") +++ "testjayiz" nomli direktoriya o'chiriladi (agar mavjud bo'lsa). %%% ###144.
import os fayljoyi = "test.txt" fayl_uzunligi = os.path.getsize(fayljoyi) print(fayl_uzunligi) +++ 27 %%% ###145.
import os fayljoyi = "test.txt" fayl_nomi = os.path.basename(fayljoyi) print(fayl_nomi) +++ test.txt %%% ###146.
import os fayljoyi = "yo'l/to/test.txt" otajoy = os.path.dirname(fayljoyi) print(otajoy) +++ yo'l/to %%% ###147.
import shutil shutil.copy("fayl1.txt", "fayl2.txt") +++ "fayl1.txt" fayli "fayl2.txt" nomi bilan nusxalanadi %%% ###148.
numbers= [1, 2, 3, 4, 5] result= 1 for num in numbers: result *= num print(result) +++ 120 %%% ###149.
import shutil shutil.move("fayll.txt", "papka/fayll.txt") +++ "fayll.txt" fayli "papka" papkasiga ko'chiriladi va yangi nomi "papka/fayll.txt" bo'ladi %%% ###150.
import os kataloglar = os.listdir(".") for katalog in kataloglar: if os.path.isdir(katalog): print(katalog) +++ Joriy ishchi direktoriyada mavjud bo'lgan barcha kataloglarni ekranga chiqaradi %%% ###151.
import os fayl = open("test.txt", "w") fayl.write("Salom, Dunyo!") fayl.close() os.rename("test.txt", "yangi_nomi.txt") +++ fayl nomi "test.txt" dan "yangi_nomi.txt" ga o'zgartiradi %%% ###152.
import os fayl = open("test.txt", "w") fayl.write("Salom, Dunyo!") fayl.close() os.remove("test.txt") +++ test.txt nomli fayl o'chiriladi %%% ###153.
a= [1, 2, 3] b=a a.append(4) print(b) +++ [1, 2, 3, 4] %%% ###154.
a= [1, 2, 3] b=a a= [4, 5, 6] print(b) +++ [1, 2, 3] %%% ###155.
a= "Hello" b=a a= "World" print(b) +++ Hello %%% ###156.
a= 10 b= 10 print(a is b) +++ True %%% ###157.
a= [1, 2, 3] b= [1, 2, 3] print(a is b) +++ False %%% ###158.
a= "Hello" b = "Hello" print(a is b) +++ True %%% ###159.
a= [1, 2, 3] b=a print(a == b) +++ True %%% ###160.
a= [1, 2, 3] b=a print(a is b) +++ True %%% ###161.
a= "Hello" b= "Hello" print(a is b) +++ True %%% ###162.
x=5 if x > 10: print("Katta") elif x < 5: print("Kichik") else: print("Bir xil") +++ Bir xil %%% ###163.
x = 15 if x > 10: print("Katta") elif x < 5: print("Kichik") else: print("Bir xil") +++ Katta %%% ###164.
x=5 if x > 5: print("Katta") elif x == 5: print("Teng") else: print("Kichik") +++ Teng %%% ###165.
x=3 if x > 5: print("Katta") elif x == 5: print("Teng") else: print("Kichik") +++ Kichik %%% ###166.
def my_func(x): if x > 0: return "Musbat" elif x < 0: return "Manfiy" else: return "Nol" result= my_func(5) print(result) +++ Musbat %%% ###167.
def my_func(x): if x > 0: return "Musbat" elif x < 0: return "Manfiy" else: return "Nol" result= my_func(-5) print(result) +++ Manfiy %%% ###168.
def my_func(x): if x > 0: return "Musbat" elif x < 0: return "Manfiy" else: return "Nol" result= my_func(0) print(result) +++ Nol %%% ###169.
def add_numbers(a, b): return a + b result= add_numbers(3, 4) print(result) +++ 7 %%% ###170.
def calculate_average(numbers): total = sum(numbers) average= total / len(numbers) return average result= calculate_average([1, 2, 3, 4, 5]) print(result) +++ 3.0 %%% ###171.
def is_even(number): if number% 2 == 0: return True else: return False result = is_even(7) print(result) +++ False %%% ###172.
def get_length(string): return len(string) result= get_length("Hello, world!") print(result) +++ 13 %%% ###173.
def is_prime(number): if number < 2: return False for i in range(2, int(number ** 0.5) + 1): if number % i == 0: return False return True result = is_prime(17) print(result) +++ True %%% ###174.
def get_max(numbers): max_number = numbers[0] for num in numbers: if num > max_number: max_number= num return max_number result= get_max([3, 9, 2, 7, 5]) print(result) +++ 9 %%% ###175.
def reverse_string(string): return string[::-1] result= reverse_string("Hello, world!") print(result) +++ !dlrow ,olleH %%% ###176.
def count_vowels(string): vowels = ['a' 'e' 'i' 'o' 'u'] count= 0 for char in string: if char.lower() in vowels: count+= 1 return count result= count_vowels("Hello, world!") print(result) +++ 0 %%% ###177.
numbers= [1, 2, 3, 4, 5] squared_numbers = [x ** 2 for x in numbers if x % 2 == 0] print(squared_numbers) +++ [4, 16] %%% ###178.
def factorial(n): if n == 0: return 1 return n * factorial( n - 1) result= factorial(5) print(result) +++ 120 %%% ###179.
def is_palindrome(word): reversed_word = word[::-1] if word == reversed_word: return True return False result = is_palindrome("level") print(result) +++ True %%% ###180.
def count_words(sentence): words= sentence.split() return len(words) result = count_words("I love Python programming") print(result) +++ 4 %%% ###181.
def get_power(base, exponent=2): return base ** exponent result = get_power(3) print(result) +++ 9 %%% ###182.
def multiply_numbers(*args): result= 1 for num in args: result *= num return result result= multiply_numbers(2, 3, 4) print(result) +++ 24 %%% ###183.
def find_average(*args): total = sum(args) average = total / len(args) return average result= find_average(1, 2, 3, 4, 5) print(result) +++ 3.0 %%% ###184.
def remove_duplicates(numbers): return list(set(numbers)) result= remove_duplicates([1, 2, 2, 3, 4, 4, 5]) print(result) +++ [1, 2, 3, 4, 5] %%% ###185.
def is_anagram(word1, word2): return sorted(word1) == sorted(word2) result= is_anagram("listen", "silent") print(result) +++ True %%% ###186.
def remove_whitespace(string): return string.replace(" ", "") result = remove_whitespace("Hello, world!") print(result) +++ Hello,world! %%% ###187.
def reverse_list(lst): return lst[::-1] result= reverse_list([1, 2, 3, 4, 5]) print(result) +++ [5, 4, 3, 2, 1] %%% ###188.
def calculate_discount(price, discount_rate=0.1): return price - (price * discount_rate) result= calculate_discount(1000) print(result) +++ 900.0 %%% ###189.
def is_power_of_two(n): return n > 0 and (n & (n - 1)) == 0 result= is_power_of_two(16) print(result) +++ True %%% ###190.
def remove_duplicates(string): unique_chars = [] for char in string: if char not in unique_chars: unique_chars.append( char) return ''.join(unique_chars) result= remove_duplicates("Hello, world!") print(result) +++ Helo, wrd! %%% ###191.
def calculate_average(*args ): total = sum(args) average = total / len(args) return average result= calculate_average(1, 2, 3, 4, 5) print(result) +++ 3.0 %%% ###192.
def is_odd(number): if number% 2 != 0: return True else: return False result = is_odd(6) print(result) +++ False %%% ###193.
def greet(name): return "Assalomu alaykum, "+name+"!" result= greet("Ali") print(result) +++ Assalomu alaykum, Ali! %%% ###194.
def count_lowercase(string): count= 0 for char in string: if char.islower(): count+= 1 return count result= count_lowercase("Hello, world!") print(result) +++ 9 %%% ###195.
def find_common_elements(list1, list2): common_elements = [] for element in list1: if element in list2: common_elements.append(element) return common_elements result= find_common_elements([1, 2, 3, 4, 5], [4, 5, 6, 7, 8]) print(result) +++ [4, 5] %%% ###196.
def calculate_square_area(side_length): return side_length ** 2 result = calculate_square_area(5) print(result) +++ 25 %%% ###197.
def find_max(numbers): max_number = numbers[0] for num in numbers: if num > max_number: max_number= num return max_number result= find_max([3, 9, 2, 7, 5]) print(result) +++ 9 %%% ###198.
def calculate_sum(*args): total= 0 for num in args: total+= num return total result= calculate_sum(1, 2, 3, 4, 5) print(result) +++ 15 %%% ###199.
def is_prime(number): if number < 2: return False for i in range(2, int(number ** 0.5) + 1): if number% i == 0: return False return True result = is_prime(11) print(result) +++ True %%% ###200.
def find_factorial(n): factorial = 1 for i in range(1, n+1): factorial *= i return factorial result = find_factorial(5) print(result) +++ 120 %%% ###201.
def calculate_celsius(fahrenheit): return (fahrenheit - 32) * 5 / 9 result = calculate_celsius(212) print(result) +++ Ushbu kodning bir xatoligi bor. result = calculate_celsius(212) va print(result) satrlari funktsiyani chaqirishdan keyin keladi va funktsiyadan qaytgan natijani "result" nomli o'zgaruvchiga yuklaydi, lekin "result" o'zgaruvchisini chiqarish uchun print() funksiyasi ishlatilmadi. %%% ###202.
def count_vowels(string): vowels = ['a' 'e' 'i' 'o' 'u'] count= 0 for char in string.lower(): if char in vowels: count+= 1 return count result= count_vowels("Hello, world!") print(result) +++ 0 %%% ###203.
def is_palindrome(word): return word== word[::-1] result = is_palindrome("madam") print(result) +++ True %%% ###204.
def calculate_power(base, exponent): return base ** exponent result = calculate_power(2, 3) print(result) +++ 8 %%% ###205.
def find_longest_word(words): longest_word = "" for word in words: if len(word) > len(longest_word): longest_word = word return longest_word result= find_longest_word(["apple", "banana", "cherry", "durian"]) print(result) +++ banana %%% ###206.
def calculate_hypotenuse(a, b): return (a**2 + b**2)**0.5 result = calculate_hypotenuse(3, 4) print(result) +++ 5.0 %%% ###207.
def find_common_characters(stringl, string2): common_characters = set(stringl) & set(string2) return ''.join(common_characters) result = find_common_characters( "hello", "world") print(result) +++ ol %%% ###208.
def calculate_average(*args): total = sum(args) average = total / len(args) return round(average, 2) result= calculate_average(1.5, 2.5, 3.5, 4.5, 5.5) print(result) +++ 3.5 %%% ###209.
def remove_duplicates(numbers): unique_numbers = [] for num in numbers: if num not in unique_numbers: unique_numbers.append(num) return unique_numbers result= remove_duplicates([1, 2, 2, 3, 4, 4, 5]) print(result) +++ [1, 2, 3, 4, 5] %%% ###210.
def calculate_average(numbers): total = sum(numbers) average= total/ len(numbers) return average result= calculate_average([1, 2, 3, 4, 5]) print(result) +++ 3.0 %%% ###211.
def is_prime(number): if number < 2: return False for i in range(2, int(number ** 0.5) + 1): if number% i == 0: return False return True result = is_prime(11) print(result) +++ True %%% ###212.
def count_lowercase(string): count= 0 for char in string: if char.islower(): count+= 1 return count result= count_lowercase("Hello, world!") print(result) +++ 9 %%% ###213.
def calculate_factorial(n): if n == 0: return 1 else: return n * calculate_factorial(n - 1) result = calculate_factorial(5) print(result) +++ 120 %%% ###214.
def find_odd_numbers(numbers): odd_numbers = [] for num in numbers: if num % 2 != 0: odd_numbers.append(num) return odd_numbers result= find_odd_numbers([1, 2, 3, 4, 5, 6, 7, 8, 9]) print(result) +++ [1, 3, 5, 7, 9] %%% ###215.
def calculate_power(base, exponent): result= 1 for _ in range(exponent): result *= base return result result = calculate_power(2, 5) print(result) +++ 32 %%% ###216.
def greet(name): if len(name) > 5: return "Assalomu alaykum, "+name+"!" else: return "Salom, " + name + "!" result= greet("Ali") print(result) +++ Salom, Ali! %%% ###217.
def find_average(numbers): total = sum(numbers) average= total/ len(numbers) return average result= find_average([2, 4, 6, 8, 10]) print(result) +++ 6.0 %%% ###218.
def is_even(number): return number % 2 == 0 result = is_even(7) print(result) +++ False %%% ###219.
def find_common_elements(list1, list2): common_elements = set(list1) & set(list2) return list(common_elements) result= find_common_elements([1, 2, 3, 4, 5], [4, 5, 6, 7, 8]) print(result) +++ [4, 5] %%% ###220.
def calculate_sum(*args): total = sum(args) return total result= calculate_sum(1, 2, 3, 4, 5) print(result) +++ 15 %%% ###221.
def capitalize_string(string): return string.capitalize() result= capitalize_string("hello, world!") print(result) +++ Hello, world! %%% ###222.
def calculate_sum(numbers): total= 0 for num in numbers: total+= num return total result= calculate_sum([1, 2, 3, 4, 5]) print(result) +++ 15 %%% ###223.
def find_max(numbers): max_num = numbers[0] for num in numbers: if num > max_num: max_num=num return max_num result= find_max([5, 3, 9, 1, 7]) print(result) +++ 9 %%% ###224.
def reverse_string(string): return string[::-1] result= reverse_string("hello, world!") print(result) +++ !dlrow ,olleh %%% ###225.
def check_palindrome(string): return string == string[::-1] result = check_palindrome("madam") print(result) +++ True %%% ###226.
def find_median(numbers): sorted_numbers = sorted(numbers) length = len(sorted_numbers) if length% 2 == 0: median= (sorted_numbers[length // 2] + sorted_numbers[length // 2 - 1]) / 2 else: median= sorted_numbers[length // 2] return median result= find_median([5, 2, 8, 1, 6, 4, 3, 7]) print(result) +++ 4.5 %%% ###227.
def calculate_product(*args): result= 1 for num in args: result *= num return result result= calculate_product(1, 2, 3, 4, 5) print(result) +++ 120 %%% ###228.
def convert_to_binary(decimal): return bin(decimal) result= convert_to_binary(10) print(result) +++ 0b1010 %%% ###229.
def is_vowel(letter): vowels = ['a' 'e' 'i' 'o' 'u'] return letter.lower() in vowels result = is_vowel('A') print(result) +++ False %%% ###230.
def calculate_power(base, exponent): if exponent == 0: return 1 else: return base * calculate_power(base, exponent - 1) result = calculate_power(2, 4) print(result) +++ 16 %%% ###231.
def count_occurrences(string, target): count= 0 for char in string: if char== target: count+= 1 return count result = count_occurrences("hello, world!", "l") print(result) +++ 3 %%% ###232.
def remove_duplicates(numbers): unique_numbers = list(set(numbers)) return unique_numbers result= remove_duplicates([1, 2, 2, 3, 4, 4, 5]) print(result) +++ [1, 2, 3, 4, 5] %%% ###233.
def calculate_factorial(n): if n == 0 or n == 1: return 1 else: return n * calculate_factorial(n - 1) result = calculate_factorial(5) print(result) +++ 120 %%% ###234.
def find_even_numbers(numbers): even_numbers = [num for num in numbers if num % 2 == 0] return even_numbers result= find_even_numbers([1, 2, 3, 4, 5, 6, 7, 8, 9]) print(result) +++ [2, 4, 6, 8] %%% ###235.
def check_prime(number): if number < 2: return False for i in range(2, int(number ** 0.5) + 1): if number% i == 0: return False return True result = check_prime(7) print(result) +++ True %%% ###236.
def find_common_characters(stringl, string2): common_characters = set(stringl) & set(string2) return list(common_characters) result = find_common_characters("hello", "world") print(result) +++ ['o', 'l'] %%% ###237.
def is_power_of_two(number): if number == 0: return False return number & (number - 1) == 0 result= is_power_of_two(16) print(result) +++ True %%% ###238.
def count_words(sentence): words= sentence.split() return len(words) result= count_words("Hello, world!") print(result) +++ 2 %%% ###239.
def is_fibonacci(number): a, b = 0, 1 while b < number: a, b = b, a + b return b == number result = is_fibonacci(13) print(result) +++ True %%% ###240.
def calculate_square_root(number): return number ** 0.5 result= calculate_square_root(16) print(result) +++ 4.0 %%% ###241.
def check_anagram(word1, word2): return sorted(word1.lower()) == sorted(word2.lower()) result= check_anagram("listen", "silent") print(result) +++ True %%% ###242.
def find_max(numbers): return max(numbers) result= find_max([5, 2, 8, 1, 6, 4, 3, 7]) print(result) +++ 8 %%% ###243.
def capitalize_words(sentence): words= sentence.split() capitalized_words = [word.capitalize() for word in words] return' '.join(capitalized_words) result = capitalize_words("hello, world!") print(result) +++ Hello, World! %%% ###244.
def calculate_power(base, exponent): return base ** exponent result = calculate_power(2, 4) print(result) +++ 16 %%% ###245.
def remove_duplicates(numbers): unique_numbers = list(set(numbers)) unique_numbers.sort() return unique_numbers result= remove_duplicates([1, 2, 2, 3, 4, 4, 5]) print(result) +++ [1, 2, 3, 4, 5] %%% ###246.
def check_odd_even(number): if number% 2 == 0: return "Juft son" else: return "Toq son" result = check_odd_even(7) print(result) +++ Toq son %%% ###247.
def calculate_factorial( n): factorial = 1 for i in range(1, n + 1): factorial *= i return factorial result= calculate_factorial(-5) print(result) +++ 1 %%% ###248.
def calculate_median(numbers): sorted_numbers = sorted(numbers) length = len(sorted_numbers) if length% 2 == 0: median= (sorted_numbers[length // 2] + sorted_numbers[length // 2 - 1]) / 2 else: median= sorted_numbers[length // 2] return median result= calculate_median([5, 2, 8, 1, 6, 4, 3, 7]) print(result) +++ 4.5 %%% ###249.
def calculate_sum(numbers): return sum(numbers) result= calculate_sum([1, 2, 3, 4, 5]) print(result) +++ 15 %%% ###250.
def find_max_common_characters(string1, string2): set1 = set(string1) set2 = set(string2) common_characters = set1.intersection(set2) return len(common_characters) result= find_max_common_characters("hello", "world") print(result) +++ 2 %%% ###251.
def check_substring(string, substring): return substring in string result= check_substring("Hello, world!", "world") print(result) +++ True %%% ###252.
def calculate_cube(number): return number ** 3 result = calculate_cube(3) print(result) +++ 27 %%% ###253.
def find_least_common_multiple(a, b): lcm = max(a, b) while True: if lcm % a == 0 and lcm % b == 0: return lcm lcm+=1 result= find_least_common_multiple(4, 5) print(result) +++ 20 %%% ###254.
def remove_duplicates(string): unique_chars = "" for char in string: if char not in unique_chars: unique_chars += char return unique_chars result = remove_duplicates("Hello, world!") print(result) +++ Helo, wrd! %%% ###255.
def calculate_product(numbers): product= 1 for num in numbers: product *= num return product result= calculate_product([1, 2, 3, 4, 5]) print(result) +++ 120 %%% ###256.
def find_max_common_characters(string1, string2): common_characters = set(string1) & set(string2) return common_characters result= find_max_common_characters("hello", "world") print(result) +++ {'o', 'l'} %%% ###257.
def calculate_square(number): return number ** 2 result = calculate_square(4) print(result) +++ 16 %%% ###258.
def count_consonants(string): vowels = ['a' 'e' 'i' 'o' 'u'] count= 0 for char in string: if char.isalpha() and char.lower() not in vowels: count+= 1 return count result= count_consonants("Hello, world!") print(result) +++ 10 %%% ###259.
def remove_whitespace(string): return ''.join(string.split()) result = remove_whitespace("Hello, world!") print(result) +++ Hello,world! %%% ###260.
def calculate_average(numbers): total = sum(numbers) average= total/ len(numbers) return round(average, 2) result= calculate_average([1, 2, 3, 4, 5]) print(result) +++ 3.0 %%% ###261.
def check_power_of_two(number): return number & (number - 1) == 0 result= check_power_of_two(16) print(result) +++ True %%% ###262.
def find_min(numbers): return min(numbers) result= find_min([5, 2, 8, 1, 6, 4, 3, 7]) print(result) +++ 1 %%% ###263.
def is_prime(number): if number < 2: return False for i in range(2, int(number ** 0.5) + 1): if number% i == 0: return False return True result= is_prime(10) print(result) +++ False %%% ###264.
def check_anagram(word1, word2): sorted_word1 = sorted(word1.lower()) sorted_word2 = sorted(word2.lower()) return sorted_word1 == sorted_word2 result= check_anagram("listen", "silent") print(result) +++ True %%% ###265.
def calculate_percentage(part, whole): return (part/ whole) * 100 result= calculate_percentage(5, 20) print(result) +++ 25.0 %%% ###266.
def find_max_common_elements(list1, list2): common_elements = set(list1) & set(list2) return list(common_elements) result= find_max_common_elements([1, 2, 3, 4, 5], [4, 5, 6, 7, 8]) print(result) +++ [4, 5] %%% ###267.
def reverse_string(string): return string[::-1] result = reverse_string("Hello, world!") print(result) +++ !dlrow ,olleH %%% ###268.
def check_even_length(string): length = len(string) return length % 2 == 0 result = check_even_length("Hello") print(result) +++ False %%% ###269.
def find_max_repeating_character(string): max_count = 0 max_char ='' for char in string: count = string.count(char) if count > max_count: max_count = count max_char = char return max_char result = find_max_repeating_character("hello, world!") print(result) +++ l %%% ###270.
num= 10 result = num > 5 and num < 15 print(result) +++ True %%% ###271.
result= "Hello"+ "World" print(result) +++ HelloWorld %%% ###272.
nums = [1, 2, 3, 4, 5] result= nums[1:3] print(result) +++ [2, 3] %%% ###273.
result = len("Python") print(result) +++ 6 %%% ###274.
num= 10 result = num if num > 5 else 0 print(result) +++ 10 %%% ###275.
nums = [1, 2, 3, 4, 5] result = nums[-2] print(result) +++ 4 %%% ###276.
result= "Python"[1:4] print(result) +++ yth %%% ###277.
result= bool("Hello") print(result) +++ True %%% ###278.
nums = [1, 2, 3, 4, 5] result= nums[1:5:2] print(result) +++ [2, 4] %%% ###279.
result = 2 ** 3 print(result) +++ 8 %%% ###280.
result = "Python" * 3 print(result) +++ PythonPythonPython %%% ###281.
result= 10 / 3 print(result) +++ 3.3333333333333335 %%% ###282.
result= "Hello"[1] print(result) +++ e %%% ###283.
result = int(3.14) print(result) +++ 3 %%% ###284.
result= "Python"[::-1] print(result) +++ nohtyP %%% ###285.
result= 7 % 3 print(result) +++ 1 %%% ###286.
result = bool(0) print(result) +++ False %%% ###287.
result= "Hello".lower() print(result) +++ hello %%% ###288.
result= [1, 2, 3] + [4, 5] print(result) +++ [1, 2, 3, 4, 5] %%% ###289.
result= "Python".startswith("Py") print(result) +++ True %%% ###290.
result= "Hello, world!".split(", ") print(result) +++ ['Hello', 'world!'] %%% ###291.
result = len([1, 2, 3]) print(result) +++ 3 %%% ###292.
result = 3 < 2 or 4 > 3 print(result) +++ True %%% ###293.
result= "Python"[1:4:2] print(result) +++ yh %%% ###294.
result= 4 // 2 print(result) +++ 2 %%% ###295.
result = "Hello".upper() print(result) +++ HELLO %%% ###296.
result= [1, 2, 3].append(4) print(result) +++ None %%% ###297.
result = "Python".find("y") print(result) +++ 1 %%% ###298.
result = not True print(result) +++ False %%% ###299.
result= 10 % 3 print(result) +++ 1 %%% ###300.
result= "Python is fun".split() print(result) +++ ['Python', 'is', 'fun'] %%% ###301.
result = len("Python is fun") print(result) +++ 13 %%% ###302.
result= "Hello"[-1] print(result) +++ o %%% ###303.
result= bool([]) print(result) +++ False %%% ###304.
result= "Python"[1:3] print(result) +++ yt %%% ###305.
result = 0 or 1 print(result) +++ 1 %%% ###306.
result= "Hello".find("l") print(result) +++ 2 %%% ###307.
result= not False print(result) +++ True %%% ###308.
result= ["apple", "banana", "cherry"][1] print(result) +++ banana %%% ###309.
result = type(3.14) print(result) +++ %%% ###310.
result = len([]) print(result) +++ 0 %%% ###311.
result = 5 > 3 and 10 < 8 print(result) +++ False %%% ###312.
result = "Hello".isalpha() print(result) +++ True %%% ###313.
result= [1, 2, 3].extend([4, 5]) print(result) +++ None %%% ###314.
result= "Python"[2:] print(result) +++ thon %%% ###315.
result= 7 // 3 print(result) +++ 2 %%% ###316.
result= bool("") print(result) +++ False %%% ###317.
result = "Python".isupper() print(result) +++ False %%% ###318.
x=5 while x > 0: print(x) x -= 1 +++ 54321 %%% ###319.
x=1 while x < 10: print(x) x+=2 +++ 13579 %%% ###320.
x = 10 while x > 0: print(x) x-= 2 +++ 108642 %%% ###321.
x=1 while x <= 5: print(x) x += 1 else: print("Loop is over") +++ 12345Loop is over %%% ###322.
x=1 while x <= 5: print(x) if x == 3: break x += 1 else: print("Loop is over") +++ 123 %%% ###323.
x=1 while x <= 5: x += 1 if x == 3: continue print(x) +++ 2456 %%% ###324.
x=0 while x < 5: x += 1 if x == 3: continue print(x) else: print("Loop is over") +++ 1245Loop is over %%% ###325.
x= 10 while True: if x < 7: break print(x) x-= 2 +++ 108 %%% ###326.
x=1 while x <= 5: print(x) x += 1 if x == 3: break else: print("Loop is over") +++ 12 %%% ###327.
x=1 while x <= 5: print(x) x += 1 if x == 3: continue else: print("Loop is over") +++ 12345Loop is over %%% ###328.
x=1 while x <= 5: x += 1 if x == 3: break print(x) else: print("Loop is over") +++ 2 %%% ###329.
x=1 while x <= 5: x += 1 if x == 3: continue print(x) if x == 5: break +++ 245 %%% ###330.
def count_characters(word): count= 0 for char in word: count+= 1 return count result= count_characters("Hello") print(result) +++ 5 %%% ###331.
def sum_numbers(n): total= 0 while n > 0: total+= n n-= 1 return total result= sum_numbers(5) print(result) +++ 15 %%% ###332.
def factorial(n): result= 1 while n > 0: result*= n n-= 1 return result result = factorial(4) print(result) +++ 24 %%% ###333.
def count_vowels(word): vowels = ['a' 'e' 'i' 'o' 'u'] count= 0 for char in word: if char in vowels: count+= 1 return count result= count_vowels("Hello") print(result) +++ 0 %%% ###334.
def reverse_string(word): result="" index = len(word) - 1 while index >= 0: result+= word[index] index-= 1 return result result= reverse_string("Python") print(result) +++ nohtyP %%% ###335.
def is_palindrome(word): reverse="" index = len(word) - 1 while index >= 0: reverse+= word[index] index-= 1 if word == reverse: return True else: return False result = is_palindrome("madam") print(result) +++ True %%% ###336.
def find_maximum(numbers): maximum= float(-inf) for num in numbers: if num > maximum: maximum= num return maximum result= find_maximum([3, 7, 1, 9, 4]) print(result) +++ 9 %%% ###337.
def calculate_average( numbers): total = sum(numbers) count = len(numbers) average = total / count return average result= calculate_average([5, 8, 3, 6, 2]) print(result) +++ 4.8 %%% ###338.
def count_words(sentence): words= sentence.split() count = len(words) return count result = count_words("I love Python programming") print(result) +++ 4 %%% ###339.
def is_prime(n): if n < 2: return False for i in range(2, n): if n % i == 0: return False return True result = is_prime(17) print(result) +++ True %%% ###340.
def calculate_factorial(n): if n == 0: return 1 else: return n * calculate_factorial(n - 1) result = calculate_factorial(5) print(result) +++ 120 %%% ###341.
def remove_duplicates( numbers): result=[] for num in numbers: if num not in result: result.append(num) return result result= remove_duplicates([1, 2, 2, 3, 4, 4, 5]) print(result) +++ [1, 2, 3, 4, 5] %%% ###342.
def calculate_power(base, exponent): result= 1 for _ in range(exponent): result *= base return result result = calculate_power(2, 3) print(result) +++ 8 %%% ###343.
def reverse_list(lst): result=[] index= len(lst) - 1 while index >= 0: result.append(lst[ index]) index-= 1 return result result= reverse_list([1, 2, 3, 4, 5]) print(result) +++ [5, 4, 3, 2, 1] %%% ###344.
def count_even_numbers(numbers): count= 0 for num in numbers: if num % 2 == 0: count+= 1 return count result= count_even_numbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) print(result) +++ 5 %%% ###345.
def calculate_sum(numbers): total= 0 index= 0 while index< len(numbers): total += numbers[index] index+= 2 return total result= calculate_sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) print(result) +++ 25 %%% ###346.
def find_smallest( numbers): smallest = float('inf') for num in numbers: if num < smallest: smallest = num return smallest result= find_smallest([8, 2, 5, 1, 9, 3]) print(result) +++ 1 %%% ###347.
def remove_vowels(word): vowels = ['a' 'e' 'i' 'o' 'u'] result= "" for char in word: if char.lower() not in vowels: result += char return result result= remove_vowels("Hello") print(result) +++ Hello %%% ###348.
def remove_vowels(word): vowels = ['a' 'e' 'i' 'o' 'u'] result="" for char in word: if char.lower() not in vowels: result += char return result result= remove_vowels("Hello") print(result) +++ Hello %%% ###349.
def calculate_average(numbers): total = sum(numbers) count = len(numbers) average = total / count return average result= calculate_average([7, 5, 9, 3, 6]) print(result) +++ 6.0 %%% ###350.
def is_palindrome(word): reverse="" index = len(word) - 1 while index >= 0: reverse+= word[index] index-= 1 if word == reverse: return True else: return False result = is_palindrome("level") print(result) +++ True %%% ###351.
def calculate_factorial(n): if n == 0: return 1 else: return n * calculate_factorial(n - 1) result = calculate_factorial(6) print(result) +++ 720 %%% ###352.
def count_duplicates(numbers): duplicates = set() count= 0 for num in numbers: if num in duplicates: count+= 1 else: duplicates.add(num) return count result= count_duplicates([1, 2, 2, 3, 4, 4, 5]) print(result) +++ 2 %%% ###353.
def calculate_power(base, exponent): result= 1 for _ in range(exponent): result *= base return result result = calculate_power(3, 4) print(result) +++ 81 %%% ###354.
person= {"name": "Ali", "age": 25, "city": "Toshkent"} result= person.get("name").upper() print(result) +++ ALI %%% ###355.
sentence= "Bu Python dasturlash tili" result= sentence.replace("Python", "Java") print(result) +++ Bu Java dasturlash tili %%% ###356.
inventory= {"item": "laptop", "price": 2500, "quantity": 5} result = len(inventory.keys()) print(result) +++ 3 %%% ###357.
text = "Dasturlash" result= text.startswith("Das") print(result) +++ True %%% ###358.
student= {"name": "Ali", "age": 20, "city": "Toshkent"} result= "-".join(student.values()) print(result) +++ Bu xatolik matnlar ustida amallar bajarishda yuzaga kelishi mumkin. Xatolikning sababi student nomli lug'atning qiymatlari ro'yxat emas, masalan, student nomli lug'atning "ism", "yosh" va "guruh" degan kalitlari bo'lishi mumkin. Quyidagi misol student lug'atining "ism", "yosh" va "guruh" qiymatlarini join() funksiyasi yordamida "-" belgisi orqali birlashtirishni namoyish qiladi: %%% ###359.
person= {"name": "John", "age": 30, "city": "Toshkent"} result = person.keys() print(result) +++ dict_keys(['name', 'age', 'city']) %%% ###360.
sentence= "Salom, dunyo!" result= sentence.split(",") print(result) +++ ['Salom', ' dunyo!'] %%% ###361.
inventory= {"item": "book", "price": 25.99, "quantity": 10} result= inventory.get("price") print(result) +++ 25.99 %%% ###362.
text = "Dasturlash tilida yozishni sevaman" result= text.endswith("sevaman") print(result) +++ True %%% ###363.
student= {"name": "Ali", "age": 20, "city": "Toshkent"} result= "_".join(student.keys()) print(result) +++ name_age_city %%% ###364.
text = "Salom, dunyo!" result = text.lower() print(result) +++ salom, dunyo! %%% ###365.
person= {"ism": "Ali", "yosh": 25, "tuman": "Toshkent"} result= person.get("tuman").upper() print(result) +++ TOSHKENT %%% ###366.
text= "Dunyo yangiliklari" result= text.split() print(result) +++ ['Dunyo', 'yangiliklari'] %%% ###367.
person= {"ism": "Ali", "yosh": 25, "tuman": "Toshkent"} result= len(person) print(result) +++ 3 %%% ###368.
text= "Bu dasturlash tillarini o'rganishjuda qiziqarli!" result= text.replace("qiziqarli", "qulay") print(result) +++ Bu dasturlash tillarini o'rganishjuda qulay! %%% ###369.
text = "Salom, dunyo!" result = text.upper().split() print(result) +++ ['SALOM,', 'DUNYO!'] %%% ###370.
numbers= [1, 2, 3, 4, 5] result = len(numbers) print(result) +++ 5 %%% ###371.
fruits= ["olma", "banan", "apelsin"] result= ", ".join(fruits) print(result) +++ olma, banan, apelsin %%% ###372.
text= "salom, dunyo!" result= text.capitalize() print(result) +++ Salom, dunyo! %%% ###373.
numbers= [1, 2, 3, 4, 5] result = numbers.reverse() print(result) +++ None %%% ###374.
text = "Salom, dunyo!" result= text.count("0") print(result) +++ 0 %%% ###375.
numbers= [1, 2, 3, 4, 5] result = numbers[3 :5] print(result) +++ [4, 5] %%% ###376.
text = "Salom, dunyo!" result= text.replace("0", "a") print(result) +++ Salom, dunyo! %%% ###377.
numbers= [1, 2, 3, 4, 5] result = numbers.append(6) print(result) +++ None %%% ###378.
text= "salom, dunyo!" result = text.upper() print(result) +++ SALOM, DUNYO! %%% ###379.
fruits= ["olma", "banan", "apelsin"] result = len(fruits) print(result) +++ 3 %%% ###380.
numbers= [1, 2, 3, 4, 5] result= numbers.pop() print(result) +++ 5 %%% ###381.
text = "Salom, dunyo!" result = text.split(",") print(result) +++ ['Salom', ' dunyo!'] %%% ###382.
numbers= [1, 2, 3, 4, 5] result = sum(numbers) print(result) +++ 15 %%% ###383.
text= "salom, dunyo!" result = text.title() print(result) +++ Salom, Dunyo! %%% ###384.
fruits= ["olma", "banan", "apelsin"] result = fruits.index("banan") print(result) +++ 1 %%% ###385.
text = "Salom, dunyo!" result= text.endswith("yo!") print(result) +++ True %%% ###386.
numbers= [1, 2, 3, 4, 5] result = numbers.insert(2, 10) print(result) +++ None %%% ###387.
text= "salom, dunyo!" result = text.islower() print(result) +++ True %%% ###388.
numbers= [1, 2, 3, 4, 5] result= numbers.count(3) print(result) +++ 1 %%% ###389.
text = "Salom, dunyo!" result= text.startswith("Salom") print(result) +++ True %%% ###390.
numbers= [1, 2, 3, 4, 5] result= numbers.sort() print(result) +++ None %%% ###391.
text= "Salom, dunyo!" result = text.isalpha() print(result) +++ False %%% ###392.
fruits= ["olma", "banan", "apelsin"] result = fruits.remove("banan") print(result) +++ None %%% ###393.
try: x = int("salom") except ValueError: x=0 print(x) +++ 0 %%% ###394.
try: x = 10 / 0 except ZeroDivisionError: x = "Nolga bo'lish mumkin emas" print(x) +++ Nolga bo'lish mumkin emas %%% ###395.
try: x = int("1O") y = int("salom") result= x / y except ValueError: result = "Qiymat xatosi" except ZeroDivisionError: result= "Nolga bo'lish mumkin emas" print(result) +++ Qiymat xatosi %%% ###396.
try: x = int("1O") y=O result= x / y except ValueError: result = "Qiymat xatosi" except ZeroDivisionError: result= "Nolga bo'lish mumkin emas" print(result) +++ Qiymat xatosi %%% ###397.
try: x = int("1O") result = x.upper() except ValueError: result = "Qiymat xatosi" except AttributeError: result= "Metod mavjud emas" print(result) +++ Qiymat xatosi %%% ###398.
try: x = int("1O") y = "salom" result= x + y except ValueError: result = "Qiymat xatosi" except TypeError: result= "To'g'ri turda operatsiya amalga oshmadi" print(result) +++ Qiymat xatosi %%% ###399.
try: x = int("salom") except ValueError: x = "Qiymat xatosi" finally: x = "Tugatildi" print(x) +++ Tugatildi %%% ###400.
try: X = 10 / 0 except ZeroDivisionError: x = "Nolga bo'lish mumkin emas" finally: x = "Tugatildi" print(x) +++ Tugatildi %%% ###401.
try: x = int("1O") y = int("salom") result= x / y except ValueError: result = "Qiymat xatosi" except ZeroDivisionError: result= "Nolga bo'lish mumkin emas" finally: result = "Tugatildi" print(result) +++ Tugatildi %%% ###402.
try: x = int("1O") y=O result= x / y except ValueError: result = "Qiymat xatosi" except ZeroDivisionError: result= "Nolga bo'lish mumkin emas" finally: result = "Tugatildi" print(result) +++ Tugatildi %%% ###403.
try: x = int("1O") result = x.upper() except ValueError: result = "Qiymat xatosi" except AttributeError: result= "Metod mavjud emas" finally: result = "Tugatildi" print(result) +++ Tugatildi %%% ###404.
try: x = int("1O") y = "salom" result= x + y except ValueError: result = "Qiymat xatosi" except TypeError: result= "To'g'ri turda operatsiya amalga oshmadi" finally: result = "Tugatildi" print(result) +++ Tugatildi %%% ###405.
try: x = int("salom") except ValueError: x = "Qiymat xatosi" else: x = "Tugatildi" print(x) +++ Qiymat xatosi %%% ###406.
try: x = 10 / 0 except ZeroDivisionError: x = "Nolga bo'lish mumkin emas" else: x = "Tugatildi" print(x) +++ Nolga bo'lish mumkin emas %%% ###407.
try: x = int("1O") y = int("salom") result= x / y except ValueError: result = "Qiymat xatosi" except ZeroDivisionError: result= "Nolga bo'lish mumkin emas" else: result = "Tugatildi" print(result) +++ Qiymat xatosi %%% ###408.
try: x = int("1O") y=O result= x / y except ValueError: result = "Qiymat xatosi" except ZeroDivisionError: result= "Nolga bo'lish mumkin emas" else: result = "Tugatildi" print(result) +++ Qiymat xatosi %%% ###409.
try: x = int(" IO") result = x.upper() except ValueError: result = "Qiymat xatosi" except AttributeError: result= "Metod mavjud emas" else: result = "Tugatildi" print(result) +++ Qiymat xatosi %%% ###410.
try: x = int(" 1O") y = "salom" result= x + y except ValueError: result = "Qiymat xatosi" except TypeError: result= "To'g'ri turda operatsiya amalga oshmadi" else: result = "Tugatildi" print(result) +++ Qiymat xatosi %%% ###411.
try: x = int("10") y=0 result= x / y except ValueError: result = "Qiymat xatosi" except ZeroDivisionError: result= "Nolga bo'lish mumkin emas" else: result = "Tugatildi" finally: result = "Bajarildi" print(result) +++ Bajarildi %%% ###412.
try: x = int("salom") except (ValueError, TypeError): x = "Qiymat yoki tur xatosi" finally: x = "Tugatildi" print(x) +++ Tugatildi %%% ###413.
try: x = int("10") result = x.lower() except (ValueError, AttributeError): result= "Qiymat yoki metod xatosi" finally: result = "Tugatildi" print(result) +++ Tugatildi %%% ###414.
try: x = int(" 1O") y = int("20") result= x + y except ValueError: result = "Qiymat xatosi" except ZeroDivisionError: result= "Nolga bo'lish mumkin emas" else: result = "Tugatildi" finally: result = "Bajarildi" print(result) +++ Bajarildi %%% ###415.
try: x = int("salom") except (ValueError, TypeError): x = "Qiymat yoki tur xatosi" else: x = "Tugatildi" finally: x = "Bajarildi" print(x) +++ Bajarildi %%% ###416.
try: x = int("1O") result = x.lower() except (ValueError, AttributeError): result= "Qiymat yoki metod xatosi" else: result = "Tugatildi" finally: result = "Bajarildi" print(result) +++ Bajarildi %%% ###417.
try: x = int("1O") y = int("salom") result= x + y except (ValueError, TypeError): result= "Qiymat yoki tur xatosi" except ZeroDivisionError: result= "Nolga bo'lish mumkin emas" else: result = "Tugatildi" finally: result = "Bajarildi" print(result) +++ Bajarildi %%% ###418.
try: x = int("salom") except ValueError: x = "Qiymat xatosi" except: x = "Boshqa xato" else: x = "Tugatildi" finally: x = "Bajarildi" print(x) +++ Bajarildi %%% ###419.
try: x = int("1O") y=O result= x / y except ZeroDivisionError: result= "Nolga bo'lish mumkin emas" except: result = "Boshqa xato" else: result = "Tugatildi" finally: result = "Bajarildi" print(result) +++ Bajarildi %%% ###420.
try: x = int("salom") except ValueError: x = "Qiymat xatosi" except ZeroDivisionError: x = "Nolga bo'lish mumkin emas" else: x = "Tugatildi" finally: x = "Bajarildi" print(x) +++ Bajarildi %%% ###421.
try: x = int("1O") result = x.lower() except ValueError: result = "Qiymat xatosi" except AttributeError: result= "Metod mavjud emas" else: result = "Tugatildi" finally: result = "Bajarildi" print(result) +++ Bajarildi %%% ###422.
word = "Python" result= word.upper() print(result) +++ PYTHON %%% ###423.
word = "Python" result = word.lower() print(result) +++ python %%% ###424.
numbers= [1, 2, 3, 4, 5] result = max(numbers) print(result) +++ 5 %%% ###425.
word = "Python" result = word.isalpha() print(result) +++ True %%% ###426.
numbers = [1, 2, 3, 4, 5] result = min(numbers) print(result) +++ 1 %%% ###427.
word = "Python" result = word.isnumeric() print(result) +++ False %%% ###428.
numbers= [1, 2, 3, 4, 5] result = sum(numbers) / len(numbers) print(result) +++ 3.0 %%% ###429.
word = "Python" result = word.capitalize() print(result) +++ Python %%% ###430.
numbers= [1, 2, 3, 4, 5] result = len(numbers) + 1 print(result) +++ 6 %%% ###431.
word = "Python" result= word.swapcase() print(result) +++ pYTHON %%% ###432.
numbers= [1, 2, 3, 4, 5] result = max(numbers) + min(numbers) print(result) +++ 6 %%% ###433.
word = "Python" result = word.isalnum() print(result) +++ True %%% ###434.
numbers= [1, 2, 3, 4, 5] result= sorted(numbers, reverse=True) print(result) +++ [5, 4, 3, 2, 1] %%% ###435.
word = "Python" result = word.islower() print(result) +++ False %%% ###436.
word = "Hello, World!" result= len(word) print(result) +++ 13 %%% ###437.
word = "Hello, World!" result= word.replace("o", "i") print(result) +++ Helli, Wirld! %%% ###438.
word = "Hello, World!" result = word.count("!") print(result) +++ 1 %%% ###439.
word = "Hello, World!" result= word.split(",") print(result) +++ ['Hello', ' World!'] %%% ###440.
word = "Hello, World!" result = word.isalpha() print(result) +++ False %%% ###441.
word = "Hello, World!" result= word.startswith("Hello") print(result) +++ True %%% ###442.
word = "Hello, World!" result = word.index("W") print(result) +++ 7 %%% ###443.
word = "Hello, World!" result= word.upper() print(result) +++ HELLO, WORLD! %%% ###444.
word = "Hello, World!" result= word.endswith("!") print(result) +++ True %%% ###445.
numbers= [1, 2, 3, 4, 5] total= 0 for num in numbers: total+= num result= total print(result) +++ 15 %%% ###446.
word = "Hello, World!" count= 0 for letter in word: if letter== "o": count+= 1 result = count print(result) +++ 2 %%% ###447.
numbers= [1, 2, 3, 4, 5] squared_numbers = [] for num in numbers: squared_numbers.append(num ** 2) result = squared_numbers print(result) +++ [1, 4, 9, 16, 25] %%% ###448.
word = "Hello, World!" reversed_word="" for letter in word: reversed_word = letter + reversed_word result = reversed_word print(result) +++ !dlroW ,olleH %%% ###449.
numbers= [1, 2, 3, 4, 5] even_numbers = [] for num in numbers: if num % 2 == 0: even_numbers.append(num) result = even_numbers print(result) +++ [2, 4] %%% ###450.
word = "Hello, World!" has_o = False for letter in word: if letter== "o": has_o = True break result = has_o print(result) +++ False %%% ###451.
word = "Hello, World!" is_palindrome = True for i in range(len(word)): if word[i] != word[-i - 1]: is_palindrome = False break result = is_palindrome print(result) +++ False %%% ###452.
numbers= [1, 2, 3, 4, 5] doubled_numbers = [] for num in numbers: doubled_numbers.append(num * 2) result= doubled_numbers print(result) +++ [2, 4, 6, 8, 10] %%% ###453.
word = "Hello, World!" vowel_count = 0 for letter in word: if letter.lower() in "aeiou": vowel_count += 1 result = vowel_count print(result) +++ 3 %%% ###454.
numbers = [1, 2, 3, 4, 5] odd_numbers = [] for num in numbers: if num % 2 != 0: odd_numbers.append(num) result = odd_numbers print(result) +++ [1, 3, 5] %%% ###455.
word = "Hello, World!" result= word.split(" ") print(result) +++ ['Hello,', 'World!'] %%% ###456.
numbers= [1, 2, 3, 4, 5] sum_of_squares = 0 for num in numbers: sum_of_squares += num ** 2 result = sum_of_squares print(result) +++ 55 %%% ###457.
numbers= [1, 2, 3, 4, 5] average= 0 for num in numbers: average += num average/= len(numbers) result = average print(result) +++ 1.18752 %%% ###458.
word = "Python Programming" result = word.count("mm") print(result) +++ 1 %%% ###459.
numbers= [1, 2, 3, 4, 5] result = sum(numbers) | len(numbers) print(result) +++ 15 %%% ###460.
word = "Python" result= word.endswith("on") print(result) +++ True %%% ###461.
numbers= [1, 2, 3, 4, 5] result = sum(numbers) * len(numbers) print(result) +++ 75 %%% ###462.
numbers= [1, 2, 3, 4, 5] result = sorted(numbers) print(result) +++ [1, 2, 3, 4, 5] %%% ###463.
word = "Python Programming" result= word.replace("Python", "Java") print(result) +++ Java Programming %%% ###464.
numbers= [1, 2, 3, 4, 5] result = min(numbers) - max(numbers) print(result) +++ -4 %%% ###465.
numbers= [1, 2, 3, 4, 5] total= 0 for num in numbers: total+= num result= total * 2 print(result) +++ 30 %%% ###466.
word = "Python" new_word="" for letter in word: new_word += letter * 2 result = new_word print(result) +++ PPyytthhoonn %%% ###467.
numbers= [1, 2, 3, 4, 5] count= 0 for num in numbers: if num % 2 == 0: count+= 1 result = count print(result) +++ 2 %%% ###468.
word = "Python" result="" for i in range(len(word) - 1, -1, -1): result+= word[i] print(result) +++ nohtyP %%% ###469.
numbers= [1, 2, 3, 4, 5] result= 0 for num in numbers: if num % 2 != 0: result += num print(result) +++ 9 %%% ###470.
word = "Python" vowel_count = 0 for letter in word: if letter.lower() in "aeiou": vowel_count += 1 result = vowel_count print(result) +++ 1 %%% Download 37.76 Kb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling