Python Unit 2 mod 1-4 Questions and
Answers Rated A+
3. Choose the correct print output for the following code:
name = "Alton"
print(name[::2])
A
"Atn"
B
"lo"
C
"on"
D
"Al" - ANSWER-"Atn"
Choose the best representation of the output expected for the following code.
numbers = ""
for x in range(0,5,2):
numbers += str(x)
print(numbers)
A
0
B
5
C
024
D
,24 - ANSWER-C
024
Choose the best representation of the output expected for the following code.
numbers = ""
for x in range(2,8,2):
numbers += str(x)
print(numbers)
A
2
B
8
C
2468
D
246 - ANSWER-D
246
Choose the best representation of the output expected for the following code.
cities = ["New York", "Shanghai", "Munich", "Tokyo", "Dubai", "Mexico City", "São
Paulo", "Hyderabad"]
for city in cities:
if city.startswith("P"):
print(city)
elif city.startswith("D"):
print(city)
A
São PauloDubai
B
Dubai
, C
São Paulo
D
none of these - ANSWER-B
Dubai
Choose the best representation of the output expected for the following code.
numbers = ""
for x in range(7):
numbers += str(x)
print(numbers)
A
0
B
7
C
1234567
D
0123456 - ANSWER-D
0123456
Choose the item that best completes the following sentence:
"A Python list..."
A
uses index 1 for the first item in the list.
B
can contain a mix of strings or numbers as list items.
C
can contain only all strings or only all numbers as list items - cannot contain a mix.
Answers Rated A+
3. Choose the correct print output for the following code:
name = "Alton"
print(name[::2])
A
"Atn"
B
"lo"
C
"on"
D
"Al" - ANSWER-"Atn"
Choose the best representation of the output expected for the following code.
numbers = ""
for x in range(0,5,2):
numbers += str(x)
print(numbers)
A
0
B
5
C
024
D
,24 - ANSWER-C
024
Choose the best representation of the output expected for the following code.
numbers = ""
for x in range(2,8,2):
numbers += str(x)
print(numbers)
A
2
B
8
C
2468
D
246 - ANSWER-D
246
Choose the best representation of the output expected for the following code.
cities = ["New York", "Shanghai", "Munich", "Tokyo", "Dubai", "Mexico City", "São
Paulo", "Hyderabad"]
for city in cities:
if city.startswith("P"):
print(city)
elif city.startswith("D"):
print(city)
A
São PauloDubai
B
Dubai
, C
São Paulo
D
none of these - ANSWER-B
Dubai
Choose the best representation of the output expected for the following code.
numbers = ""
for x in range(7):
numbers += str(x)
print(numbers)
A
0
B
7
C
1234567
D
0123456 - ANSWER-D
0123456
Choose the item that best completes the following sentence:
"A Python list..."
A
uses index 1 for the first item in the list.
B
can contain a mix of strings or numbers as list items.
C
can contain only all strings or only all numbers as list items - cannot contain a mix.