
Difficult Python and SQL MCQs
Quiz
•
Computers
•
12th Grade
•
Practice Problem
•
Hard
dcsgs sdfdg
Used 1+ times
FREE Resource
Enhance your content in a minute
51 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following Python code? x=[1,2,3] x[1:2]=[4,5] print(x)
[1,4,5,3]
[1,4,5]
[4,5,3]
[1,2,4,5,3]
Answer explanation
The code replaces the slice x[1:2] (which is [2]) with [4,5]. Thus, x becomes [1, 4, 5, 3]. The correct output is [1, 4, 5, 3].
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the result of the following Python expression? result=2**3**2 print(result)
512
64
128
256
Answer explanation
In Python, the expression 2**3**2 is evaluated as 2**(3**2) due to right-to-left associativity of the exponentiation operator. Thus, 3**2 equals 9, and then 2**9 equals 512, making the correct answer 512.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following statements will correctly define a function that accepts variable number of keyword arguments in Python?
def func(*args, **kwargs):
def func(**args, *kwargs):
def func(*args):
def func(kwargs, *args):
Answer explanation
The correct choice is 'def func(*args, **kwargs):' because it allows the function to accept a variable number of positional arguments (*args) and keyword arguments (**kwargs), making it flexible for various inputs.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following will correctly open a file in Python for reading and writing?
open('file.txt', 'r+')
open('file.txt', 'w')
open('file.txt', 'r')
open('file.txt', 'wb')
Answer explanation
The correct choice is open('file.txt', 'r+')' because it opens a file for both reading and writing. 'r' is for reading only, 'w' is for writing (overwriting), and 'wb' is for writing in binary mode.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the result of the following Python code? x=[1,2,3] del x[1] print(x)
[1,2]
[1,3]
[2,3]
[3]
Answer explanation
The code initializes a list x with [1, 2, 3]. The 'del x[1]' statement removes the element at index 1 (which is 2). Thus, the list becomes [1, 3]. The correct output is [1, 3].
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following Python data structures is mutable?
Tuple
String
List
Set (in some contexts)
Answer explanation
Among the options, only a List is mutable, meaning its contents can be changed after creation. Tuples and strings are immutable, while sets can be mutable but are not universally so.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct output of the following code? x={1,2,3,4} x.add(5) x.remove(3) print(x)
{1,2,4,5}
{1,2,3,4,5}
{2,3,4,5}
{1,2,4}
Answer explanation
The code initializes a set x with {1,2,3,4}. It adds 5, resulting in {1,2,3,4,5}, then removes 3, leaving {1,2,4,5}. Thus, the correct output is {1,2,4,5}.
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?
Similar Resources on Wayground
50 questions
Pra USPBK - Kompetensi Keahlian TKJ
Quiz
•
12th Grade
50 questions
Latihan Soal Multimedia
Quiz
•
12th Grade
46 questions
CompTIA ITFundamentals CRAM
Quiz
•
6th Grade - University
48 questions
OSI Layer
Quiz
•
12th Grade - University
50 questions
Data Science
Quiz
•
9th - 12th Grade
50 questions
Empowerment Technology - 1st Quarter
Quiz
•
11th - 12th Grade
50 questions
AIJ
Quiz
•
12th Grade
53 questions
Scratch Programming
Quiz
•
9th Grade - University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
