What will be the output of the following code snippet?
s = "DataScience"
result = s[1:9:2] + s[-3:]
print(result)
Python Code Snippet Quiz
Quiz
•
Computers
•
11th Grade
•
Hard
Harmeet Kaur
Used 4+ times
FREE Resource
9 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What will be the output of the following code snippet?
s = "DataScience"
result = s[1:9:2] + s[-3:]
print(result)
ataecine
atsciece
ataceine
aacence
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the output of the following code snippet?
lst = [2, 4, 6, 8, 10]
result = [x**2 for x in lst if x % 3 == 2]
print(result)
[4, 64]
[36]
[4, 36, 64]
[16, 64]
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider the following tuple:
t = (1, [2, 3], (4, 5))
Which of the following statements will raise an error?
t[1][0] = 9
t[2] = (6, 7)
t[0] = 0
Both B and C
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Given the following dictionary:
d = {'John': 25, 'Jane': 30, 'Doe': 45}
What will be the output of the following code?
d['Jane'] += 5
del d['Doe']
d['Alice'] = 35
print(sorted(d.keys()))
['John', 'Doe', 'Alice']
['Alice', 'Jane', 'John']
['Doe', 'Jane', 'Alice']
['John', 'Jane', 'Alice']
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What will be the output of the following code snippet?
s = "Programming is fun!"
result = s[ : 11 ].upper() + s[ 11 : ][ : : -1 ]
print(result)
`PROGRAMMING !nuf si`
`PROGRAMMING is fun!`
`PROGRAMMING !nuf si gnimmargorP`
`Programming IS FUN!`
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What will be the output of the following code?
lst = [1, 2, 3, 4]
lst.append([5, 6])
lst.extend([7, 8])
print(lst)
[1, 2, 3, 4, 5, 6, 7, 8]
[1, 2, 3, 4, [5, 6], 7, 8]
[1, 2, 3, 4, 5, 6, [7, 8]]
[1, 2, 3, 4, [5, 6, 7, 8]]
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the result of the following code snippet?
t = (3, 1, 4, 1, 5, 9)
result = t.index(1, 2)
print(result)
1
2
3
IndexError
8.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Given the dictionary: d = {'cat': 'meow', 'dog': 'bark', 'cow': 'moo'}
Which of the following operations will correctly remove a key-value pair and add a new one?
d.pop('dog')
d['sheep'] = 'baa'
print(d)
{'cat': 'meow', 'dog': 'bark', 'cow': 'moo', 'sheep': 'baa'}
{'cat': 'meow', 'cow': 'moo', 'sheep': 'baa'}
{'cat': 'meow', 'sheep': 'baa', 'dog': 'bark'}
{'cow': 'moo', 'sheep': 'baa'}
9.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What will be the output of the following code snippet?
text = "Python is versatile and Python is fun."
position = text.find("Python", 10)
print(position)
0
18
-1
24
10 questions
Python Flow Control
Quiz
•
9th - 12th Grade
10 questions
Python Booleans
Quiz
•
11th Grade
14 questions
PYTHON DICTIONARIES
Quiz
•
11th Grade
10 questions
Python quiz
Quiz
•
10th Grade - Professi...
10 questions
Python Variables
Quiz
•
7th - 12th Grade
10 questions
Python - Flow control
Quiz
•
11th Grade
10 questions
Python Boolean and If
Quiz
•
9th - 12th Grade
10 questions
Python If Statements - and or not
Quiz
•
11th Grade
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Taxes
Quiz
•
9th - 12th Grade
17 questions
Parts of Speech
Quiz
•
7th - 12th Grade
20 questions
Chapter 3 - Making a Good Impression
Quiz
•
9th - 12th Grade
20 questions
Inequalities Graphing
Quiz
•
9th - 12th Grade
10 questions
Identifying equations
Quiz
•
KG - University