
Cyber Sleuth Tier 1
Authored by Asymmetric Club
Computers
University
Used 7+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
What will be the output of the following code?
[1, 2]
[2,3]
[3,4]
[3,4,5]
Answer explanation
The slicing a[2:4] returns elements from index 2 up to (but not including) index 4.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is the correct way to open a file for reading in Python?
file = open('filename.txt', 'w')
file = open('filename.txt', 'r')
file = open('filename.txt', 'a')
file = open('filename.txt', 'x')
Answer explanation
The mode 'r' opens the file for reading.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Given the dictionary
d = {'one': 1, 'two': 2, 'three': 3},
what is the result of d.get('four')?
None
KeyError
0
4
Answer explanation
The get() method returns None if the key is not found and no default value is provided.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code?
a: 1 b: 5 c: 10
a: 1 b: 2 c: 10
a: 1 b: 2 c: 5
a: 1 b: 5 c: 2
Answer explanation
The function call func(1, 2) assigns 1 to a and 2 to b, using the default value 10 for c.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code snippet?
[1, 2, 3]
[1, 2, 3, 4]
[2]
None
Answer explanation
b is a reference to a, so changes to b affect a
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a mutable data type in Python?
int
str
tuple
list
Answer explanation
Lists are mutable, meaning their elements can be changed.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you create a set in Python?
s = {}
s = set([])
s = []
s = ()
Answer explanation
set([]) creates an empty set. {} creates an empty dictionary.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?