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
print('you can terminate the operation by entering 0') | |
while True: | |
number = int(input('Enter a number:')) | |
if number > 1: | |
for i in range(2, number): | |
if number % i == 0: | |
print(number, 'is not a prime number') | |
break |
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 sqrt(number): | |
return int(number ** 0.5) | |
def prime_number(number): | |
for i in range(2, sqrt(number)): | |
if number % i == 0: | |
print(number, 'is not a prime number') | |
break | |
else: | |
print(number, 'is a prime number') |
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 sum_of_multipliers(number): | |
sum_of_multipliers = 0 | |
for i in range (1,number): | |
if number % i == 0: | |
sum_of_multipliers += i | |
return sum_of_multipliers | |
for i in range(1,10000): | |
if i == sum_of_multipliers(i): | |
print(i) |
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 fibonacci(num): | |
if num <= 1: | |
return 1 | |
else: | |
return fibonacci(num-1) + fibonacci(num-2) | |
num = int(input('How many?:')) | |
if num <= 0: | |
print('Enter a positive number.') |
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
numbers = [-2, 5, 16, 21, -21, 1] | |
def Find_max(list): | |
if len(list) == 1: | |
return list[0] | |
else: | |
max = Find_max(list[1:]) | |
return max if max > list[0] else list[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
def ekok(num1, num2): | |
x = num1 | |
while True: | |
x += num1 | |
if x % num2 == 0 and x > num2: | |
return x | |
print("**ekok**") | |
num1 = int(input("1.sayı:")) |
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 ebob(num1,num2): | |
lst = [] | |
max = 0 | |
for i in range(1,num1): | |
if num1 % i == 0 and num2 % i == 0: | |
lst.append(i) | |
for i in lst: | |
if i > max: | |
max = i | |
return max |
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 mukemmel_sayi(sayi): | |
lst = [i for i in range(1, sayi) if sayi % i == 0] | |
sum = 0 | |
for i in lst: | |
sum += i | |
if sum == sayi: | |
print(sayi) | |
for i in range(1, 1001): |
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") | |
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: |