Recap - Initialize Variables
Part of the Fundamentals section of Coddy's GDScript journey. Lesson 13 of 92.
Challenge
BeginnerWrite code that creates the following, under the comment:
- a variable
k(lowercase) of typeintwith the value88 - a variable
ratioof typefloatwith the value3.14 - a variable
player_nameof typeStringwith the value"Bob" - a constant
MAX_LEVELwith the value10
Give each variable its type, with a colon or with :=. Use the exact names: GDScript is case-sensitive, so k and K are different. Do not change the print() lines. The program prints:
k = 88
ratio = 3.14
player_name = Bob
MAX_LEVEL = 10Try it yourself
extends Node
func _ready():
# Type your code below
# Don't change the lines below
print("k = ", k)
print("ratio = ", ratio)
print("player_name = ", player_name)
print("MAX_LEVEL = ", MAX_LEVEL)
All lessons in Fundamentals
4Operators Part 1
Arithmetic OperatorsInteger DivisionModulo OperatorArithmetic ShortcutsRecap - Simple MathComparison Operators10Functions
Declare a FunctionArgumentsReturnReturn TypesRecap - Sigma FunctionRecap - Validation FunctionDefault Values5Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3Ternary OperatorPractice on your own: Online GDScript compiler