Fall 2024 - P1
Big Idea 3 | .1 | .2 | .3 | .4 | .5 | .6 | .7 | .8 | .10 |
3.7 Mastering Nested Conditionals - Hacks
A supplemental blog on nested conditionals. Learn how nested conditionals allow for more complex decision-making by enabling multiple levels of conditions than regular conditionals.
Quiz!
Homework (Hacks)
- Write pseudocode to determine if a student passes a class based on their exam scores and attendance using nested conditionals.
- Write a python segment to decide the shipping cost based on the weight of a package and the delivery speed chosen (standard or express) using nested conditionals.
- Write a python segment to have different ticket prices for different ages, with a discount for students
Challenge Hack
Write a program that helps a user determine the type of triangle based on the lengths of its sides. The program should prompt the user to input three positive numbers representing the sides of a triangle. Your task is to use nested conditionals to check the following:
First, verify if the three sides can form a valid triangle (hint: the sum of any two sides must be greater than the third side). If it’s a valid triangle, further classify it into one of the following categories:
- Equilateral Triangle: All sides are equal.
- Isosceles Triangle: Two sides are equal.
- Scalene Triangle: No sides are equal. If the sides do not form a valid triangle, the program should display an appropriate message.
Requirements: Use nested conditionals to handle the logic for checking the type of triangle. Include input validation to ensure the user enters positive numbers.
Submission
Submit your assignment HERE
This is how we grade:
- 1.0 = above and beyond - mortensen level code
- 0.95 = challenge hack completed + all other hacks are well done
- 0.9 = all hacks completed, but challenge is not attempted/not good
- 0.85 = hacks are not well made / incomplete
- 0.75 = some hacks are missing
- 0.5 = not submitted
Need Help?
Here’s some solutions.