Difficult Python and SQL MCQs

Difficult Python and SQL MCQs

12th Grade

•

51 Qs

quiz-placeholder

Similar activities

VOIP XII

VOIP XII

1st Grade - University

•

50 Qs

Grade 10 Computer Systems Quiz

Grade 10 Computer Systems Quiz

10th Grade - University

•

50 Qs

Excel Getting Started

Excel Getting Started

8th - 12th Grade

•

50 Qs

Latihan UNBK TKJ 2019

Latihan UNBK TKJ 2019

10th Grade - University

•

50 Qs

PHOTOPEA-TEST-2023-S2ACC

PHOTOPEA-TEST-2023-S2ACC

12th Grade

•

46 Qs

#2 CIW Data Analyst - Certification Prep

#2 CIW Data Analyst - Certification Prep

9th Grade - University

•

54 Qs

Application Software Quiz

Application Software Quiz

12th Grade - University

•

50 Qs

CBT - Revision # 3

CBT - Revision # 3

12th Grade - University

•

54 Qs

Difficult Python and SQL MCQs

Difficult Python and SQL MCQs

Assessment

Quiz

•

Computers

•

12th Grade

•

Practice Problem

•

Hard

Created by

dcsgs sdfdg

Used 1+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?