wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Get started with python

Total questions: 19

Worksheet time: 9mins

Name
Class
Date
1.

What are the basic data types in Python?

a)

char, list, tuple, dict

b)

int, float, str, bool

c)

int, float, array, set

d)

string, number, boolean, object

2.

How do you define a variable in Python?

a)

x : 10.

b)

int x = 10.

c)

x; 10.

d)

x = 10.

3.

What is the purpose of the 'if' statement in Python?

a)

To define a function in Python.

b)

To execute code conditionally based on a boolean expression.

c)

To create a loop that iterates over a list.

d)

To declare a variable in Python.

4.

Explain the difference between a list and a tuple in Python.

a)

A list is immutable and tuple is mutable

b)

Both lists and tuples are mutable

c)

A list contain integers, tuple contain string.

d)

A list is mutable and

tuple is immutable

5.

How functions is defined in python?

a)

Using 'def' keyword

b)

Using 'define' keyword

c)

Using 'func' keyword.

d)

Using x=fun()

6.

How do you import a module in Python?

a)

Using 'require' statement

b)

Using 'load' command

c)

Using 'import' statement

d)

By function call

7.

What is the syntax for a for loop in Python?

a)

for variable in sequence:

b)

for variable to sequence:

c)

foreach variable in sequence:

d)

for (variable : sequence)

8.

In python String concatenation is done using ?

a)

'concat()' method.

b)

'append()' function

c)

'+' operator.

d)

'&' operator.

9.

What is the output of the expression '5' + '3'?

a)

'53'

b)

'5''3'

c)

53

d)

8

10.

How do you access an element in a list by its index?

a)

list.get(index)

b)

list.index

c)

list[index]

d)

list[index + 1]

11.

What is the purpose of the 'return' statement in a function?

a)

To end the function execution immediately.

b)

To define the function's parameters.

c)

The purpose of the 'return' statement is to provide a value from a function to its caller.

d)

To create a loop within the function.

12.

How do you create a dictionary in Python?

a)

{'key': 'value'}.

b)

import dict module.

c)

('key', 'value')

d)

['key': 'value']

13.

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

a)

'==' compares values, 'is' compares identities.

b)

'==' is faster than 'is' for large data sets.

c)

'==' is used for assignment, 'is' is for comparison.

d)

'==' checks data types, 'is' checks values.

14.

How do you handle exceptions in Python?

a)

Exception handling not possible

b)

Using if-else statements

c)

Ignore exceptions & go on.

d)

Using try-except blocks

15.

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

a)

To exit the loop immediately.

b)

To skip the current iteration and continue with the next one.

c)

To pause the loop for a specified time.

d)

To define a new function within the loop.

16.

How can you check the length of a list in Python?

a)

Using the 'length()' function.

b)

Using 'len(list)'.

c)

Using 'size(list)'.

d)

Using 'count(list)'.

17.

What does the 'pass' statement do in Python?

a)

It terminates the program.

b)

It acts as a placeholder for future code.

c)

It raises an exception.

d)

It defines a new variable.

18.

What is the purpose of the 'elif' statement in Python?

a)

To define a function in Python.

b)

To execute multiple conditional checks in a sequence.

c)

To create a loop that iterates over a list.

d)

To declare a variable in Python.

19.

What is the output of the expression '10' * 3?

a)

30

b)

'101010'

c)

'10'*3

d)

TypeError