Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mustafamuratcoskun
GitHub Repository: mustafamuratcoskun/Sifirdan-Ileri-Seviyeye-Python-Programlama
Path: blob/master/Pythondaki Iteratorlar ve Generatorlar/Kodlama Egzersizleri/iterator.py
765 views
1
class Kuvvet3():
2
def __init__(self,max = 0):
3
4
self.max = max
5
self.kuvvet = 0
6
7
def __iter__(self):
8
9
return self
10
def __next__(self):
11
if (self.kuvvet <= self.max):
12
sonuc = 3 ** self.kuvvet
13
14
self.kuvvet += 1
15
16
return sonuc
17
else:
18
self.kuvvet = 0
19
raise StopIteration
20
21
22
kuvvet = Kuvvet3(6)
23
24
for i in kuvvet:
25
print(i)
26
27
for j in kuvvet:
28
print(j)
29
30
31
32
33
34
35
36
37
38
39
40