Lesson 3 Summary
In Lesson 3 we have covered the following:
Nested If Statements
Let's put together everything that we learned and try a real world example.
Review the table below - it shows the freezing and boiling temperatures for a few common substances. It is often important in science to know at what temperature certain substances change states of matter. Let's create a program that will tell us whether our substance is freezing, boiling or neither.
Freezing Point (˚C)
Boiling Point (˚C)
1. Start by creating two variables, one to contain our substance and one to contain our temperature.
2. Create a series of If Statements to check which substance we're dealing with (you can select two for simplicity)
3. Then within each If Statement, we should check to see if the temperature is above the boiling point, lower than the freezing point, or neither
4. The result should be a printed statement that says: [Substance] is [a solid, a liquid, or a gas]
Hint: Your first two lines of code might look something like this below
1 substance = "mercury"
2 temperature = 16