1#to print number from 1 to 10
2for i in range(1,11):
3 print(i)
4
5#to print a list
6l = [1,2,3,4]
7for i in l:
8 print(i)
9
10r = ["a","b","c","d","e"]
11s = [1,2,3,4,5]
12
13#print two list with the help of zip function
14for p,q in zip(r,s):
15 print(p,q)
1# range(start, stop, step)
2 # start = index to begin at (INCLUSIVE)
3 # stop = generate numbers up to, but not including this number (EXCLUSIVE)
4 # step = (can be omitted) difference between each number in the sequence
5
6arr = [19,5,3,22,13]
7
8# range(stop)
9for i in range(len(arr)):
10 print(arr[i]) # prints: 19, 5, 3, 22, 13
11
12# range(start, stop)
13for i in range(2, len(arr)):
14 print(arr[i]) # prints: 3, 22, 13
15
16# range(start, stop, step)
17for i in range(0, len(arr), 2):
18 print(arr[i]) # prints: 19, 3, 13
19
20# reverse:
21for i in range(len(arr)-1, -1, -1):
22 print(arr[i])
23
1# range(start, stop, step)
2 # start = (can be ommitted) index to begin at (INCLUSIVE)
3 # stop = generate numbers up to, but not including this number (EXCLUSIVE)
4 # step = (can be omitted) difference between each number in the sequence
5
6# idx: 0 1 2 3 4
7# arr: 19 5 3 22 13
8
9arr = [19,5,3,22,13]
10
11# range(stop)
12for i in range(len(arr)):
13 print(arr[i]) # prints: 19, 5, 3, 22, 13
14
15# range(start, stop)
16for i in range(2, len(arr)):
17 print(arr[i]) # prints: 3, 22, 13
18
19# range(start, stop, step)
20for i in range(0, len(arr), 2):
21 print(arr[i]) # prints: 19, 3, 13
22
23# reverse:
24for i in range(len(arr)-1, -1, -1):
25 print(arr[i])
1for variable in range (69): # Runs the code below 69 times, sets the var "variable" to the index
2 print(variable) # Prints the var "variable" (every time the number will be bigger)
3 print("Done") # This will not get sent 69 times.