Opening the book…
In this chapter, we’ll use functions and a new feature—conditional statements—to search for Pythagorean triples. A Pythagorean triple is a set of integers, like 3, 4, and 5, that are the lengths of the sides of a right triangle. Mathematically, it’s a set of integers \(a\), \(b\), and \(c\) such that \(a^2 + b^2 = c^2\). This example will also demonstrate the incremental development process we talked about in Chapter 3.
- 6.2: if Statement
- Use of the basic "it" logic block
- 6.3: if, else, elseif
- if, else, elseif, end examples
- 6.4: Incremental Development
- Outlines the steps for creating and testing a program.
- 6.5: Logical Functions
- Logical functions and operations. This is a modified version Of Allen Downey's section. It has been modified to use parentheses to remove ambiguity in the logic.
- 6.6: Nested for Loops
- nested loops
- 6.7: Putting It Together
- Now instead of displaying all of the triples, we’ll add an if statement and display only Pythagorean triples
- 6.8: Encapsulation and Generalization
- encapsulation: wrapping the code in a function
- 6.9: Adding a continue Statement
- continue short circuits a for loop
- 6.10: Chapter Review
- Chapter review
- 6.11: Chapter 6 if-logic videos English and Espanol
- Chapter 6 videos English and Espanol
This page titled 6: Conditionals Part 1 was last modified on Wed, 13 Jul 2022 23:51:56 GMT and is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Carey Smith via source content that was edited to the style and standards of the LibreTexts platform.
The book could not be loaded just now.