Skip to content
- What is the output of
print("Python".rjust(10, "*"))?
a) Python
b) Python
c) Python
d) Error
Correct Answer: a) ****Python
- Which of the following is used to create a tuple comprehension in Python?
a) (x for x in iterable)
b) [x for x in iterable]
c) {x for x in iterable}
d) <x for x in iterable>
Correct Answer: a) (x for x in iterable)
- What is the output of
print("Python".center(10, "*"))?
a) Python
b) Python****
c) ****Python
d) Error
Correct Answer: a) Python
- Which of the following is used to create a generator expression in Python?
a) (x for x in iterable)
b) [x for x in iterable]
c) {x for x in iterable}
d) <x for x in iterable>
Correct Answer: a) (x for x in iterable)
- What is the output of
print("Python".strip())?
a) Python
b) Python
c) Python
d) Error
Correct Answer: a) Python
- Which of the following is used to create a list of numbers from 0 to 9 in Python?
a) list(range(10))
b) list(range(9))
c) list(range(0, 10))
d) list(range(0, 9))
Correct Answer: a) list(range(10))
- What is the output of
print("Python".lstrip())?
a) Python
b) Python
c) Python
d) Error
Correct Answer: a) Python
- Which of the following is used to create a list of numbers from 1 to 10 in Python?
a) list(range(1, 11))
b) list(range(1, 10))
c) list(range(10))
d) list(range(11))
Correct Answer: a) list(range(1, 11))
- What is the output of
print("Python".rstrip())?
a) Python
b) Python
c) Python
d) Error
Correct Answer: a) Python
- Which of the following is used to create a list of even numbers from 0 to 10 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".partition("t"))?
a) (‘Py’, ‘t’, ‘hon’)
b) (‘Pyt’, ‘h’, ‘on’)
c) (‘P’, ‘t’, ‘ython’)
d) Error
Correct Answer: a) (‘Py’, ‘t’, ‘hon’)
- Which of the following is used to create a list of odd numbers from 1 to 10 in Python?
a) list(range(1, 11, 2))
b) list(range(1, 10, 2))
c) list(range(0, 11, 2))
d) list(range(0, 10, 2))
Correct Answer: a) list(range(1, 11, 2))
- What is the output of
print("Python".rpartition("t"))?
a) (‘Py’, ‘t’, ‘hon’)
b) (‘Pyt’, ‘h’, ‘on’)
c) (‘P’, ‘t’, ‘ython’)
d) Error
Correct Answer: a) (‘Py’, ‘t’, ‘hon’)
- Which of the following is used to create a list of numbers from 10 to 1 in Python?
a) list(range(10, 0, -1))
b) list(range(10, 1, -1))
c) list(range(10, 0))
d) list(range(10, 1))
Correct Answer: a) list(range(10, 0, -1))
- What is the output of
print("Python".splitlines())?
a) [‘Python’]
b) [‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’]
c) [‘P’, ‘ython’]
d) Error
Correct Answer: a) [‘Python’]
Pages:
1 2 3 4 5 6 7 8 9 10