Difficult Python and SQL MCQs

Difficult Python and SQL MCQs

12th Grade

51 Qs

quiz-placeholder

Similar activities

Ulangan harian Subneting 11 TKJ 1 2023/2024

Ulangan harian Subneting 11 TKJ 1 2023/2024

12th Grade

52 Qs

PENILAIAN TENGAH SEMESTER GANJIL

PENILAIAN TENGAH SEMESTER GANJIL

12th Grade

50 Qs

NetAcad Quiz Questions

NetAcad Quiz Questions

11th Grade - University

48 Qs

Latihan Soal US TKJ

Latihan Soal US TKJ

12th Grade

50 Qs

PYTHON PROGRAMMING - FINAL EXAM REVIEW

PYTHON PROGRAMMING - FINAL EXAM REVIEW

9th - 12th Grade

46 Qs

UAS_ADMINISTRASI SISTEM JARINGAN_ XII TKJ

UAS_ADMINISTRASI SISTEM JARINGAN_ XII TKJ

12th Grade

50 Qs

komputer jaringan

komputer jaringan

12th Grade

50 Qs

Networking Unit 2 Review

Networking Unit 2 Review

11th - 12th Grade

56 Qs

Difficult Python and SQL MCQs

Difficult Python and SQL MCQs

Assessment

Quiz

Computers

12th Grade

Hard

Created by

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

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?