Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Basic Coding Concepts in GDScript

Total questions: 22

Worksheet time: 28mins

Name
Class
Date
1.

Which of the following is a correct variable declaration in Godot? (Select 3)

a)

var points: int = 0

b)

var myVariable: int

c)

let myVariable = int

d)

var myVariable: float = 3.14

e)

var float: int = 34

2.

Complete the line of code below to correctly define a constant float variable in GDScript.

​ (a)   pi: ​ float = ​ (b)   ​

Choose from the below words

const

3.14

def

57

3.

Which of these data types are supported in GDScript? (Select 3)

a)

Double

b)

Char

c)

Integer

d)

Float

e)

Bool

4.

What are the different types of conditional statements in GDScript? (Select 2)

a)

if

b)

for

c)

else

d)

when

e)

elif

5.

What is the purpose of loops in programming?

a)

The purpose of loops in programming is to automate the execution of repetitive tasks.

b)

Loops are designed to execute tasks only once in programming

c)

The purpose of loops is to slow down the program execution

d)

Loops in programming are used to create chaos and confusion

6.

What are the types of loops available in GDScript? (Select 2)

a)

while

b)

do-while

c)

repeat

d)

for

e)

when

7.

How do you write a for loop in GDScript? (Select 2)

a)

for (i = 0; i < 10; i++):

b)

for i = 0 to 10:

c)

for i in range(0, 10):

d)

for i in range(10):

e)

for range(0, 10):

8.

What is a function in programming?

a)

A function in programming is a block of code that performs a specific task.

b)

A function in programming is a variable that stores data

c)

A function in programming is a loop that repeats a set of instructions

d)

A function in programming is a comment that explains code

9.

What is the difference between a function and a method in GDScript?

a)

A function is standalone, while a method is associated with an object or class.

b)

A function is associated with an object, while a method is standalone.

c)

A function can only be used in classes, while a method can be used anywhere.

d)

A function can access class variables, while a method cannot.

10.

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"]

Choose from the below words
var

def

enemyAttack
"Fire"
"Blizzard"

enemy Attack

11.

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.

a)

True

b)

False

12.

Arrays can only store one data type, while lists can store multiple data types in GDScript.

a)

True

b)

False

13.

Complete Line 7 on the code attached to print the number 10.

print(​ (a)   )

Choose from the below words

num1

num2

14.

What is wrong with Line 7 of the attached code?

a)

The value in num1 must contain decimal places.

b)

The value in num1 cannot be changed.

c)

There must be indentions on Line 7.

d)

There are NO errors on Line 7.

15.

The given code must display 0-10. What is wrong with Line 6 of the attached code?

a)

range must be (0, 11)

b)

x must be declared first.

c)

Line 6 must have NO indentation.

d)

There are NO errors on Line 6.

16.

Which of the following GDScript code is equivalent to this (Select 2):

for (i=0, i<=5, i++)

a)

for i in range(5):

b)

for i in range(6):

c)

for i in [0, 6]:

d)

for i in range(0, 5):

e)

for i in range(0, 6):

17.

Complete Line 7 on the given image to print all items on array1.

for ​ (a)   in ​ (b)  

Choose from the below words

a

array1

i

list1

x

array2

18.

The given code will add all numbers from 1-100. Complete Line 7 to do this.

for ​ x in range (​ (a)   , ​ (b)   )

Choose from the below words
1
101

100

99

19.

Which of the following can you do to remove the error on Line 7 and print the number 7? (Select 2)

a)

Change "_ready" to "_const" on Line 5

b)

Change "func" to "def" on Line 5

c)

Remove Line 7, and change "10" to "7" on Line 6.

d)

Remove Line 7 completely.

e)

Change "const" to "var" from Line 6

20.

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?

a)

Add a semicolon at the end of the line.

b)

Change "print" to "scan"

c)

Add indentation to Line 8 once.

d)

There are no errors on Line 8.

21.

What is the output of the code attached?

a)

3070

b)

100

c)

num1+num2

d)

Error

22.

Organize these values into the right categories.

Categorize the following

37

42

99

6.29

2.718

true
false

"apple"

"banana"

"56"

int
float
Bool
String