File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ # booleans
2
+ x = 3
3
+ print x == 2
4
+
5
+ # proper indentation in python is essential
6
+ if x == 2 :
7
+ print "x is indeed 2"
8
+ print "it's insane that the if block is determined by indentation"
9
+ # print "this will give me an error"
10
+ print "So, this will be printed regardless of x == 2"
11
+
12
+ # combining boolean expressions
13
+ y = 5
14
+
15
+ if x == 2 and y == 5 :
16
+ print "Think positive"
17
+ elif x == 3 and y == 5 :
18
+ print "Life's okay, I guess"
19
+ else :
20
+ print "That's it, I'm done!"
21
+
22
+ # iterating using in operator
23
+ name = "SlimShady"
24
+ rappers = ["SlimShady" , "TheRealSlimShady" , "Eminem" ]
25
+
26
+ if name in rappers :
27
+ print "He's from Detroit"
28
+ else :
29
+ print "He's not a real rapper"
30
+
31
+ # comparing values vs objects
32
+ x = [1 , 2 , 3 ]
33
+ y = [1 , 2 , 3 ]
34
+
35
+ if x == y :
36
+ print "x and y are equal in terms of their values"
37
+
38
+ if x is y :
39
+ print "x and y are the same object"
40
+ else :
41
+ print "they're different objects though"
42
+
43
+ # the not operator
44
+ if True is not False :
45
+ print "This concludes the chapter"
46
+ print not False
47
+ print not True
You can’t perform that action at this time.
0 commit comments