Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Test11

Total questions: 30

Worksheet time: 30mins

Name
Class
Date
1.

Which of the following describes the role of a Python interpreter?

a)

It converts Python code into Java bytecode.

b)

It executes Python code line by line, translating it just-in-time.

c)

It translates the entire source code into machine code before execution.

d)

It's primarily used for debugging Python applications only.

2.

Which of the following is NOT a fundamental property of the Python language?

a)

Statically typed

b)

Object-oriented

c)

Uses significant indentation

d)

Interpreted

3.

Which of these are valid Python keywords?

a)

do...while

b)

typedef

c)

yield

d)

return

4.

What is the output of the following code?

a)

A

b)

A B C

c)

B C

d)

C

5.

How would you correctly represent the logical literal 'false' in Python?

a)

false

b)

False

c)

0

d)

NULL

6.

What is the output of print(type(0.0034))?

a)

<class 'float'>

b)

<class 'int'>

c)

<class 'decimal'>

d)

float

7.

Which of the following are valid ways to include a comment in Python?

a)

# This is a comment

b)

'''This is a\nmulti-line comment'''

c)

// This is a comment

d)

/* This is a comment */

8.

What will the code print(input('Enter value: ')) display and then wait for?

a)

It will display nothing, just wait for input.

b)

It will display 'Enter value: ' and then print the user's input.

c)

It will display 'Enter value: ' and then print 'None'.

d)

It will cause a TypeError.

9.

Which number system is most commonly used by computers internally?

a)

Decimal (Base-10)

b)

Binary (Base-2)

c)

Hexadecimal (Base-16)

d)

Octal (Base-8)

10.

What is the result of 7 // 2 and 7 / 2 respectively?

a)

3 and 3

b)

3 and 3.5

c)

3.5 and 3

d)

3.5 and 3.5

11.

Which operators are used for string repetition and concatenation in Python?

a)

* for repetition, + for concatenation

b)

x for repetition, & for concatenation

c)

repeat() for repetition, join() for concatenation

d)

** for repetition, . for concatenation

12.

If my_value = 10, what will my_value be after my_value -= 3?

a)

3

b)

7

c)

10

d)

Error

13.

Which of the following data types are mutable in Python?

a)

int

b)

list

c)

tuple

d)

str

14.

What is the result of the bitwise operation 10 << 1?

a)

5

b)

10

c)

20

d)

12

15.

Which of the following logical expressions evaluates to True?

a)

not (5 > 3 and 2 < 1)

b)

True or False and False

c)

10 == 10 and not False

d)

False or (True and False)

16.

What does len("Python") return?

a)

6

b)

"Python"

c)

Error

d)

None

17.

You want to print two variables, name and age, on the same line, separated by a comma and a space, and ending with a period. Which print() statement achieves this?

a)

print(name, age, sep= ', ' , end='.')

b)

print(name + ', ' + str(age) + '.')

c)

print(name, age, separator =', ' , end_char='.')

d)

print(f'{name}, {age}.')

18.

What is the data type of the object [1, 2, 3]?

a)

tuple

b)

set

c)

list

d)

dictionary

19.

Which of these statements correctly calculate 23 in Python?

a)

2 ^ 3

b)

2 ** 3

c)

pow(2, 3)

d)

2 * 3

20.

Given my_string = "Python Programming", what is the output of my_string[7:11]?

a)

Prog

b)

Progr

c)

ram

d)

ram

21.

What will be the output of this code?

a)

0 1 2 3 4

b)

0 1 2 3 4 5

c)

Infinite loop

d)

Error

22.

Which of the following are true about the range() function?

a)

It generates a list of numbers.

b)

It can take one, two, or three arguments.

c)

The stop value is exclusive.

d)

It always starts counting from 1.

23.

When does the else block associated with a while loop execute?

a)

When the while loop condition initially evaluates to False.

b)

When the while loop terminates normally (i.e., without a break statement).

c)

Every time the while loop condition is checked and is False.

d)

If an Exception occurs within the loop.

24.

What is the purpose of the break statement in a loop?

a)

To skip the current iteration and move to the next.

b)

To immediately exit the innermost loop.

c)

To restart the loop from the beginning.

d)

To raise an exception.

25.

Given my_list = [10, 20, 30, 40, 50], what is the output of my_list[1:4]?

a)

[10, 20, 30, 40]

b)

[20, 30, 40]

c)

[20, 30, 40, 50]

d)

[10, 20, 30]

26.

Which of the following list methods adds an element at a specific position?

a)

append()

b)

extend()

c)

insert()

d)

add()

27.

Given my_tuple = (1, 2, 3), which of the following operations is valid?

a)

my_tuple[0] = 5

b)

my_tuple.append(4)

c)

new_tuple = my_tuple + (4,) *

d)

del my_tuple[0]

28.

How do you add a new key-value pair ('city': 'London') to an existing dictionary my_dict = {'name': 'Alice'}?

a)

my_dict.add('city', 'London')

b)

my_dict['city'] = 'London'

c)

my_dict.update({'city': 'London'})

d)

my_dict.append('city', 'London')

29.

What is the result of "hello".upper()?

a)

"HELLO"

b)

"Hello"

c)

hello

d)

Error

30.

When a Python function is called, what is the correct term for the actual values passed into the function?

a)

Parameters

b)

Arguments

c)

Return values

d)

Variables