-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPCEP-30-02 1.3 literals, variables,.txt
172 lines (146 loc) · 4.2 KB
/
PCEP-30-02 1.3 literals, variables,.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
PCEP-30-02 1.3 literals, variables, and numeral systems:
1. Which of the following is a valid Boolean literal in Python?
A: TRUE
B: true
C: True
D: "True"
2. What is the output of the following code?
```python
print(0.1 + 0.2 == 0.3)
```
A: True
B: False
C: Error
D: None
3. How do you represent the number 5.3 x 10^8 in scientific notation in Python?
A: 5.3e8
B: 5.3E8
C: 5.3 * 10^8
D: Both A and B
4. Which of the following is a valid string literal in Python?
A: 'Hello'
B: "Hello"
C: '''Hello'''
D: All of the above
5. What is the binary representation of the decimal number 10?
A: 0b1010
B: 0b1000
C: 0b1100
D: 0b1110
6. Which of the following is the correct way to declare a variable in Python?
A: var myVar = 10
B: int myVar = 10
C: myVar = 10
D: let myVar = 10
7. According to PEP-8, which naming convention should be used for function names?
A: camelCase
B: PascalCase
C: snake_case
D: UPPERCASE
8. What is the hexadecimal representation of the decimal number 255?
A: 0xFF
B: 0xFE
C: 0x11
D: 0xFF
9. Which of the following is NOT a valid variable name in Python?
A: myVariable
B: _my_variable
C: 1stVariable
D: my_variable_1
10. What is the output of the following code?
```python
print(0o10)
```
A: 10
B: 8
C: 16
D: Error
11. Which of the following is a valid floating-point literal in Python?
A: 3.14
B: .314
C: 3.
D: All of the above
12. What is the correct way to declare a constant in Python according to PEP-8?
A: CONSTANT_NAME = value
B: ConstantName = value
C: constantName = value
D: Constant_Name = value
13. How do you represent the binary number 1010 as an integer literal in Python?
A: 1010b
B: 0b1010
C: bin(1010)
D: binary(1010)
14. What is the output of the following code?
```python
print(type(1 + 1.0))
```
A: <class 'int'>
B: <class 'float'>
C: <class 'number'>
D: Error
15. Which of the following is NOT a valid way to declare a multiline string in Python?
A: '''Multiline
string'''
B: """Multiline
string"""
C: "Multiline
string"
D: Both A and B are valid
16. What is the octal representation of the decimal number 64?
A: 0o100
B: 0o64
C: 0o200
D: 0o40
17. According to PEP-8, what is the maximum line length recommended for Python code?
A: 79 characters
B: 80 characters
C: 100 characters
D: 120 characters
18. Which of the following is a valid complex number literal in Python?
A: 3 + 4i
B: 3 + 4j
C: 3i + 4
D: complex(3, 4)
19. What is the output of the following code?
```python
print(0xA + 0o10)
```
A: 20
B: 18
C: 16
D: Error
20. Which of the following is NOT a recommended practice according to PEP-8?
A: Using spaces around operators
B: Using camelCase for function names
C: Using lowercase letters for module names
D: Using uppercase letters for constants
21. What is the correct way to declare a variable with a long integer value in Python 3?
A: long x = 1234567890L
B: x = 1234567890L
C: x = 1234567890
D: x = long(1234567890)
22. Which of the following is a valid way to use scientific notation in Python?
A: 1.23e-4
B: 1.23E-4
C: 1.23 * 10^-4
D: Both A and B
23. What is the output of the following code?
```python
print(f"{3.14159:.2f}")
```
A: 3.14
B: 3.14159
C: 3.142
D: Error
24. According to PEP-8, how should module-level "dunders" (names with two leading and two trailing underscores) be placed in a module?
A: At the very top of the file
B: After the module docstring
C: At the bottom of the file
D: Anywhere in the file
25. What is the correct way to declare a binary literal in Python?
A: 0b1010
B: binary(1010)
C: 1010b
D: bin(1010)
Answers:
1. C, 2. B, 3. D, 4. D, 5. A, 6. C, 7. C, 8. A, 9. C, 10. B, 11. D, 12. A, 13. B, 14. B, 15. C, 16. A, 17. B, 18. B, 19. B, 20. B, 21. C, 22. D, 23. A, 24. B, 25. A