1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Julia

Exercise

Converting types

Integers, floats, and strings are the most common data types you will encounter when working with Julia. Certain operations can only be performed on certain data types, and some operations work differently based on the data type.

For example, in Julia 3*2 will return 6, but "3"*"2" will return "32". These kinds of bugs can crash your code or ruin your analysis, so it is important to know how to convert between types.

Instructions 1/4

undefined XP
  • 1
    • Convert the float a_float into an integer, assign it to a new variable named a_int, and print a_int's type.
  • 2
    • Convert the integer b_int from an integer to a float, and assign the result to b_float.
  • 3
    • Convert the integer c_int into a string and assign it to the variable c_string.
  • 4
    • Convert the string d_string into a float and assign it to the variable d_float.