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
lst = ["a",2,"bc",76,86,"sasa",1.86,0.5,(36,45),("a","b")] | |
def value_type_extcract(type_exam,value): | |
if type(value) != type(type_exam): | |
raise ValueError("incompatible value") | |
else: | |
return value | |
for i in lst: |
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
dict1 = {"1":"on","2":"yirmi","3":"otuz","4":"kırk","5":"elli","6":"altmış","7":"yetmiş","8":"seksen","9":"doksan"} | |
dict2 = {"0":"","1":"bir","2":"iki","3":"üç","4":"dört","5":"beş","6":"altı","7":"yedi","8":"sekiz","9":"dokuz"} | |
def read_nums(num): | |
num = str(num) | |
if len(num) >= 3 or len(num) < 2: | |
raise ValueError("...") | |
for x in dict1: | |
x = str(x) |
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
from functools import reduce | |
even = list(filter(lambda x: x % 2 == 0, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) | |
print(reduce(lambda x, y: x + y, even)) |
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
for i in range(1, 11): | |
print("**************") | |
for j in range(1, 11): | |
print("{} x {} = {}".format(i, j, i*j)) |
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
while True: | |
num = input("Sayı giriniz:") | |
arm_factor = len(num) | |
sum = 0 | |
if num == "q": | |
print("Sonlandırıldı") | |
break | |
else: | |
for i in num: |
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
def sqr(num): | |
if (type(num) != int): | |
raise ValueError("Geçerli bir sayı girmediniz.") | |
else: | |
return num**2 | |
try: | |
print(sqr(2)) | |
print(sqr("a")) | |
except ValueError: |
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
s = "asdfaksjdşfıoqnfxcvçmaldmfgjdghfgqyewb" | |
letter_count = {} | |
for i in s: | |
if i in letter_count: | |
letter_count[i] += 1 | |
else: | |
letter_count[i] = 1 |
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
lst = ["345","sadas","324a","14","kemal"] | |
for i in lst: | |
try: | |
i = int(i) | |
print(i) | |
except: | |
pass |
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
def even_number(num): | |
if num % 2 != 0: | |
raise ValueError("this number is not even number.") | |
else: | |
return num | |
lst = [3,4,5,6,7,8,9,16] | |
for i in lst: | |
try: |
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
try: | |
num1 = int(input("1.Sayı:")) | |
num2 = int(input("2.Sayı:")) | |
print(num1 / num2) | |
except ZeroDivisionError: | |
print("Bir sayı sıfıra bölünemez.") | |
except ValueError: | |
print("Geçerli sayılar girmediniz") | |