Menu
CoddyTech

Recap - Initialize Variables

Part of the Fundamentals section of Coddy's GDScript journey. Lesson 13 of 92.

challenge icon

Challenge

Beginner

Write code that creates the following, under the comment:

  • a variable k (lowercase) of type int with the value 88
  • a variable ratio of type float with the value 3.14
  • a variable player_name of type String with the value "Bob"
  • a constant MAX_LEVEL with the value 10

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 = 10

Try 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

Practice on your own: Online GDScript compiler