Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare an integer variable named count with value 10.
iOS Swift
var count: [1] = 10
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Double instead of Int for whole numbers.
Using String when a number is needed.
✗ Incorrect
The type Int is used for whole numbers in Swift.
2fill in blank
mediumComplete the code to declare a variable price with a decimal value 9.99.
iOS Swift
var price: [1] = 9.99
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Int for decimal numbers causes errors.
Using Bool or String instead of a number type.
✗ Incorrect
The type Double is used for decimal numbers in Swift.
3fill in blank
hardFix the error in the code by choosing the correct type for the variable isActive.
iOS Swift
var isActive: [1] = true Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using String or Int for boolean values.
Using Double instead of Bool.
✗ Incorrect
The type Bool is used for true or false values in Swift.
4fill in blank
hardFill both blanks to declare a variable greeting with a text value.
iOS Swift
var greeting: [1] = [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around text values.
Using Bool or Int types for text.
✗ Incorrect
The type String is used for text. Text values must be in quotes.
5fill in blank
hardFill all three blanks to declare a variable temperature with a decimal value and print it.
iOS Swift
var [1]: [2] = [3] print(temperature)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Int instead of Double for decimal values.
Using wrong variable name.
✗ Incorrect
Declare a variable named temperature of type Double with value 36.6. Then print it.