Font size
WorksheetsPython Basics Quiz
Total questions: 15
Worksheet time: 11mins
What is a variable?
Variables are those which delete programs
A variable is an entity which stores some values
Values stored in a variable can't be changed
A variable is something used to repeat steps
"def" keyword is used in python to-
def is a variable
define a new conditional variable
use conditional
define a new function
enemy = hero.findNearestEnemy( )
What is findNearestEnemy( ) ?
It is a null function
It is a function of the object hero called "method"
a variable
function definition
enemy = hero.findNearestEnemy( )
in the variable enemy what is being stored?
The name of the nearest enemy if present
The nearest enemy object if present
it is a conditional to check if enemy is present
hero.findNearestEnemy( ) is a method to find the nearest enemy
Which of the following symbols is used in the beginning of a line to create a single line comment in Python?
&&
@
*
#
def goToDistance(x, y):
hero.moveXY( (a) )
Fill in the blanks if using the goToDistance( ) function the hero needs to move to (34, 50)
What is a syntax?
Syntaxes are not written in a code to explain inner code workings
The symbols used in computer programming are called syntaxes
The rule following which different computer programs are written.
All are correct
Choose the correct alternative out of the following
while loops can be used to create infinite loops only
Python if else conditionals cannot be used to compare values
Python is nothing but english
The inputs to the functions or methods are called arguments
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")
No
madonna
Yes
Compilation Error
cleave = hero.isReadyToCleave( )
The cleave variable is checking if cleave is ready
cleave is not a variable, it is a conditional here
The confirms that hero is not ready to cleave
cleave is a variable storing True/False, depending on the hero to be ready to cleave or not
while True:
.............
.............
break
What does a break statement do inside the "While-True" loop
The break statement breaks the code creating an error
It breaks the loop, else the loop will run infinitely
Break is just a template code and needs to be removed to execute the actual programs
The break statement doesn't affect the code and can be ignored in this case
You have a goal to collect 6 items in the game, what will be your argument for the method mentioned below?
game.addCollectGoal(_)
(a)
game.spawnPlayerXY("captain", 9, 18)
How many arguments does the spawnPlayerXY( ) method use here?
1 argument which is "captain"
There are no arguments in the method as methods do not need arguments mandatorily
2 arguments 9 and 18
3 arguments "captain", 9 and 18
hero.findNearestItem( )
which of the following describes hero properly?
hero is a function
hero is an object
hero is a variable
It is just a python syntax
Use the suitable method with the game object to spawn a "fence" at (23, 17)
<do not use spaces in your solution>
(a)
