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]
2 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]2 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
Which of the following commands can be used to display socket information out to the terminal screen
Slav-nsk [51]
Linus ss

Explanation:

The ss (socket statistics) command provides a lot of information by displaying details on socket activity. One way to get started, although this may be a bit overwhelming, is to use the ss -h (help) command to get a listing of the command's numerous options. Another is to try some of the more useful commands and get an idea what each of them can tell you.

One very useful command is the ss -s command. This command will show you some overall stats by transport type. In this output, we see stats for RAW, UDP, TCP, INET and FRAG sockets.
6 0
1 year ago
Write a program that will add up the series of numbers: 99,98, 97...3.2.1. The program should print the running total as well as
Gekata [30.6K]

Answer:

result = 0

for i in range(99, 0, -1):

   result += i

   print(result)

Explanation:

7 0
3 years ago
ค้้้้้้้้้้้้้้้้้้้­้้้้้้้้้้้้้้้้้้้้­้้้้้้้้้้้้้้้้้้้้­้้้้้้้้้้้้้้้้้้้้­้้้้้้้้้้้้้้้ ฏ๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎­๎๎๎๎๎๎๎
Hitman42 [59]

Explanation:

ค้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้ ค้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้ค้้้้้้้้้้้้้้้้้้้­้้้้้้้้้้้้้้้้้้้้­้้้้้้้้้้้้้้้้้้้้­้้้้้้้้้้้้้้้้้้้้­้้้้้้้้้้้้้้้ ฏ๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎­๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎­๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎­๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎­๎๎๎๎๎๎๎๎ํํํํํํํํํํํํ­ํํํํํํํํํํํํํํํํํํํํ­ํํํํํํํํํํํํํํํํ ค้้้้้้้้้้้้้้้้้้้­้้้้้้้้้้้้้้้้้้้้­้้้้้้้้้้้้้้้้้้้้­้้้้้้้้้้้้้้้้้้้้­้้้้้้้้้้้้้้้ ฏ๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎

5 0
2 years ago
Activities provided for the satisfaction of others and consumed at the time of purchase<br> are…
Natasha2012 [34]
The answer is services
6 0
2 years ago
You can post a Facebook status update from your smartphone. True or false?
Nady [450]
True .................
3 0
2 years ago
Read 2 more answers
Other questions:
  • Aubrey didnt like to use graphics or images on her slides. She preferred to use only a title for her slides and bullet-poinged t
    14·2 answers
  • It is safe to use your bright headlights if there is a car ahead of you within 300 feet
    9·2 answers
  • A way to have cells in your spreadsheet change formats based on the value of the cells is called ________.
    8·1 answer
  • Which computer applications can Mr. Crowell use to make the classroom learning more stimulating and interesting? Mr. Crowell has
    9·2 answers
  • Which of these is a Microsoft certification CCIE PMP PRINCE2 MCSE
    11·1 answer
  • A web application starts when a client sends _______ to a server?
    13·1 answer
  • What mass of nh3 can be made from 35g of n2?
    14·1 answer
  • Which job role requires you to create user guides for computer products and services?
    11·1 answer
  • Which of the following is a property of TCP?
    8·1 answer
  • What code would you use to create the login button?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!