wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Class 8 Assessment

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What are the different data types in Python?

a)

The different data types in Python include: int, float, complex, str, list, tuple, dict, set, bool, bytes, bytearray, range, None

b)

int, float, str, bool, list

c)

integer, decimal, string, boolean, array

d)

number, text, boolean, array, dictionary

2.

How do you declare a variable in Python?

a)

value = variable_name

b)

variable_name = value

c)

value variable_name

d)

variable_name == value

3.

What is the syntax for an if-else statement in Python?

a)

if condition: # code to be executed if the condition is true else: # code to be executed if the condition is false

b)

if condition: # code to be executed if the condition is true else: # code to be executed if the condition is true

c)

if condition: # code to be executed if the condition is true else: # code to be executed if the condition is false

d)

if condition: # code to be executed if the condition is false else: # code to be executed if the condition is true

4.

What is the purpose of a function in Python?

a)

To perform a specific task or set of tasks, and allow for code reusability and modularity.

b)

To slow down the execution of the program

c)

To make the code more complicated and difficult to understand

d)

To make the code less organized and harder to maintain

5.

How do you import a module in Python?

a)

load moduleName

b)

use moduleName

c)

import moduleName

d)

include moduleName

6.

What is the difference between read() and readline() methods in file handling?

a)

The read() method reads one line at a time, while the readline() method reads the entire file at once.

b)

The read() method reads the entire file at once, while the readline() method reads one line at a time.

c)

The read() method reads the entire file at once, while the readline() method reads the entire file at once.

d)

The read() method reads one line at a time, while the readline() method reads one character at a time.

7.

What is the use of the 'with' statement in file handling?

a)

To open the file in read-only mode

b)

To create a new file

c)

To ensure proper file handling and automatic closing of the file

d)

To delete the file after use

8.

What is the difference between 'w' and 'a' modes in file handling?

a)

The 'w' mode is for writing and the 'a' mode is for appending.

b)

The 'w' mode is for appending and the 'a' mode is for writing

c)

The 'w' mode is for reading and the 'a' mode is for writing

d)

The 'w' mode is for reading and the 'a' mode is for appending

9.

How do you write to a file in Python?

a)

open('filename.txt', 'a').write('content')

b)

open('filename.txt', 'r').write('content')

c)

open('filename.txt', 'w').write('content')

d)

write('filename.txt', 'w').open('content')

10.

How do you define a class in Python?

a)

def ClassName():

b)

class ClassName:

c)

ClassName = class():

d)

ClassName = def():