...

Travel Adventure

As part of this project you will learn:

Conditional statements if/else

Conditional Statement

Condition is important in Programming language. In the process of writing your logic you often want to check if something is correct (or True) then do something, else do nothing (or do something else).

Make sure to use Colon (:) at the end of if and else statement

Python Indentation

Indentation is the spaces at the beginning of a code line. Statements written inside the body of if or else must be indented equally from the left side.

Logical Operations

  • Equals: a == b
  • Not Equals: a != b
  • Less than: a < b
  • Less than or equal to: a <= b
  • Greater than: a > b
  • Greater than or equal to: a >= b
  • Next
    Please ensure all required fields are filled in
    Step 1 : Tell The Story

    Let's create our adventure story and define all the possible conditions


    Prev Next
    Please ensure all required fields are filled in
    Step 2: Start coding
  • Open the blank Python template trinket: Open New.
  • Use the print() statement to tell begining of your story, e.g.
  • Use input() to input information into the program and ask for decision, follow the code on the picture..
  • Now RUN your program and enter right, left or forward. We will create a different story paths for each direction.
  • Prev Next
    Please ensure all required fields are filled in
    Step 3: Add IF condition path

  • Now we need to verify the entry value and create conditions for each possible variations.
  • We are checking if entered value is equals to right Make sure to use == for comparison
  • Next, we need to check two other conditions for left and forward
  • We will use Elif statements to check those conditions
  • Elif is a short way of else if

    Don't forget to use Colon : after each if, elif and else conditions

    Make sure all the code inside if, elif and else is shifted

    Prev Next
    Please ensure all required fields are filled in
    Step 4: Add Else Condition path

    Now we checked all the possible variations right, left and forward, but what if you've entered something different? So we need to add an Else condition for that. Type the next line of code as shown in the picture:

    After that run your code and test all four possible variations.

    Prev Next
    Please ensure all required fields are filled in
    Step 5: Add second level of IF/ELSE conditions

    We can add more conditions inside existing if or else conditions. Let's do it inside our first if conditions

  • Add following lines of code:
  • Prev Next
    Please ensure all required fields are filled in
    Step 6: Save your work

  • If you don't have a Trinket account, click the down arrow and then click Link. This will give you a link that you can save and come back to later.
  • If you have a Trinket account, you can click Remix to save your own copy of the trinket.
  • Prev Next
    Please ensure all required fields are filled in
    Step 7: Challenge

  • Finish existing story or create your own with different decision pathways
  • Make sure you have at least 2 levels of if/else conditions
  • Can't wait to see your story!

    Prev Next
    Please ensure all required fields are filled in
    Step 8: Final program code

    The final program code should look similar to this:

    Don't forget to save your work!

    Prev Next
    Step 9: Complete and Share

    Submit your final project

    In order to receive your completion certificate all projects should be submited before 6th April 2023



    Copy your Trinket Url

  • Click Share->Link
  • Copy the link to share your code
  • Paste link into the field
  • Prev