how to write a function in python 3 that reads a txt file which includes three number (each line has one number) assuming these numbers are the side lengths of a triangle. The function checks the validity of the triangle and prints whether the triangle is valid or not. If is is valid, the result should also indicate the type of triangle.
Open a file in read mode
Read a line from file and store the number in variable a
Read a line from file and store the number in variable b
Read a line from file and store the number in variable c
if (a + b > c) and (a + c > b) and (b + c > a)
then print "Triangle is valid"
if (a==b) and (b==c)
then print "Equilateral Triangle"
else if (a!=b) and (b!=c) and (a!=c)
then print "Scalene Triangle"
print "Isoceles Triangle"
else print "Triangle is NOT valid"
inputFile = open("numbers.txt", "r")
if (a + b > c) and (a + c > b) and (b + c > a) :
print("Triangle is valid")
if (a==b) and (b==c):
elif (a!=b) and (b!=c) and (a!=c):
print("Triangle is NOT valid")
File name: numbers.txt
Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*See Solution
Q: How can I create a decoder and a multiplexer in a circuit? The decoder has a 3 bit select input and ...
A: A decoder is a circuit which has n inputs and 2n outputs. So if there are 3 inputs to a decoder it w...
Q: 11.9: Speakers' Bureau Write a program that keeps track of a speaker's bureau. The program should us...
A: We use C++ language and validate input for fees so that only integers are accepted. A struct data st...
Q: JAVA PROGRAM NEED TO BE SUBMITTED TOMORROW you operate 3 hot dog stands distributed throughout tow...
A: The following override methods are created along with @Override annotation:equalsfinalizetoStringThe...
Q: A pet shop wants to give a discount to its clients if they buy one or more pets and at least four ot...
A: The program has two main parts – the part which receives the input and the part which validates the ...
Q: l Sprint LTE 09:28 9 morgan.blackboard.com Bb Courses Course Material Assignment 3 1. Use the variab...
A: Hey, since there are multiple questions posted, I answer first three questions. If you want any spec...
Q: Write a PL/SQL block to accept a date from the user and print the day and the date as shown below. U...
A: Solution:Given data,The PL/SQL code read the user input of date and display the day and the date in ...
Q: What are the errors in the following code?
A: Given below are the errors found in the code send by you along with an error free code.
Q: (Method Overloading) Given the following methods, write down the printed output of themethod calls: ...
A: Answer with Explanation:“doSomething(5)” contains an argument integer “5” and it is called to the “d...
Q: Normalization Repair the ER Diagrams into at least 1nf, 2nf and 3nf Give explanations...
A: Hi due to lack of adequate information we are unable to provide any solution. Please provide us more...