Let's go through your questions one by one:
Question 1: Why do we use if statements?
The correct answer is:
- To have Tracy make decisions based on conditional statements.
If statements are used in programming to execute certain parts of code based on whether a condition is true or false.
Question 2: If we write an if statement and the condition is false, what does Tracy do?
The correct answer is:
- Tracy skips the commands under the if statement.
If the condition in an if statement evaluates to false, the code block within that if statement will not be executed.
Question 3: How would we write an if statement where Tracy will put the pen down if a variable called count was positive?
The correct answer is:
- if count > 0: pendown()
This is the correct syntax for an if statement checking if the count
variable is positive and executing the indented command if so.
Question 4: Which comparison operator means ‘is not equal to’?
The correct answer is:
- !=
In programming, !=
is used to check if two values are not equal to each other.
Feel free to ask if you have more questions!