-
Notifications
You must be signed in to change notification settings - Fork 0
/
Session_1.py
84 lines (54 loc) · 1.15 KB
/
Session_1.py
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
####RANGE METHOD
for i in range(1,20,2):
print(i, end=" ")
print()
for i in range(2,20,2):
print(i, end=" ")
print()
for i in range(1,20,2):
print(i*i, end=" ")
print()
####LIST ERROR
namelist = ['wub_wub', 'RubyPinch', 'go|dfish', 'Nitori']
namelist.append('pb122')
if 'pb122' in namelist:
print("Now I know pb122!")
####VARIABLE ERROR
print("Hello!")
name = input("Enter your name: ")
print("Your name is " + name + ".")
####EXTEND METHOD ERROR
namelist = ['wub_wub', 'RubyPinch', 'go|dfish', 'Nitori']
namelist.extend('theelous3')
if input("Enter your name: ") in namelist:
print("I know you!")
else:
print("I don't know you.")
####GET VALUES FROM DICT
abc = {
'__Myst__': 'cats',
'Arun': 'dogs',
'horusr': 'cats',
'caisa64': 'cats and dogs'
}
print()
for i , b in abc.items():
print(i, ":", b)
print()
####FUNCTION EXPLANATION
a1=10
def abc(s):
a2=20
return a2
print(a1)
b=abc("hi")
print(b)
####NESTED FOR LOOP
for i in range(0,3):
for j in range(0,3):
for k in range(0,3):
for l in range(3,0):
print(l)
print(k)
print(j)
print(i)