
Difficult Python and SQL MCQs

Quiz
•
Computers
•
12th Grade
•
Hard
dcsgs sdfdg
Used 1+ times
FREE Resource
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}.
Create a free account and access millions of resources
Similar Resources on Wayground
50 questions
TEST TULIS KEJURUAN TKJ 2024

Quiz
•
12th Grade
50 questions
PYTHON BASICS GRADE 11

Quiz
•
11th - 12th Grade
53 questions
ulangan menentukan jumlah subnet- jumlah host dan blok 11tkj 1

Quiz
•
12th Grade
50 questions
Latihan TLJ 4

Quiz
•
12th Grade
50 questions
CCST Networking Basics, Unit test

Quiz
•
12th Grade
55 questions
Uji Kompetesi

Quiz
•
1st - 12th Grade
50 questions
THIRD QUARTER ASSESSMENT IN CSS - GRADE 9

Quiz
•
9th Grade - University
50 questions
US Kelas XII Jaringan, Komputer SMK Samudera Bandar Lampung

Quiz
•
12th Grade
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
20 questions
Digital Citizenship

Quiz
•
8th - 12th Grade
35 questions
Computer Baseline Examination 2025-26

Quiz
•
9th - 12th Grade
13 questions
Problem Solving Process

Quiz
•
9th - 12th Grade
10 questions
Understanding Algorithms with Pseudocode and Flowcharts

Interactive video
•
9th - 12th Grade
19 questions
AP CSP Unit 1 Review (code.org)

Quiz
•
10th - 12th Grade