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

Connected

Exercise

If-else practice

Conditional statements will come up in your code in lots of places, so its really important you are comfortable with them.

In the following samples you are writing little pieces of code to:

  1. Find the absolute value of a number
  2. Find the maximum value of two numbers
  3. Print a message if your script has finished

The variables you need to complete these examples, x, y, and finished are available in your environment.

Instructions 1/3

undefined XP
  • 1
    • Complete the if-else statement to print x if it is greater than zero, and print -x otherwise.
  • 2
    • Complete the code so larger = x if the float x is bigger than the float y, and larger = y otherwise.
  • 3
    • If the boolean finished is true, print "Script has finished", otherwise print "Script still running"