Task One Solutions
Swap the following variables around without using multiple assignment:
a = "A" b = "B"
a = "A" b = "B" temp = a a = b b = temp print(a, b)
This requires you to use a third variable to hold the contents of one of the original variables. This is avoided when using multiple assignment.
This code contains errors, identify and fix them:
Hello = a b = Print c = type b(c(a))
a = "Hello" b = print c = type b(c(a))
When assigning a variable, the contents need to appear on the right of the equal sign, and the variable name to the left. Strings also require quotation marks " " or ' '. Remember that Lua is case sensitive, meaning Print is not a real function, unlike print. While variables that contain just a function is ugly (and fairly pointless), it does highlight that any piece of code can be held in a variable.
Without running it, what would the outcome of this code be?
a = type(type(1)) print(a)
The type function always returns a string as it's result, regardless of the argument's datatype. Therefore, type of type is a string.