1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lyudmila [28]
3 years ago
8

The set of three integer values for the lengths of the sides of a right triangle is called a Pythagorean triple. These three sid

es must satisfy the relationship that the sum of the two sides is equal to the square of the hypotenuse. Find all integer Pythagorean triples for side1, side2, and the hypotenuse, all no larger than 500. Use a triple-nested for loop that tries all possibilities. This program is an example of brute force computing. You will learn in more advanced computer science courses that there are many interesting problems for which there is no algorithmic approach other than using sheer brute force. This program does not need any input from the user. Write at least one bool function that takes the 3 sides of the triangle and returns true or false based on if it is a right triangle or not.
Computers and Technology
1 answer:
Sloan [31]3 years ago
8 0

Answer:

In Python:

def  Pythagorean_triple(hyp,side1,side2):

   if hyp**2 == side1**2 + side2*2:

       return True

   else:

       return False

               

print("Hypotenuse\tSide 1\t Side 2\t Return Value")

for i in range(1,501):

   for j in range(1,501):

       for k in range(1,501):

           print(str(i)+"\t"+str(j)+"\t"+str(k)+"\t"+str(Pythagorean_triple(i,j,k)))

Explanation:

This defines the function

def  Pythagorean_triple(hyp,side1,side2):

This checks for pythagorean triple

   if hyp**2 == side1**2 + side2*2:

Returns True, if true

       return True

   else:

Returns False, if otherwise

       return False

               

The main method begins

This prints the header

print("Hypotenuse\tSide 1\t Side 2\t Return Value")

The following is a triple-nested loop [Each of the loop is from 1 to 500]

for i in range(1,501): -->The hypotenuse

   for j in range(1,501): -->Side 1

       for k in range(1,501):-->Side 2

This calls the function and prints the required output i.e. the sides of the triangle and True or False

           print(str(i)+"\t"+str(j)+"\t"+str(k)+"\t"+str(Pythagorean_triple(i,j,k)))

You might be interested in
The following program segment is designed to compute the product of two nonnegative integers X and Y by accumulating the sum of
mote1985 [20]

The program is correct: at the beginning, product = 0. Then, we start summing Y to that variable, and we sum Y exactly X times, because with each iteration we increase Count by 1, and check if Count=X so that we can exit the loop.

5 0
3 years ago
Each server on a network that needs to act as a web server needs an application layer software package called a (n) ____________
vovangra [49]
I believe the answer is in the question, web server. although I may be wrong
3 0
3 years ago
Read each description below, and then choose the correct term that matches the description from the drop-down menus.
lilavasa [31]

hyperlink

browser

website

webpage

5 0
3 years ago
Read 2 more answers
Puung.<br>f. Differentiate between second and third Generation Computer<br>IG ANSWER QUESTIONS​
Papessa [141]

Answer:

Second generation computers were based on transistors, essentially the same as first generation computers, but with the transistors replacing the vacuum tubes / thermionic valves.

Third generation computers used printed circuit boards to replace much of the wiring between the transistors. This had the advantage that components could be mass produced, reducing the number of errors because of incorrect wiring and making the component boards replacable.

6 0
3 years ago
What is computer? what are the major function of computer​
Naya [18.7K]

Answer:

A computer is a machine that can be programmed to carry out sequences of arithmetic or logical operations automatically. Modern computers can perform generic sets of operations known as programs. These programs enable computers to perform a wide range of tasks.Computers are used to control large and small machines which in the past were controlled by humans. Most people have used a personal computer in their home or at work. They are used for things such as calculation, listening to music, reading an article, writing etc.

Computers are used at homes for several purposes like online bill payment, watching movies or shows at home, home tutoring, social media access, playing games, internet access, etc. ...

Medical Field. ...

Entertainment. ...

Industry. ...

Education. ...

Government. ...

Banking. ...

Business.

BRAINLIEST PLEASE

7 0
2 years ago
Other questions:
  • Consider a file system that uses inodes to represent files. Disk blocks are 2KB in size and a pointer to a disk block requires 4
    13·1 answer
  • 14. Emelia is very concerned about safety and has conducted a study to determine how many bike helmets were replaced at each loc
    13·2 answers
  • Are the actions legal or illegal?
    13·1 answer
  • What are pixels? A. Objects that are part of a particle system B. Tiny colored dots that make up images and text on a computer s
    9·1 answer
  • Which of the following is the result of a query?
    9·1 answer
  • From Blown to Bits why is it important to know what children are doing on the Web Tonight?
    7·1 answer
  • Which of the following are the most important reasons people in the 1920s were so interested in seeing lifelike stories in audio
    6·1 answer
  • What was the strategy the company adopted for ERP implementation?
    12·1 answer
  • See the file attached!​
    11·1 answer
  • The scope of a temporary table is limited to what?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!