wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python basics

Total questions: 16

Worksheet time: 8mins

Name
Class
Date
1.

What is a correct syntax to output "Hello World" in Python?

a)

echo("Hello World")

b)

echo "Hello World"

c)

print("Hello World")

d)

PRINT("Hello World")

2.

How do you insert COMMENTS in Python code?

a)

/*this is a comment

b)

//this is a comment

c)

#this is a comment

3.

Which one is NOT a legal variable name?

a)

my_var

b)

myvar

c)

_myvar

d)

my-var

4.

What is the correct file extension for Python files?

a)

.py

b)

.pt

c)

.pyt

d)

.pyth

5.

In Python, 'Hello', is the same as "Hello"

a)

yes

b)

no

6.

Which operator can be used to compare two values?

a)

=

b)

<>

c)

><

d)

==

7.

How do you create a variable with the numeric value 5?

a)

Both are correct

b)

x=5

c)

x=int(5)

8.

How do you create a variable with the floating number 2.8?

a)

x=2.8

b)

x=float(2.8)

c)

both are correct

9.

If num1 = 5

num2 = 6

then what will be the output of num1*num2

a)

11

b)

6

c)

30

d)

-1

10.

If num1 = 3

num2 = 4

then what will be the output of num1 ** num2

a)

3

b)

7

c)

12

d)

81

11.

Which of the following is an acceptable variable name?

a)


no-text

b)

8text

c)

no_text

d)


no_text$

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.

What button do you press to compile (run) your program so that it runs in the shell?

a)

F3

b)

F5

c)

F7

d)

F11

14.

What symbol do you use to make a comment in Python?

a)


@

b)

:

c)


;

d)

#

15.

"def" keyword is used in python to-

a)

def is a variable

b)


define a new conditional variable

c)

use conditional

d)


define a new function

16.

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

a)

+

b)

-

c)

==

d)

!=