forked from deepdalsania/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoopingTechnique.py
More file actions
33 lines (27 loc) · 898 Bytes
/
LoopingTechnique.py
File metadata and controls
33 lines (27 loc) · 898 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
from math import isnan
# looping through dictionaries
'''tel = {"abc":9877,"def":9563}
for k,v in tel.items():
print(k,v)'''
# looping with two or more sequences
from builtins import print
'''que = ["name","nick name","favourite person"]
ans = ["deep","DD","My MoM"]
sign = [".","!","!"]
for q,a,s in zip(que,ans,sign):
print("what is your {0}? It is {1}{2}".format(q,a,s))'''
# loop over a sequence in reverse
'''for i in reversed(range(1,11)):
print(i)'''
# loop over a sequence in sorted order
'''fruits = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
# if we are sorting list we will have a duplicate value
for i in sorted(set(fruits)) :
print(i)'''
# manipulating a list while iterating
raw_data = [56.2, float('NaN'), 51.7, 55.3, 52.5, float('NaN'), 47.8]
data = []
for i in raw_data:
if not isnan(i):
data.append(i)
print("filtered data : ",data)