-
Notifications
You must be signed in to change notification settings - Fork 0
/
exer.py
100 lines (67 loc) · 1.43 KB
/
exer.py
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
def fiboiter(n):
prevnum = 0
currentnum = 1
for i in range(1, n):
prevprev = prevnum
prevnum = currentnum
currentnum = prevnum + prevprev
return currentnum
if __name__ == '__main__':
print(fiboiter(5))
def facto(n):
factorial = 1
# factorail_2 = factorial
if n<0:
print("Error")
elif n==0:
print("1")
else:
for i in range(factorial, n+1):
factorial *= i
print(factorial)
# if factorial > 1:
# print(factorial//factorail_2)
#
# else:
# print(factorial)
if __name__ == '__main__':
facto(7)
def itera(n):
for i in range(n):
yield i
vals = itera(12)
print(vals.__iter__())
print(vals.__next__())
print(vals.__next__())
print(vals.__next__())
def findDuplicate():
lst = [23, 34, 34, 11, 67, 54, 90, 17]
for i in range(len(lst)):
if lst[i] == lst[i + 1]:
return lst[i], lst[i+1]
print(findDuplicate())
num = 153
copy_n = num
sum = 0
convert_str = len(str(num))
while num > 0:
dipo = num % 10
sum += dipo ** convert_str
num = num // 10
if sum == copy_n:
print('armstrong')
else:
print('buzz')
# import requests
# import json
#
# url = requests.get('https://api.github.com')
# jason = url.json()
#
# dd = json.dumps(jason)
#
# dd2 = json.loads(dd)
# print(dd)
# print(dd2)
# print(json.loads(dd))
# print(json.dumps(dd))