-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerators.py
More file actions
54 lines (37 loc) · 731 Bytes
/
Copy pathgenerators.py
File metadata and controls
54 lines (37 loc) · 731 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
# Genrators
def my_generator():
yield 1
yield 2
yield 3
for value in my_generator():
print(value)
def count_up_to(n):
count = 1
while count <= n:
yield count
count += 1
for num in count_up_to(5):
print(num)
def large_sequence(n):
for i in range(n):
yield i
# This doesn't create a million numbers in memory
gen = large_sequence(1000000)
print(next(gen))
print(next(gen))
print(next(gen))
# Range Function
x = range(3, 10)
#display x:
print(x)
#convert to list to display the content of x:
print(list(x))
x = range(3, 10, 2)
#display x:
print(x)
#convert to list to display the content of x:
print(list(x))
for x in range(-4):
print(x)
cars = ["Ford", "Volvo", "BMW"]
print(cars)