Skip to content
- Which of the following is used to create a list of numbers from 0 to 10 in steps of 0.5 in Python?
a) [x * 0.5 for x in range(21)]
b) [x * 0.5 for x in range(20)]
c) [x * 0.5 for x in range(0, 21)]
d) [x * 0.5 for x in range(0, 20)]
Correct Answer: a) [x * 0.5 for x in range(21)]
- What is the output of
print("Python".split("t"))?
a) [‘Py’, ‘hon’]
b) [‘Pyt’, ‘hon’]
c) [‘P’, ‘ython’]
d) Error
Correct Answer: a) [‘Py’, ‘hon’]
- Which of the following is used to create a list of squares of numbers from 1 to 10 in Python?
a) [x ** 2 for x in range(1, 11)]
b) [x ** 2 for x in range(1, 10)]
c) [x ** 2 for x in range(11)]
d) [x ** 2 for x in range(10)]
Correct Answer: a) [x ** 2 for x in range(1, 11)]
- What is the output of
print("Python".rsplit("t"))?
a) [‘Py’, ‘hon’]
b) [‘Pyt’, ‘hon’]
c) [‘P’, ‘ython’]
d) Error
Correct Answer: a) [‘Py’, ‘hon’]
- Which of the following is used to create a list of cubes of numbers from 1 to 10 in Python?
a) [x ** 3 for x in range(1, 11)]
b) [x ** 3 for x in range(1, 10)]
c) [x ** 3 for x in range(11)]
d) [x ** 3 for x in range(10)]
Correct Answer: a) [x ** 3 for x in range(1, 11)]
- What is the output of
print("Python".split("t", 1))?
a) [‘Py’, ‘hon’]
b) [‘Pyt’, ‘hon’]
c) [‘P’, ‘ython’]
d) Error
Correct Answer: a) [‘Py’, ‘hon’]
- Which of the following is used to create a list of even squares of numbers from 1 to 10 in Python?
a) [x ** 2 for x in range(1, 11) if x % 2 == 0]
b) [x ** 2 for x in range(1, 10) if x % 2 == 0]
c) [x ** 2 for x in range(11) if x % 2 == 0]
d) [x ** 2 for x in range(10) if x % 2 == 0]
Correct Answer: a) [x ** 2 for x in range(1, 11) if x % 2 == 0]
- What is the output of
print("Python".rsplit("t", 1))?
a) [‘Py’, ‘hon’]
b) [‘Pyt’, ‘hon’]
c) [‘P’, ‘ython’]
d) Error
Correct Answer: a) [‘Py’, ‘hon’]
- Which of the following is used to create a list of odd cubes of numbers from 1 to 10 in Python?
a) [x ** 3 for x in range(1, 11) if x % 2 != 0]
b) [x ** 3 for x in range(1, 10) if x % 2 != 0]
c) [x ** 3 for x in range(11) if x % 2 != 0]
d) [x ** 3 for x in range(10) if x % 2 != 0]
Correct Answer: a) [x ** 3 for x in range(1, 11) if x % 2 != 0]
- What is the output of
print("Python".split("t", 0))?
a) [‘Python’]
b) [‘P’, ‘ython’]
c) [‘Py’, ‘hon’]
d) Error
Correct Answer: a) [‘Python’]
- Which of the following is used to create a list of numbers from 0 to 10 in steps of 2 in Python?
a) list(range(0, 11, 2))
b) list(range(0, 10, 2))
c) list(range(2, 11, 2))
d) list(range(2, 10, 2))
Correct Answer: a) list(range(0, 11, 2))
- What is the output of
print("Python".rsplit("t", 0))?
a) [‘Python’]
b) [‘P’, ‘ython’]
c) [‘Py’, ‘hon’]
d) Error
Correct Answer: a) [‘Python’]
- Which of the following is used to create a list of numbers from 10 to 0 in steps of -1 in Python?
a) list(range(10, -1, -1))
b) list(range(10, 0, -1))
c) list(range(10, -1))
d) list(range(10, 0))
Correct Answer: a) list(range(10, -1, -1))
- What is the output of
print("Python".split("t", -1))?
a) [‘Py’, ‘hon’]
b) [‘Pyt’, ‘hon’]
c) [‘P’, ‘ython’]
d) Error
Correct Answer: a) [‘Py’, ‘hon’]
- Which of the following is used to create a list of numbers from 0 to 10 in steps of 0.1 in Python?
a) [x * 0.1 for x in range(101)]
b) [x * 0.1 for x in range(100)]
c) [x * 0.1 for x in range(0, 101)]
d) [x * 0.1 for x in range(0, 100)]
Correct Answer: a) [x * 0.1 for x in range(101)]
Pages:
1 2 3 4 5 6 7 8 9 10