Finding the data type
When you perform a calculation, the data type of the result can be different than the data type of the inputs. This change in data types can happen without you realizing it and may cause your code to malfunction. Printing the data type of variables can help you track down issues caused by variables being a different data type than expected.
In this script, you are analyzing your run times again. Your last two times (30 minutes and 33 minutes) to run 5 kilometers have been assigned to the variables runtime_1
and runtime_2
.
In this exercise, you will find the average of your run times. You can find the average of two numbers, \(x\) and \(y\), using:
$$\text{average} =\frac{x+y}{2}$$
This exercise is part of the course
Introduction to Julia
Exercise instructions
- Print the data type of the variable
runtime_1
. - Print the data type of the variable
runtime_2
. - Calculate the average of the two run times and assign it to the variable
average_runtime
. - Print the data type of
average_runtime
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Print the type of runtime_1
____
# Print the type of runtime_2
____
# Calculate the average run time
average_runtime = ____
# Print the type of average_runtime
____