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
You are on vacation and want to see where all the restaurants and trendy shops are in relation to your hotel. You remember there
klasskru [66]

Answer:

The right answer is GPS.

Explanation:

According to the scenario, the most appropriate answer is GPS service because nowadays there are many application i.e google maps,etc. which uses the location service and on the basis of the user's GPS coordinates gives the appropriate results.

GPS stands for the term global positioning system which is used to determine the geolocation of any person on earth by using navigation satellites.

4 0
4 years ago
2.3 Code Practice: Question 3
Tpy6a [65]

Answer:

Code in C++

Explanation:

C++ Code

#include<iostream> //for input and output  

using namespace std;  

int main()  

{  

  int hour;

  int minute;

  cout<<"Enter the hour:";

  cin>> hour;

  cout<<"Enter the minute:";

  cin>>minute;

  minute = minute+15;

  if(minute>=60){

   hour++;

   minute=minute-60;

  }

  if(hour>=24){

   hour=0;

  }

  cout<<"Hours: "<<hour<<endl;

  cout<<"Minutes:"<<minute;

  return 0;  

}

Code Explanation

First we need to declare two int variables to hold hour and minute values input from user.

Check if by adding 15 minutes into minute entered by user is greater then or equal to 60 then increment into hour and subtract 60 from minute.

Another check is that if user enters more then 24 hour or by making increment into hour, the hour values i greater then or equal to 24 then we need to change the hour to 0.

Result

Case 1:

Enter the hour:8

Enter the minute:15

Hours: 8

Minutes:30

Case 2:

Enter the hour:9

Enter the minute:46

Hours: 10

Minutes:1

8 0
3 years ago
This algorithm requires you to find the perimeter of 12 different squares.
k0ka [10]

Answer:

BEGIN

SET count = 1

WHILE count <= 12 THEN

     INPUT length

     perimeter = length * length

     PRINT perimeter

END WHILE

END

Explanation:

You can also set count to 0 and in while loop use count < 12 to loop just 12 times just as above

4 0
3 years ago
6. How might you go about securing an internship or job on LinkedIn?
Greeley [361]
Seems nice I mean yeah its be fine
4 0
4 years ago
Read 2 more answers
Which type of navigation involves multiple frames that are linked to a number of other frames?
Reptile [31]
The answer to the question is linear
6 0
3 years ago
Read 2 more answers
Other questions:
  • Electronic files created on a computer using programs such as word software are considered to be
    15·1 answer
  • Which type of password would be considered secure
    13·2 answers
  • Assume that we have an application with a total of 500,000 instructions where 20% of them are the load/store instructions with a
    14·1 answer
  • A canister is released from a helicopter 500m above the ground. The canister is designed to withstand an impact speed of up to 1
    15·1 answer
  • If you type too much text on a PowerPoint slide, the additional text is added to a second slide.
    9·1 answer
  • you crossed two heterozygous red flowers (dominant color), what are your chances to have a white flower
    11·1 answer
  • Guys help—How do you start a conversation with someone on brainly if that is a thing?
    6·1 answer
  • A website for a certain political party or candidate is likely to have unbiased
    6·1 answer
  • The entities on which data are collected are _____.
    10·2 answers
  • A _____ consists of horizontal bars, connected with arrows that indicate task dependencies.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!