IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Intermediate Julia

Visualizza il corso

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Define the range in the variable x
x = ____

# Print the type of the range x
println(____(____))
Modifica ed esegui il codice