1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Julia

Connected

Exercise

Defining ranges

Ranges are an important concept in Julia, allowing you to quickly create an ordered collection of values. In this exercise, you want to generate a range of evenly-spaced points. Imagine if the spacing between each point was 1/3 - you would quickly find it hard to do this ourselves. This is where a range comes in - you can specify a start value, an optional step value, and an end value. Then, the range will automatically be generated for us.

There are two steps in the exercise below. In the first step, you will create and inspect a range with no step value specified. In the second step, you will create and inspect a second range, this time specifying a step value.

Instructions 1/2

undefined XP
  • 1
    • Create a simple range starting at one and ending at 10, and assign this to the variable x.
    • Print the type of the variable x.
  • 2
    • Assign to y a range again between one and 10, but this time with a step size of two.
    • Print the type of the variable y to the terminal.