wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Basics

Total questions: 12

Worksheet time: 6mins

Name
Class
Date
1.

What is the correct extension of the Python file?

a)

.py

b)

.python

c)

None of these

d)

.p

2.

How to insert COMMENTS in Python code?

a)

"this is a comment"

b)

c)

#this is a comment

d)

None of these

3.

What do we use to define a block of code in Python language?

a)

None of these

b)

Key

c)

Brackets

d)

Indentation

4.

What is a correct syntax to output “REC" in Python?

a)

echo("REC")

b)

print("REC")

c)

echo “REC”

d)

print ”REC”

5.

What is the purpose of the input() function in Python?

a)

To take input from the user

b)

To convert an object into a string

c)

To print a message on the screen

d)

To add a string at the end of the output

6.

What is the purpose of the print() function in Python?

a)

To print a specified message on the screen

b)

To take input from the user

c)

To add a string at the end of the output

d)

To convert an object into a string

7.

What is the purpose of the int() function in Python?

a)

To return an integer number

b)

To return a complex number

c)

To return a Boolean value

d)

To return a decimal/floating point number

8.

What is the purpose of the str() function in Python?

a)

To return a decimal/floating point number

b)

To return a Boolean value

c)

To return a complex number

d)

To return a string

9.

What is the purpose of the bool() function in Python?

a)

To return a Boolean value

b)

To return a complex number

c)

To return an integer number

d)

To return a decimal/floating point number

10.

What is the purpose of the complex() function in Python?

a)

To return a Boolean value

b)

To return a decimal/floating point number

c)

To return a complex number

d)

To return an integer number

11.

What is the purpose of the % operator in Python?

a)

To multiply elements of values

b)

To replace instances of % in a string with elements of values

c)

To add elements of values

d)

To divide elements of values

12.

What is the purpose of the string format method in Python?

a)

To add elements of values

b)

To replace instances of % in a string with elements of values

c)

To divide elements of values

d)

To multiply elements of values