-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogam3 using loops.py
More file actions
59 lines (44 loc) · 940 Bytes
/
progam3 using loops.py
File metadata and controls
59 lines (44 loc) · 940 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
55
56
57
58
59
dictionary: exericse
fib = {5: 3}
print(fib.get(5, 0))
print(5 in fib)
print(fib.get(51,"notfound"))
Tuples: example: same as lists ,immutable
Like lists and dictionaries, tuples can be nested within each other.
words = ("spam", "eggs", "sausages")
my_tuple = "one", "two", "three"
print(my_tuple[0])
-- this is list having tuple
contacts = [
('James', 42),
('Amy', 24),
('John', 31),
('Amanda', 63),
('Bob', 18)
]
name = input()
x=False
for i in range(0,5):
if(name==contacts[i][0]):
print (contacts [i][0]+" is "+str(contacts[i][1]))
x=True
break
if(x==False):
print("Not Found")
name=input()
for i in contacts:
if name in i:
print(i[0]+" is "+str(i[1]))
break
else:
print("Not Found")
for loops
for i in range(0,10):
print(i)
list1=[1,3,4,78,99,111,244,2]
for i in list1:
if i%2==0:
print(i)
print("even"+str(i))
else:
print("odd"+str(i))