Home > Articles > Programming > General Programming/Other Languages

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Exercises

  1. Declare and initialize a pair of variables for each type listed in this chapter, both explicitly and using type inference. What do you need to do to get the compiler to infer the Float type?
  2. Create a constant with an emoji character in the name. Are you able to easily use the constant? Does this help with the readability of your code?
  3. How would you explicitly declare an array that stores another array of Ints as each element? Show how you would access elements by using subscripts.
  4. Set up a dictionary that uses Ints as the key. How is this different from using an array? When could using a dictionary such as this be better than using an array?
  5. Create a Fizz Buzz implementation. Iterate through the numbers from 1 to 100. If a number is evenly divisible by 3, print Fizz. If the number is evenly divisible by 5, print Buzz. If the number is evenly divisible by both 3 and 5, print Fizz Buzz. For all other numbers, just print the number.
  • + Share This
  • 🔖 Save To Your Account