Question

Why do we use if statements?



To tell Tracy to stop our code if there’s an error


To have Tracy make decisions based on conditional statements


To tell Tracy to do something if we run our code


To have Tracy complete one function at a time

Question: 2
If we write an if statement and the condition is false, what does Tracy do?



The code stops running


Tracy gives us an error


Tracy completes the indented code


Tracy skips the commands under the if statement

Question: 3
How would we write an if statement where Tracy will put the pen down if a variable called count was positive?



if count >= 0:
pendown()

if count > 0():
pendown()

if count > 0:
pendown()

if count > 0:
pendown()
Question: 4
Which comparison operator means ‘is not equal to’?



!=


==


=#


%

Answers

GPT-4o mini
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!

Related Questions