forked from werhereitacademy/Python_Modul_Week_1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfatma_week1.py
More file actions
72 lines (39 loc) · 983 Bytes
/
fatma_week1.py
File metadata and controls
72 lines (39 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# SORU - 1
for i in range(1, 10):
print(i)
#SORU - 2
#for dongusu kullanilarak yapilan cozum
sayi = int(input("Bir sayi girin: "))
for i in range(0, sayi, 2):
print(i)
# while dongusu kullanilarak yapilan cozum
sayi = int(input("Bir sayi girin: "))
i = 0
while i < sayi:
print(i)
i += 2
#SORU - 3
ilk_sayi = int(input("Ilk sayiyi giriniz: "))
son_sayi = int(input("Son sayiyi giriniz: "))
for sayi in range(ilk_sayi + 1, son_sayi + 1):
print(sayi)
#SORU - 4
sayi = int(input("Bir sayi giriniz: "))
if sayi % 2 == 0:
print(f"{sayi} bir cift sayidir.")
else:
print(f"{sayi} tek sayidir.")
#SORU - 5
import math
sayi = int(input("Pozitif bir sayi giriniz: "))
result = math.factorial(sayi)
print(f"{sayi}! = {result}")
#SORU - 6
bolen_sayisi = 0
for i in range(2, sayi + 1):
if sayi % i == 0:
bolen_sayisi += 1
if bolen_sayisi == 1:
print(f"{sayi} asal bir sayidir")
else:
print(f"{sayi} asal degildir")