wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Basics Quiz

Total questions: 15

Worksheet time: 11mins

Name
Class
Date
1.

What is a variable?

a)

Variables are those which delete programs

b)

A variable is an entity which stores some values

c)

Values stored in a variable can't be changed

d)

A variable is something used to repeat steps

2.

"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

3.

enemy = hero.findNearestEnemy( )

What is findNearestEnemy( ) ?

a)

It is a null function

b)

It is a function of the object hero called "method"

c)

a variable

d)

function definition

4.

enemy = hero.findNearestEnemy( )

in the variable enemy what is being stored?

a)

The name of the nearest enemy if present

b)

The nearest enemy object if present

c)

it is a conditional to check if enemy is present

d)

hero.findNearestEnemy( ) is a method to find the nearest enemy

5.

Which of the following symbols is used in the beginning of a line to create a single line comment in Python?

a)

&&

b)

@

c)

*

d)

#

6.

def goToDistance(x, y):

hero.moveXY( (a)   )

Fill in the blanks if using the goToDistance( ) function the hero needs to move to (34, 50)

7.

What is a syntax?

a)

Syntaxes are not written in a code to explain inner code workings

b)

The symbols used in computer programming are called syntaxes

c)

The rule following which different computer programs are written.

d)

All are correct

8.

Choose the correct alternative out of the following

a)

while loops can be used to create infinite loops only

b)

Python if else conditionals cannot be used to compare values

c)

Python is nothing but english

d)

The inputs to the functions or methods are called arguments

9.

What will be the output of the following code snippet? <please ignore the parenthesis>

name1 = "jazz"

name 2 = "madonna"

if name1 != name2:

print("No")

else:

print("Yes")

a)

No

b)

madonna

c)

Yes

d)

Compilation Error

10.

cleave = hero.isReadyToCleave( )

a)

The cleave variable is checking if cleave is ready

b)

cleave is not a variable, it is a conditional here

c)

The confirms that hero is not ready to cleave

d)

cleave is a variable storing True/False, depending on the hero to be ready to cleave or not

11.

while True:

.............

.............

break

What does a break statement do inside the "While-True" loop

a)

The break statement breaks the code creating an error

b)

It breaks the loop, else the loop will run infinitely

c)

Break is just a template code and needs to be removed to execute the actual programs

d)

The break statement doesn't affect the code and can be ignored in this case

12.

You have a goal to collect 6 items in the game, what will be your argument for the method mentioned below?

game.addCollectGoal(_)

(a)  

13.

game.spawnPlayerXY("captain", 9, 18)

How many arguments does the spawnPlayerXY( ) method use here?

a)

1 argument which is "captain"

b)

There are no arguments in the method as methods do not need arguments mandatorily

c)

2 arguments 9 and 18

d)

3 arguments "captain", 9 and 18

14.

hero.findNearestItem( )

which of the following describes hero properly?

a)

hero is a function

b)

hero is an object

c)

hero is a variable

d)

It is just a python syntax

15.

Use the suitable method with the game object to spawn a "fence" at (23, 17)

<do not use spaces in your solution>

(a)