Search Header Logo
Python quiz

Python quiz

Assessment

Presentation

Engineering

University

Practice Problem

Hard

Created by

JAGARLAMUDI 23BCE9726

Used 3+ times

FREE Resource

0 Slides • 15 Questions

1

Multiple Choice

What is the correct syntax to print a string in Python?

1

echo "Hello, World!"

2

print("Hello, World!")

3

printf("Hello, World!")

4

System.out.println("Hello, World!")

2

Multiple Choice

How do you create a list in Python?

1

{1, 2, 3}

2

(1, 2, 3)

3

[1, 2, 3]

4

list(1, 2, 3)

3

Multiple Choice

Which library is used for data manipulation and analysis in Python?

1

NumPy

2

Pandas

3

Matplotlib

4

SciPy

4

Multiple Choice

How do you create a tuple in Python?

1

[1, 2, 3]

2

{1, 2, 3}

3

(1, 2, 3)

4

tuple[1, 2, 3]

5

Multiple Choice

Which of the following is NOT a valid Python data type?

1

int

2

float

3

double

4

str

6

Multiple Choice

How do you install an external Python library?

1

install library_name

2

python -m pip install library_name

3

include library_name

4

library_name install

7

Multiple Choice

What is the output of print(type([]))?

1

<class 'list'>

2

<type 'list'>

3

list

4

[]

8

Multiple Choice

How do you start a for loop in Python?

1

for (i=0; i<10; i++)

2

for i in range(10):

3

for i = 1 to 10:

4

foreach (i in 10)

9

Multiple Choice

What is the output of print(10 // 3)?

1

3.33

2

3

3

4

4

None

10

Multiple Choice

What is the correct way to write a conditional statement in Python?

1

if x > y {}

2

if x > y:

3

if x > y then:

4

if (x > y):

11

Multiple Choice

What will be the output of the following code snippet?
def foo(x=[]):

x.append(1)

return x

print(foo())

print(foo())

1

[1] [1]

2

[1] [2]

3

[1] [1, 1]

4

[1] [1, 2]

12

Multiple Choice

Which of the following statements about Python's Global Interpreter Lock (GIL) is TRUE?

1

It allows multi-threading in Python to run concurrently on multiple cores.

2

It prevents multiple threads from executing Python bytecodes at the same time.

3

It is specific to Jython and not CPython.

4

It is used to manage memory allocation across threads.

13

Multiple Choice

What will the following code output?
class A:

def init(self):

self.value = 10

def getattr(self, name):

if name == 'value':

return 20

raise AttributeError

a = A()

print(a.value)

1

10

2

20

3

AttributeError

4

Depends on Python version

14

Multiple Choice

What is the time complexity of list.pop(0) in Python?

1

O(1)

2

O(log n)

3

O(n)

4

O(n^2)

15

Multiple Choice

What is the difference between is and == in Python?

1

is checks value equality, and == checks reference equality.

2

Both check reference equality.

3

Both check value equality.

4

is checks reference equality, and == checks value equality.

What is the correct syntax to print a string in Python?

1

echo "Hello, World!"

2

print("Hello, World!")

3

printf("Hello, World!")

4

System.out.println("Hello, World!")

Show answer

Auto Play

Slide 1 / 15

MULTIPLE CHOICE