Objective: Practice Displaying Output with print Function, Comments, Variable, Reading Input from the Keyboard, format output, if statement, if-else statement, and loop structure Lab Description: 1. Pythagorean Triples A right triangle can have sides that are all integers. A set of three integer values for the sides of a right triangle is called a Pythagorean triple. These three sides must satisfy the relationship that the sum of the squares of two of the sides is equal to the square of the hypotenuse. Find all Pythagorean triples for side1, side2 and hypotenuse all no larger than 100 Use a triple-nested for loop that tries all possibilities. This is an example of “brute force computing.” You will leam in more advanced computer-science courses that there are many interesting problems for which there is no known algonthmic approach other than using sheer brute force. Test your program first with a lower number, such as 30. Write your program so it will not show or count duplicate, such as (3 4 5 and 43 5) It should appear once and count as one (Save your file as pythagorean.py) SAMPLE RUN for hypotenuse less than 30 hyp 5 13 sidel 3 5 6 7 8 side2 4 12 8 24 15 12 10 25 17 15 26 20 9 10 12 15 20 24 16 28 21 Total number of triples are 10 25 29 2. Factorial Calculator In mathematics, the notation n represents the factorial of the nonnegative integer n. The factorial of n is the product of all nonnegative integers from 1 to n. For example 71-7 6 54 3 2 1 5040 And 4! 4 3 2 1 24 Write a program that lets the user enter a non-negative integer then uses a Display the factorial. You need to implement your program by using both for loop and while loop “You will calculate the factorial twice. (Save your file as factorial.py) to calculate the factorial of that number SAMPLE RUN 1 Enter positive integer value to calculate the factorial: 10 Factorial value using for loop is equal Factorial value using while loop is equal 3628800 3628800 SAMPLE RUN 2 Enter positive integer value to calculate the factorial: 8 Factorial value using for loop is equal Factorial value using while loop is equal 40320 40320 Show transcribed image text Objective: Practice Displaying Output with print Function, Comments, Variable, Reading Input from the Keyboard, format output, if statement, if-else statement, and loop structure Lab Description: 1. Pythagorean Triples A right triangle can have sides that are all integers. A set of three integer values for the sides of a right triangle is called a Pythagorean triple. These three sides must satisfy the relationship that the sum of the squares of two of the sides is equal to the square of the hypotenuse. Find all Pythagorean triples for side1, side2 and hypotenuse all no larger than 100 Use a triple-nested for loop that tries all possibilities. This is an example of “brute force computing.” You will leam in more advanced computer-science courses that there are many interesting problems for which there is no known algonthmic approach other than using sheer brute force. Test your program first with a lower number, such as 30. Write your program so it will not show or count duplicate, such as (3 4 5 and 43 5) It should appear once and count as one (Save your file as pythagorean.py) SAMPLE RUN for hypotenuse less than 30 hyp 5 13 sidel 3 5 6 7 8 side2 4 12 8 24 15 12 10 25 17 15 26 20 9 10 12 15 20 24 16 28 21 Total number of triples are 10 25 29 2. Factorial Calculator In mathematics, the notation n represents the factorial of the nonnegative integer n. The factorial of n is the product of all nonnegative integers from 1 to n. For example 71-7 6 54 3 2 1 5040 And 4! 4 3 2 1 24 Write a program that lets the user enter a non-negative integer then uses a Display the factorial. You need to implement your program by using both for loop and while loop “You will calculate the factorial twice. (Save your file as factorial.py) to calculate the factorial of that number SAMPLE RUN 1 Enter positive integer value to calculate the factorial: 10 Factorial value using for loop is equal Factorial value using while loop is equal 3628800 3628800 SAMPLE RUN 2 Enter positive integer value to calculate the factorial: 8 Factorial value using for loop is equal Factorial value using while loop is equal 40320 40320

## Expert Answer

Answer to Objective: Practice Displaying Output with print Function, Comments, Variable, Reading Input from the Keyboard, format o…