WorksheetsBasic Coding Concepts in GDScript
Total questions: 22
Worksheet time: 28mins
Which of the following is a correct variable declaration in Godot? (Select 3)
var points: int = 0
var myVariable: int
let myVariable = int
var myVariable: float = 3.14
var float: int = 34
Complete the line of code below to correctly define a constant float variable in GDScript.
(a) pi: float = (b)
const
3.14
def
57
Which of these data types are supported in GDScript? (Select 3)
Double
Char
Integer
Float
Bool
What are the different types of conditional statements in GDScript? (Select 2)
if
for
else
when
elif
What is the purpose of loops in programming?
The purpose of loops in programming is to automate the execution of repetitive tasks.
Loops are designed to execute tasks only once in programming
The purpose of loops is to slow down the program execution
Loops in programming are used to create chaos and confusion
What are the types of loops available in GDScript? (Select 2)
while
do-while
repeat
for
when
How do you write a for loop in GDScript? (Select 2)
for (i = 0; i < 10; i++):
for i = 0 to 10:
for i in range(0, 10):
for i in range(10):
for range(0, 10):
What is a function in programming?
A function in programming is a block of code that performs a specific task.
A function in programming is a variable that stores data
A function in programming is a loop that repeats a set of instructions
A function in programming is a comment that explains code
What is the difference between a function and a method in GDScript?
A function is standalone, while a method is associated with an object or class.
A function is associated with an object, while a method is standalone.
A function can only be used in classes, while a method can be used anywhere.
A function can access class variables, while a method cannot.
Complete the line of code below to declare a String array with the name enemyAttack and the item "Blizzard" on index 1.
(a) (b) = [ (c) , (d) , "Thunder"]
def
enemy Attack
An array in programming is a data structure that stores a collection of elements, typically of the same data type, in a contiguous block of memory.
True
False
Arrays can only store one data type, while lists can store multiple data types in GDScript.
True
False
Complete Line 7 on the code attached to print the number 10.
print( (a) )
num1
num2
What is wrong with Line 7 of the attached code?
The value in num1 must contain decimal places.
The value in num1 cannot be changed.
There must be indentions on Line 7.
There are NO errors on Line 7.
The given code must display 0-10. What is wrong with Line 6 of the attached code?
range must be (0, 11)
x must be declared first.
Line 6 must have NO indentation.
There are NO errors on Line 6.
Which of the following GDScript code is equivalent to this (Select 2):
for (i=0, i<=5, i++)
for i in range(5):
for i in range(6):
for i in [0, 6]:
for i in range(0, 5):
for i in range(0, 6):
Complete Line 7 on the given image to print all items on array1.
for (a) in (b)
a
array1
i
list1
x
array2
The given code will add all numbers from 1-100. Complete Line 7 to do this.
for x in range ( (a) , (b) )
100
99
Which of the following can you do to remove the error on Line 7 and print the number 7? (Select 2)
Change "_ready" to "_const" on Line 5
Change "func" to "def" on Line 5
Remove Line 7, and change "10" to "7" on Line 6.
Remove Line 7 completely.
Change "const" to "var" from Line 6
The given code should output "Hello" if the number is less than 5, otherwise, will print "World". What should you do on Line 8 to remove the error?
Add a semicolon at the end of the line.
Change "print" to "scan"
Add indentation to Line 8 once.
There are no errors on Line 8.
What is the output of the code attached?
3070
100
num1+num2
Error
Organize these values into the right categories.
37
42
99
6.29
2.718
"apple"
"banana"
"56"
