Worksheet 8.1. Conditional Algorithms
Worksheet 8.1. Conditional Algorithms
WORKSHEET 8.2
WORKSHEET 8.3
Reading text
Conditionals and how they are used in Algorithms
IF-THEN-ELSE CONDITIONALS
One of the first things that programmers learn is how to use IF-THEN-ELSE conditionals.
The basic idea is: IF some condition is true THEN do this, ELSE do that.
For example, imagine you have to connect to an online class, and you have two devices: a
computer and a cellphone. You prefer to use the computer, but your computer is
sometimes blocked. So the CONDIIONAL for your situation is: IF the computer works well
THEN connect with the computer, ELSE connect with the cellphone.
Sometimes, you can have complex conditional statements when you have more than two
choices. As humans, make decisions with several options in a very different way than
computers. We have the ability to select one item out of a group of choices, but a
computer program has to make binary decisions, meaning that it can only select between
two things at a time.
Imagine you want to go to a restaurant. You top-favorite is a pizza restaurant, your second
favorite is a hot-dog restaurant, and your third favorite is a burger restaurant. There are
no more restaurants in your town. Your CONDITIONAL for this situation is:
AND/OR CONDITIONALS
If you want to check multiple conditions, you can use AND/OR statements. Using AND will
cause the program to do something if both conditions are true. Using an OR statement
will do something if one of the conditions is true.
WORKSHEET 8.4
EVALUATION
Write a CONDITIONAL for each situation using the programming language you learned
today: IF, THEN, ELSE, AND, OR.
1. Your flight is at 5 pm. You have to be at the airport at least 1 hour before. You get to
the airport on time, you take the flight. You don´t get to the airport on time, you buy a
new ticket.
If You get to the airport 1 hour before or on time, then you take the flight. else, you
buy a new ticket.
2. You want to withdraw 10 000 pesos from the ATM. You have 10 000 or more in your
account; you get the money. You have less than 10 000 in your account, you get
nothing.
if you have 10000 or more in your account then you can withdraw 10.000 else you get
nothing
3. You want to take salsa classes. Salsa classes start at 3 pm. Your university classes finish
before 3 pm, you take salsa classes. Your university classes finish after 3 pm, you don´t
take salsa classes.
if Salsa classes start at 3 pm and Your university classes finish before 3 pm then you
take salsa classes else you don´t take salsa classes.
WORKSHEET 8.5
SELF –EVALUATION
1. La estrategia de Previewing & Predicting me ayudó a tener una idea de qué se trata el
texto.
Si No Tal vez