wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Quiz

Total questions: 56

Worksheet time: 28mins

Name
Class
Date
1.

What is a variable in Python?

a)

A fixed value that cannot be changed

b)

A named location in memory that stores data

c)

A type of function

d)

A method to print data

2.

Which of the following is an example of an integer in Python?

a)

3.14

b)

"Hello, World!"

c)

True

d)

-3

3.

What data type in Python represents logical values?

a)

int

b)

float

c)

str

d)

bool

4.

Which of the following is an example of a string in Python?

a)

5

b)

3.14

c)

"Hello, World!"

d)

False

5.

What does it mean that Python is dynamically typed?

a)

You must declare the type of a variable before using it

b)

The type of a variable is determined at runtime

c)

Variables cannot change type once assigned

d)

Python does not support different data types

6.

Which of the following is the correct way to declare an integer variable in Python?

a)

age = "30"

b)

age = 30.0

c)

age = 30

d)

age = True

7.

What data type is the variable 'height' in the example script?

height = 5.3

a)

Integer

b)

Float

c)

String

d)

Boolean

8.

In the example script, what is the value assigned to the variable 'name'?

name = '

a)

"Jane Doe"

b)

"John Doe"

c)

"Doe John"

d)

"Student"

9.

Which function is used to print the type of a variable in Python?

a)

print_type()

b)

type()

c)

getType()

d)

showType()

10.

What is the value of the boolean variable 'is_student' in the example script?

a)

False

b)

"True"

c)

True

d)

"False"

11.

Which of the following statements correctly prints the type of the variable 'name'?

a)

print("Name:", name, type(name))

b)

print("Name:", name, getType(name))

c)

print("Name:", name, showType(name))

d)

print("Name:", name, print_type(name))

12.

What is the purpose of the lab exercise described in the document?

a)

To learn how to create functions in Python

b)

To understand how to declare and print variables of different data types

c)

To learn how to write loops in Python

d)

To understand how to handle exceptions in Python

13.

Why are data types important in programming?

a)

They determine how values are stored and manipulated in memory.

b)

They make the code look more colorful.

c)

They help in writing comments in the code.

d)

They are used to name variables.

14.

What is one of the best practices for naming variables?

a)

Using meaningful names.

b)

Using random names.

c)

Using only numbers.

d)

Using special characters.

15.

What is a potential benefit of dynamic typing in Python?

a)

Flexibility in variable assignment.

b)

Increased memory usage.

c)

Slower execution time.

d)

More complex syntax.

16.

What should a Python script do according to the assignment in the document?

a)

Ask the user to input their name, age, and height.

b)

Calculate the sum of two numbers.

c)

Print "Hello, World!".

d)

Sort a list of numbers.

17.

What function is used in Python to display the type of each input?

a)

type()

b)

print()

c)

input()

d)

len()

18.

What is the primary purpose of arithmetic operators in Python?

a)

To perform mathematical operations on numerical data.

b)

To compare two values.

c)

To assign values to variables.

d)

To perform logical operations.

19.

Which arithmetic operator is used to add two numbers in Python?

a)

+

b)

-

c)

*

d)

/

20.

What does the floor division (//) operator do in Python?

a)

Divides the first number by the second and returns the largest integer less than or equal to the result.

b)

Divides the first number by the second.

c)

Returns the remainder of the division.

d)

Raises the first number to the power of the second.

21.

Which operator is used to raise the first number to the power of the second in Python?

a)

**

b)

%

c)

/

d)

*

22.

What is the result of the modulus (%) operator in Python?

a)

Returns the remainder of the division.

b)

Adds two numbers.

c)

Subtracts the second number from the first.

d)

Multiplies two numbers.

23.

What is the output of the following code snippet? x = True y = False print(x and y)

a)

True

b)

False

c)

None

d)

Error

24.

What is the output of the following code snippet? x = True y = False print(x or y)

a)

True

b)

False

c)

None

d)

Error

25.

What is the output of the following code snippet? x = True print(not x)

a)

True

b)

False

c)

None

d)

Error

26.

In which scenario are logical operators crucial?

a)

Arithmetic calculations

b)

User authentication or validation processes

c)

Data storage

d)

File management

27.

What is the purpose of assignment operators in programming?

a)

To compare two values.

b)

To assign values to variables.

c)

To print values to the console.

d)

To create loops.

28.

Which of the following assignment operators is used to add and assign the result to the variable?

a)

=

b)

-=

c)

+=

d)

/=

29.

What is the equivalent expression for the assignment operator x -= 3?

a)

x = x + 3

b)

x = x - 3

c)

x = x * 3

d)

x = x / 3

30.

In the given example, what is the output of the expression x *= 2 if x initially equals 12?

a)

24

b)

6

c)

15

d)

10

31.

Which assignment operator is used to divide and assign the result to the variable?

a)

*=

b)

+=

c)

-=

d)

/=

32.

What is the output of the following code snippet? x = 10 x += 5 print(x)

a)

5

b)

10

c)

15

d)

20

33.

What is the output of the following code snippet? x = 10 x /= 4 print(x)

a)

2.5

b)

4.0

c)

6.0

d)

2.0

34.

Which of the following tasks is part of Task 1: Arithmetic Operations in the lab instructions?

a)

Calculate the sum, difference, product, and quotient of two numbers.

b)

Compare two user-input values and print whether they are equal, not equal, greater, or less than each other.

c)

Create a script that evaluates multiple conditions using and, or, and not operators.

