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
Other drivers and pedestrians expect you to be sober and attentive, so you are responsible for ___________.
marysya [2.9K]
Um A is the only logical answer
5 0
3 years ago
Read 2 more answers
Please i need your help
motikmotik
Hello!

The answer would be:

C. non-linear navigation.

Explanation: Non-linear navigation lets a user navigate through material without them having to follow a strict order.

I hope that this helps you!
3 0
2 years ago
What are two characteristics of switches? (Choose two.) * 1 point A. Switches identify the intended destination of the data that
tigry1 [53]

Answer:

A. Switches identify the intended destination of the data that they receive. And C. Switches are capable of sending and receiving data at the same time

Explanation:

Switches can be used as inputs (Analog), or outputs (digital). These inputs and outputs are signals that the switches send or receive- Or at least as push button switches... But the same applies to network switches.

Hope this helps! Have a great day!

7 0
3 years ago
Can you tell me what to put in these line please!
Harman [31]

Answer:

I know nothing about this

3 0
3 years ago
Why are the central processing unit (cpu) and motherboard considered the brain and heart of a computer? do you think these are g
kupik [55]
I think that they are sufficient analogies. But, the heart allows the organs to remain healthy and active. The motherboard does not fully fit that classification. The motherboard would be more like the spinal cord or nerves.
8 0
3 years ago
Other questions:
  • Which information technology job has the lowest predicted 10-year growth? computer programmer software developer computer suppor
    13·1 answer
  • which of the following is not an operating system? A. leopard B. linux C. firefox D. windows
    11·2 answers
  • How is it possible to find encyclopedias and reference texts on the internet
    11·2 answers
  • An information system report is an example of...
    13·1 answer
  • Judy forgot where she saved a certain file on her computer. Therefore, she searches for all files with a .jpg file extension. Wh
    7·2 answers
  • Suppose an initially empty stack S has performed a total of 15 push operations, 12 top operations, and 13 pop operations ( 3 of
    5·1 answer
  • There are types of templates​
    5·1 answer
  • Use MPLAB to write an asemply program to multipy two numbers (11111001) and (11111001). Then save the product in file reisters 0
    8·1 answer
  • Most project files will contain:
    9·1 answer
  • Raman will perform in pune tomorrow(simple past)​
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!