wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Basic Python Programming Concepts

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is the correct way to create a variable in Python?

a)

let x = 10

b)

x : 10

c)

10 = x

d)

x = 10

2.

Which of the following is a valid Python data type?

a)

int

b)

float

c)

string

d)

list

3.

What symbol is used for comments in Python?

a)

#

c)

//

d)

%%

4.

How do you start a function definition in Python?

a)

function_name(parameters) start with def

b)

def function_name(parameters):

c)

function_name(parameters) is defined using define

d)

function_name(parameters) begin with func

5.

Which of the following is used to create a loop in Python?

a)

repeat

b)

looping

c)

for, while

d)

iterate

6.

What will be the output of print(2 ** 3)?

a)

6

b)

9

c)

4

d)

8

7.

How do you check the type of a variable in Python?

a)

Use the 'checktype()' function.

b)

Use the 'instanceof' operator.

c)

Use the 'var_type()' method.

d)

Use the 'type()' function.

8.

Which keyword is used to handle exceptions in Python?

a)

catch

b)

finally

c)

except

d)

throw

9.

What is the output of the following code: print('Hello' + ' World')?

a)

Hello World

b)

HelloWorld

c)

Hello, World

d)

Hello World!

10.

How do you create a list in Python?

a)

You create a list in Python using square brackets, e.g., my_list = [1, 2, 3].

b)

You create a list in Python by using the list() function, e.g., my_list = list(1, 2, 3).

c)

You create a list in Python using parentheses, e.g., my_list = (1, 2, 3).

d)

You create a list in Python using curly braces, e.g., my_list = {1, 2, 3}.

11.

Which of the following is a correct way to import a module in Python?

a)

using math;

b)

require('math')

c)

import math()

d)

import math

12.

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

a)

The 'return' statement is used to declare variables within a function.

b)

The 'return' statement is used to define a function's name.

c)

The 'return' statement stops the execution of a program entirely.

d)

The 'return' statement provides a way to output a value from a function.

13.

How do you define a class in Python?

a)

class ClassName: pass

b)

class ClassName() {}

c)

define ClassName as a function

d)

class ClassName[]:

14.

What is the output of the following code: print(len('Python'))?

a)

8

b)

7

c)

6

d)

5

15.

Which operator is used for comparison in Python?

a)

Logical operators

b)

Comparison operators

c)

Arithmetic operators

d)

Bitwise operators