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
Lena [83]
3 years ago
14

Write a function is_rightangled which, given the length of three sides of a triangle, will determine whether the triangle is rig

ht-angled. Assume that the third argument to the function is always the longest side. It will return True if the triangle is right-angled, or False otherwise. Hint: floating point arithmetic is not always exactly accurate, so it is not safe to test floating point numbers for equality. If a good programmer wants to know whether x is equal or close enough to y, they would probably code it up as
Computers and Technology
1 answer:
Olenka [21]3 years ago
5 0

Answer:

Written in Python:

def is_rightangled(a,b,c):

     if abs(c**2 - (a**2 + b**2) < 0.001):

           return "True"

     else:

           return "False"

       

a = float(input("Side 1: "))

b = float(input("Side 2: "))

c = float(input("Side 3: "))

print(is_rightangled(a,b,c))

Explanation:

The function is defined here

def is_rightangled(a,b,c):

The following if statement implements Pythagoras theorem c^2 = a^2 + b^2 by checking if the left hand side is approximately equal to the right hand side

<em>      if abs(c**2 - (a**2 + b**2) < 0.001):</em>

<em>            return "True"</em>

<em>      else:</em>

<em>            return "False"</em>

If the specified condition is met, the if function returns true; Otherwise, it returns false.

The main function starts here

The next three line prompts user for the sides of the triangle

<em>a = float(input("Side 1: "))</em>

<em>b = float(input("Side 2: "))</em>

<em>c = float(input("Side 3: "))</em>

The next line calls the defined function

print(is_rightangled(a,b,c))

You might be interested in
The laser in a compact disc (cd) player uses light with a wavelength of 715 nm. what is the frequency of this light?
oee [108]
In order to get the frequency of this light you have to d<span>ivide the speed of light by the wavelength. 
The formula: </span>F = c / w<span>
Set the values in the appropriate form:</span>740nm = 7.40e-9m


Solution: 
3.00e8m/s : 7.40e-9m &#10;&#10;&#10;F = 6.38e16Hz
The answer:  = 63.8PHz
6 0
3 years ago
Variable X is a *
xxTIMURxx [149]

Answer:

Variable X is a local variable.

Explanation:

X exists only inside the sub.

6 0
3 years ago
Write a program that uses while loops to perform the following steps:
Vladimir79 [104]

Answer:

Explanation:

//Include the required header files.

#include<iostream>

using namespace std;

//Define the main function.

int main()

{

//Define the variables.

int i, sum = 0, sqSum = 0, firstNum = 1, secondNum = 0;

char ch;

//Check for valid input.

while (!(firstNum < secondNum))

{

cout << "Enter starting number: ";

cin >> firstNum;

cout<<"Enter ending number(must be > startingNumber): ";

cin >> secondNum;

}

//Store first number in i

i = firstNum;

//Dispaly the number.

cout << "The odd numbers between " << firstNum

<< " and " << secondNum << " are:\n";

//Iterate between first and second number.

while (i <= secondNum)

{

//Check for even numbers.

//Store the sum

if (i % 2 == 0)

sum = sum + i;

//Print the odd numbers

//Evaluate the square of sum of odd number.

else

{

cout << i << " ";

sqSum = sqSum + i * i;

}

//Increase the value of i.

i++;

}

//Dispaly the sum of even numbers.

cout << "\n\nThe sum of the even numbers is:"

<< sum << endl << endl;

//Dispaly the sum of square of odd number.

cout << "The sum of squares the odd numbers is:"

<< sqSum << endl;

//Set i to 1.

i = 1;

//Dispaly the message.

cout << "\nNumber Square\n";

//Iterate and print number between 1 andd 10

//along with the sum.

while (i <= 10)

{

cout << " " << i << "\t " << i * i << endl;

i++;

}

//USe for visual studio.

system("pause");

//Return the value 0.

return 0;

}

Explanation:

The program code will perform the function listed below using loop.

Prompt the user to input two integers: firstNum and secondNum (firstNum must be less than secondNum). Output all odd numbers between firstNum and secondNum. Output the sum of all even numbers between firstNum and secondNum. Output the numbers and their squares between 1 and 10. Separate the numbers using any amount of spaces. Output the sum of the square of the odd numbers between firstNum and secondNum. Output all uppercase letters.

Hope this helps!

3 0
3 years ago
What was the first carbonated drink to be introduced in the US?
adelina 88 [10]
Taco bell...........................................................................................................................................................................

6 0
3 years ago
The Central Processing Unit carries out the commands from programs running in...
prohojiy [21]

Answer:

the main memory to be precise

5 0
3 years ago
Other questions:
  • Write a static method named listcountriesoforigin, to be added to the bowl class, which is passed an array of bowl objects, and
    13·1 answer
  • Computer security:
    15·1 answer
  • In what way can parents use technology in their children’s development?
    11·2 answers
  • Routing in Practice (30 points). For each of the statements below, decide which it is true or false, and briefly justify your an
    13·1 answer
  • is a shell program in Windows that holds individual utilities called snap-ins, designed for administration and troubleshooting.
    11·1 answer
  • Using truth table, prove that:<br><br> (A + B). C = (A . C)+ (B .C) ?
    7·1 answer
  • Software that allows users to use and adapt it for any purpose, often allowing the public to participate in further development
    7·2 answers
  • Using complete sentences post a detailed response to the following.
    15·1 answer
  • Electrical data suitable for transmission is called a(n)
    5·1 answer
  • Which remote access role service allows publishingweb-based applications for use by clients outside thenetwork?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!