Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a hexadecimal integer literal.
Swift
let hexNumber = 0[1]1A
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0b or 0o instead of 0x for hexadecimal.
Forgetting the letter after 0.
✗ Incorrect
In Swift, hexadecimal literals start with 0x.
2fill in blank
mediumComplete the code to declare a binary integer literal.
Swift
let binaryNumber = 0[1]1011
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0x or 0o instead of 0b for binary.
Omitting the prefix.
✗ Incorrect
Binary literals in Swift start with 0b.
3fill in blank
hardFix the error in the code to declare an octal integer literal.
Swift
let octalNumber = 0[1]17
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0b or 0x instead of 0o for octal.
Writing octal numbers without prefix.
✗ Incorrect
Octal literals in Swift start with 0o.
4fill in blank
hardFill both blanks to declare a floating-point literal with an exponent.
Swift
let floatNumber = 1.25[1]3[2]2
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'p' instead of 'e' for decimal exponents.
Omitting the sign after the exponent.
✗ Incorrect
Floating-point literals with decimal exponents use e followed by a plus or minus sign.
5fill in blank
hardFill all three blanks to declare a hexadecimal floating-point literal with a negative exponent.
Swift
let hexFloat = 0x1.[1]p[2][3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'e' instead of 'p' for hexadecimal floating-point literals.
Omitting the sign before the exponent.
✗ Incorrect
Hexadecimal floating-point literals use p followed by a sign and exponent number.