Question

In: Computer Science

Write a design algorithm and a python program which asks the user for the length of...

Write a design algorithm and a python program which asks the user for the length of the three sides of two triangles. It should compute the perimeter of the two triangles and display it. It should also display which triangle has the greater perimeter. If both have the same perimeter it should display that the perimeters are the same. Formula: Perimeter of triangleA = (side1A + side2A +side3A) See the 2 sample outputs. Enter side1 of TriangleA: 2 Enter side2 of TriangleA: 3 Enter side3 of TriangleA: 4 Enter side1 of TriangleB: 1 Enter side2 of TriangleB: 2 Enter side3 of TriangleB: 2 perimeter of TriangleA: 9.00 perimeter of of TriangleB: 5.00 perimeter of TriangleA is greater than perimeter of TriangleB. or Enter side1 of TriangleA: 2 Enter side2 of TriangleA: 1 Enter side3 of TriangleA: 3 Enter side1 of TriangleB: 1 Enter side2 of TriangleB: 2 Enter side3 of TriangleB: 3 perimeter of TriangleA: 6.00 perimeter of of TriangleB: 6.00 perimeter of TriangleA is equal to perimeter of TriangleB. PYTHON!!

Solutions

Expert Solution

Aside1 = float(input("Enter side1 of TriangleA:"))
Aside2 = float(input("Enter side2 of TriangleA:"))
Aside3 = float(input("Enter side3 of TriangleA:"))
Bside1 = float(input("Enter side1 of TriangleB:"))
Bside2 = float(input("Enter side2 of TriangleB:"))
Bside3 = float(input("Enter side3 of TriangleB:"))
Aperimeter = Aside1+Aside2+Aside3;
Bperimeter = Bside1 + Bside2+Bside3;
# .2f means how many digit after decimal .
print("perimeter of TriangleA:%.2f" %Aperimeter)
print("perimeter of TriangleB:%.2f" %Bperimeter)
if Aperimeter==Bperimeter:
    print("perimeter of TriangleA is equal to perimeter of TriangleB.");
elif Aperimeter>Bperimeter:
    print("perimeter of TriangleA is greater than perimeter of TriangleB.");
else:
    print("perimeter of TriangleA is less than perimeter of TriangleB.");
   

In the code there are variables of sides of trangle A and B which is taking float values from the use and computing the result according to given in the quesiton.


Related Solutions

Python English algorithm explanation Write a program that asks the user for the name of a...
Python English algorithm explanation Write a program that asks the user for the name of a file in the current directory. Then, open the file and process the content of the file. 1)If the file contains words that appear more than once, print “We found duplicates.” 2)If the file does not contain duplicate words, print “There are no duplicates.”
Python English algorithm explanation Write a program that asks the user for the name of a...
Python English algorithm explanation Write a program that asks the user for the name of a file in the current directory. Then, open the file and process the content of the file. 1)If the file contains words that appear more than once, print “We found duplicates.” 2)If the file does not contain duplicate words, print “There are no duplicates.”
Please write in python Use modular design to write a program that asks the user to...
Please write in python Use modular design to write a program that asks the user to enter his or her weight and the name of a planet. The program then outputs how much the user would weigh on that planet. The following table gives the factor by which the weight must be multiplied for each planet. PLANET CONVERSION FACTOR Mercury 0.4155 Venus 0.8975 Earth 1.0000 Moon 0.1660 Mars 0.3507 Jupiter 2.5374 Saturn 1.0677 Uranus 0.8947 Neptune 1.1794 Pluto 0.0899 The...
Python: Write a program that asks the user for the name of a file. The program...
Python: Write a program that asks the user for the name of a file. The program should display the contents of the file line by line.
Write a python program which asks the user to enter a positive number that is greater...
Write a python program which asks the user to enter a positive number that is greater than 30 called, “num2” and then does the following: o 1) Print all numbers between 1 and “num2” that are divisible by 2 and 3. o 2) Print all numbers between 1 and “num2” that are either divisible by 6 or 7. o 3) Print all numbers between 1 and “num3” that is not divisible by 5
In Python write a program that asks the user to enter the monthly costs for the...
In Python write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, oil, tires, and maintenance the program should then display the total monthly cost of these expenses, and the total annual cost of these expenses. your program MUST have BOTH a main function AND a function named calcExpenses to calculate the expenses. DO NOT display the expenses inside of the calcExpenses function!!...
Write a program in PYTHON, using a while loop, that asks the user to enter the...
Write a program in PYTHON, using a while loop, that asks the user to enter the amount that they have budgeted for the month. The program should then prompt the user to enter their expenses for the month. The program should keep a running total. Once the user has finished entering their expenses the program should then display if the user is over or under budget. The output should display the monthly budget, the total expenses and whether the user...
Write a complete Python program that asks the user for a line of text (not just...
Write a complete Python program that asks the user for a line of text (not just a single word), and then tells the user whether the string is a palindrome (same forward and backward) if you ignore case and non-alphabetic characters. The following methods and functions may be useful: str.upper(), str.isalpha() -> bool, reversed(str) -> sequence, str.find(str) -> int, str.replace(str, str), str.center(int). Unless otherwise specified, they all return a string.
CODE IN PYTHON 1. Write a program that asks the user for the number of slices...
CODE IN PYTHON 1. Write a program that asks the user for the number of slices of pizza they want to order and displays the total number of dollar bills they owe given pizza costs 3 dollars a slice.  Note: You may print the value an integer value. 2. Assume that y, a and b have already been defined, display the value of x: x =   ya+b    3. The variable start_tees refers to the number of UD T-shirts at the start...
(IN PYTHON) Write a program that asks the user repeatedly to enter a student's score or...
(IN PYTHON) Write a program that asks the user repeatedly to enter a student's score or enter -1 to stop. When finished entering all the scores, the program should display the number of scores entered, the sum of the scores, the mean, the lowest and the highest score. (IN PYTHON)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT