forked from aiti-ghana-2012/Lab_Python_01
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday2.txt
134 lines (128 loc) · 2.2 KB
/
day2.txt
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
Python 2.7.2+ (default, Oct 4 2011, 20:03:08)
[GCC 4.6.1] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> a = False
>>> b = True
>>> c = False
>>> not a and b
True
>>> b and c
False
>>> (a and b) or not c
True
>>> not b and not (a or c)
False
>>> not((not b or not a) and c ) or a
True
>>> 5/2
2
>>> 5/2.0
2.5
>>> 5.0/2
2.5
>>> 7*(1/2)
0
>>> 7*(1/2.0)
3.5
>>> 5**2
25
>>> 5.0**2
25.0
>>> 5.0**2 =25.0
SyntaxError: can't assign to operator
>>> .0**2.0
0.0
>>> 5.0**2.0
25.0
>>> 1/3
0
>>>
>>> 1/3.0
0.3333333333333333
>>> ================================ RESTART ================================
>>>
LAB01, EXERCISE 1
Question 1
1. x is valid
2. 56thnumber is invalid
3. length is valid
4. !Tayo! is invalid
5. NUMBER is valid
6. Android_Phone1 is valid
7. 'this variable' is invalid
Question 2
1. 'a' is Boolean
2. 'b' is float
3. 'c' is string
4. 'd' is integer
5. 'e' is string
6. 'f' is integer
7. 'g' is invalid
8. 'h' is Boolean
9. 'i' is string
10. 'j' is string
LAB01, EXERCISE 2
a = False
b = True
c = False
1. b and c = False
2. b or c = True
3. not a and b = True
4. (a and b) or not c = True
5. not b and not (a or c) = False
6. not((not b or not a) and c ) or a = True
LAB01, EXERCISE 3
1. 5/2 = 2
2. 5/2.0 = 2.5
3. 5.0/2 = 2.5
4. 7*(1/2) = 0
5. 7*(1/2.0) = 3.5
6. 5**2 = 25
7. 5.0**2 =25.0
8. 5.0**2.0 = 25.0
9. 1/3 = 0
10. 1/3.0 = 0.33333333333
>>> ================================ RESTART ================================
>>>
LAB01, EXERCISE 1
Question 1
1. x is valid
2. 56thnumber is invalid
3. length is valid
4. !Tayo! is invalid
5. NUMBER is valid
6. Android_Phone1 is valid
7. 'this variable' is invalid
Question 2
1. 'a' is Boolean
2. 'b' is float
3. 'c' is string
4. 'd' is integer
5. 'e' is string
6. 'f' is integer
7. 'g' is invalid
8. 'h' is Boolean
9. 'i' is string
10. 'j' is string
LAB01, EXERCISE 2
a = False
b = True
c = False
1. b and c = False
2. b or c = True
3. not a and b = True
4. (a and b) or not c = True
5. not b and not (a or c) = False
6. not((not b or not a) and c ) or a = True
LAB01, EXERCISE 3
1. 5/2 = 2
2. 5/2.0 = 2.5
3. 5.0/2 = 2.5
4. 7*(1/2) = 0
5. 7*(1/2.0) = 3.5
6. 5**2 = 25
7. 5.0**2 =25.0
8. 5.0**2.0 = 25.0
9. 1/3 = 0
10. 1/3.0 = 0.33333333333
>>>