d)

Write a script that uses assignment operators to update a variable based on arithmetic operations.

35.

In Task 2: Comparison Operations, what are students required to do?

a)

Calculate the sum, difference, product, and quotient of two numbers.

b)

Compare two user-input values and print whether they are equal, not equal, greater, or less than each other.

c)

Create a script that evaluates multiple conditions using and, or, and not operators.

d)

Write a script that uses assignment operators to update a variable based on arithmetic operations.

36.

Which of the following is an example of a task in Task 3: Logical Operations?

a)

Calculate the sum, difference, product, and quotient of two numbers.

b)

Compare two user-input values and print whether they are equal, not equal, greater, or less than each other.

c)

Check if a user-provided number is within a certain range.

d)

Write a script that uses assignment operators to update a variable based on arithmetic operations.

37.

What is the main objective of Task 4: Assignment Operations?

a)

Calculate the sum, difference, product, and quotient of two numbers.

b)

Compare two user-input values and print whether they are equal, not equal, greater, or less than each other.

c)

Create a script that evaluates multiple conditions using and, or, and not operators.

d)

Write a script that uses assignment operators to update a variable based on arithmetic operations.

38.

What should students do to understand how operators behave, according to the Lab Notes?

a)

Submit the Python script file with all the tasks completed.

b)

Include comments in the script to explain each operation.

c)

Test their scripts with different inputs.

d)

Print a message indicating whether the budget is exceeded.

39.

What is one of the deliverables for the Homework Assignment: Applying Operators?

a)

Write a script that uses assignment operators to update a variable based on arithmetic operations.

b)

Submit the Python script file with all the tasks completed.

c)

Compare two user-input values and print whether they are equal, not equal, greater, or less than each other.

d)

Create a script that evaluates multiple conditions using and, or, and not operators.

40.

Which of the following is NOT a key concept covered in the quiz on operators?

a)

Arithmetic operators

b)

Comparison operators

c)

Logical operators

d)

String manipulation

41.

What will students be evaluated on during in-class participation?

a)

Their ability to complete the lab exercises

b)

Their ability to write essays

c)

Their ability to solve puzzles

d)

Their ability to draw diagrams

42.

What is the purpose of the detailed plan for Chapter 2, Lesson 2?

a)

To ensure students gain a solid understanding of Python operators

b)

To teach students how to write essays

c)

To help students learn about historical events

d)

To improve students' drawing skills

43.

What do bitwise operators in Python allow for?

a)

Manipulation of individual bits in binary numbers

b)

Manipulation of individual characters in strings

c)

Manipulation of individual elements in lists

d)

Manipulation of individual pixels in images

44.

Which of the following is NOT an objective of learning bitwise operators in Python?

a)

Understand what bitwise operators are and how they work in Python

b)

Learn to apply bitwise operators to perform operations on binary numbers

c)

Practice using bitwise operators in practical scenarios

d)

Learn to manipulate individual characters in strings

45.

What is the binary representation of the number 5?

a)

0101

b)

0011

c)

1001

d)

0110

46.

What is the result of the bitwise AND operation between 5 and 3?

a)

1

b)

7

c)

5

d)

3

47.

What is the result of the bitwise OR operation between 5 and 3?

a)

7

b)

1

c)

5

d)

3

48.

What is the binary representation of the number 3?

a)

0011

b)

0101

c)

1001

d)

0110

49.

What does the Bitwise XOR (^) operation do?

a)

Compares each bit of two numbers and returns a new number where each bit is 1 if the corresponding bits of the operands are different.

b)

Inverts the bits of its operand, changing 1s to 0s and 0s to 1s.

c)

Shifts the bits of a number to the left by a specified number of positions.

d)

Shifts the bits of a number to the right by a specified number of positions.

50.

What is the result of the Bitwise XOR operation 5 ^ 3?

a)

6

b)

8

c)

2

d)

10

51.

What does the Bitwise NOT (~) operation do?

a)

Compares each bit of two numbers and returns a new number where each bit is 1 if the corresponding bits of the operands are different.

b)

Inverts the bits of its operand, changing 1s to 0s and 0s to 1s.

c)

Shifts the bits of a number to the left by a specified number of positions.

d)

Shifts the bits of a number to the right by a specified number of positions.

52.

What is the result of the Bitwise NOT operation ~5?

a)

-6

b)

6

c)

-5

d)

5

53.

What does the Left Shift (<<) operation do?

a)

Compares each bit of two numbers and returns a new number where each bit is 1 if the corresponding bits of the operands are different.

b)

Inverts the bits of its operand, changing 1s to 0s and 0s to 1s.

c)

Shifts the bits of a number to the left by a specified number of positions, filling the vacant bits with zeros.

d)

Shifts the bits of a number to the right by a specified number of positions, discarding the bits shifted off.

54.

What is the result of the Left Shift operation 5 << 1?

a)

10

b)

5

c)

1

d)

2

55.

What does the Right Shift (>>) operation do?

a)

Compares each bit of two numbers and returns a new number where each bit is 1 if the corresponding bits of the operands are different.

b)

Inverts the bits of its operand, changing 1s to 0s and 0s to 1s.

c)

Shifts the bits of a number to the left by a specified number of positions, filling the vacant bits with zeros.

d)

Shifts the bits of a number to the right by a specified number of positions, discarding the bits shifted off.

56.

What is the result of the Right Shift operation 5 >> 1?

a)

2

b)

5

c)

1

d)

10