Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PYTHON BASICS

Total questions: 23

Worksheet time: 14mins

Name
Class
Date
1.
The correct way to write a variable in Python?
a)
my_variable = 10
b)
my variable = 10
c)
my_variable is 10
d)
my_variable: 10
2.
Data type for a whole number
a)
String
b)
Integer
c)
Boolean
d)
Float
3.
What is python named after
a)
The snake
b)
Television show called Monty Python
4.
What syntax can you use to insert a line break between strings so that they appear over multiple lines?
a)
/
b)
\n
c)
\l
d)
n
5.

Features of Python

a)

Easy to learn and read

b)

Portable

c)

GUI programming

d)

All of the above

6.
The number or word we give to a variable
a)
Value
b)
Bug
c)
Information
d)
Text
7.

To display something on the screen, use this command:

a)

print()

b)

Print()

c)

screen()

d)

write()

e)

display()

8.

To display the following on screen

Hello World!

the following command should be used:

a)

print(Hello World!)

b)

print("Hello World!")

c)

print("Hello World" + !)

d)

print"(Hello World!)"

9.

Everything that we want do display in a print() function must:

a)

be inside parentheses - ()

b)

quotation marks - " "

c)

be inside single quotation marks - ''

d)

be inside hash marks - #

10.

An Operator is:

a)

A person that performs operations

b)

a symbol that specifies the operation to perform

c)

a symbol that means the code will run

d)

a line of code

11.
Choose the statement that assigns 4 to the power of 3 to the variable new_var...
a)
new_var = 4 ** 3
b)
new_var = 3 ** 4
c)
new var = 3 ** 4
d)
new_var = 4 ^^ 3
12.

What is the name of the environment in Python that write your programs and then test them out?

a)

Shell

b)

Window

c)

IDLE

d)


CLI

13.

Which operator checks if a value is equal to another value?

a)

+

b)

-

c)

==

d)

!=

14.

x = 5


x%=3


print(x)

a)

2

b)

2.0

c)

3

d)

3.0

15.

What is the value of the expression 100 / 25?

a)

4

b)

4.0

c)

"4.0"

d)

'4.0'

16.

What is the output of the following code :


print 9//2

a)

4.5

b)

4.0

c)

4

d)

3

17.

What is the answer of this expression, 22 % 3 is?

a)

7

b)

1

c)

0

d)

5

18.

Select the valid Octal integer literals

a)

0836

b)

7976

c)

07362

d)

0x1726

19.

Choose the INVALID identifiers from the following

a)

NUmbEr1

b)

1NUMBer

c)

A_B

d)

A&B

20.

(a)   is smallest individual unit in a program.

21.

What is the output of the following code :


print 7//2

a)

3.5

b)

3.0

c)

3

d)

4

22.

Which of the following is a correct way to comment a single line in Python?

a)

// This is a comment

b)

# This is a comment

c)

/* This is a comment */

d)

" This is a comment "

23.

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

a)

To exit the current loop prematurely

b)

To skip the current iteration of a loop

c)

To continue to the next iteration of a loop

d)

To end the program execution