Unit 6 Flashcards
In this unit, you will learn how to use conditional statements which are commands for handling decision points in your program. By the end of this unit, you will be able to: Use one or more conditional statements to control a program’s flow. Evaluate basic Boolean logic.
What does conditional statement mean?
“Conditional statements” help a computer answer “yes” or “no” questions.
What are the things that an if statement comprises of?
An if statement has the keyword (if), a condition, and a colon. You will have a block of code that’s indented so that the computer knows that it belongs to the if statement.
How do we get out of our block of code for functions and if statement?
We have to press enter twice to get out of our block of code.
The if is highlighted in which colour for if statements?
In red
The condition part of the if statement is highlighted in what colour?
Blue
What colour is the colon highlighted in for the if statement?
Orange
For the if statement, what happens if the value does not fit into the condition?
Nothing will print out.
The condition equals to is represented by which symbol?
==
When is one equal sign used?
When we want to assign a value to a variable.
What is the definition of this symbol != ?
Not equal to
What is the definition of this symbol < ?
Less than
What is the definition of this symbol > ?
Greater than
What is the definition of this symbol <= ?
Less than or equal to
What is the definition of this symbol >= ?
Greater than or equal to
If I have at least $50, then I can buy the new video game.
if my_money ___49:
Print(“I can buy the new video game”)
What symbol should be filled in the blank?
>
To do something different when the answer is “no” for if statements, we use _____.
the if-then-else statement
What is the difference between the if part and the else part?
If part contains the conditions while the else part does not.
How do you enter the else part?
To enter the else part, you will need to press backspace or delete to remove the white space and start a new block.
What must you take note when you are coding your if and else statement?
Do not press enter
This is a good time to start using a separate document for writing your code instead of typing it into IDLE.