wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Understanding Python

Total questions: 20

Worksheet time: 6mins

Name
Class
Date
1.

To display something on the screen, use this command:

a)

print()

b)

Print()

c)

screen()

d)

write()

e)

display()

2.

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!)"

3.
Which symbol do we use if we want to add a comment to our code?
a)
@
b)
#
c)
*
d)
&
4.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
5.

Which operator performs a division?

a)

-

b)

+

c)

/

d)

*

6.
Which of the following is a float?
a)
new_var = 1234
b)
new_var = True
c)
new_var = 1.234
d)
new_var = "True"
7.
Which of the following is not a string?
a)
new_var = "True"
b)
new_var = "3123"
c)
new_var = "3.123"
d)
new_var = False
8.

Which of the following is correct?

a)

Comments are for programmers for better understanding of the program.

b)

Python Interpreter ignores comment.

c)

You can write multi-line comments in Python using triple quotes, either ''' or """.

d)

All of the above

9.

In the following code, n is a/an _______?


n = '5'

a)

integer

b)

string

c)

tuple

d)

operator

10.

What is used to take input from the user in Python?

a)

cin

b)

scanf()

c)

input()

d)

<>

11.

Which of the following is correct?

a)

Variable name can start with an underscore.

b)

Variable name can start with a digit.

c)

Keywords cannot be used as a variable name.

d)

Variable name can have symbols like: @, #, $ etc.

12.

What is the output of the following code?


numbers = [2, 3, 4]

print(numbers)

a)

2, 3, 4

b)

2 3 4

c)

[2, 3, 4]

d)

[2 3 4]

13.

What is the output of the following code?


print(3 >= 3)

a)

3 >= 3

b)

True

c)

False

d)

None

14.

Which one will display when this code is run?

a)
b)
c)
d)
15.
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
16.

a = 10

b = 5

if b > a

print("b is bigger")

a)

True

b)

False

17.

In For loop


for i in range (0, 10, 1)

the range got represent what?

a)

start

b)

stop

c)

step

d)

All of the above

18.

.pop() can use in where?

a)

dictionary

b)

list

c)

both

19.

Choose the correct syntax of the replace function:

a)

x.Replace(x)

b)

x.replace(y)

c)

x.replace(3,x)

d)

x.replace("j","3")

20.

The correct syntax for converting the string myname to lowercase is :

a)

myNAME.lower[ ]

b)

myname.lower( )

c)

myname.upper( )

d)

myname_lower(12 )