Computer Science, asked by loveraja3356, 9 months ago

Write a python function to check whether three given numbers can form the sides of a triangle.Hint : three numbers can be the sides of a triangle if none of the numbers are greater than or equal to the sum of the other two numbers.

Answers

Answered by Swetha03K
15

a=int(input("Enter 1st side of triangle:"))

b=int(input("Enter 2nd side of triangle:"))

c=int(input("Enter 3rd side of triangle:"))

if a+b>c:

     if b+c>a:

            if a+c>b:

                  print("The given measurements:",a,b,c,"forms a triangle")

else:

    print("The given measurements:",a,b,c,"does not form a triangle")

Answered by AskewTronics
5

The python program for the above question is stated below

Explanation:

a=int(input()) # take the first input and convert it into integer datatype

b=int(input()) # take the second input and convert it into integer datatype

c=int(input()) # take the third input and convert it into integer datatype

# The above inputs are the size of the triangle

if(((a+b)<=c)or((b+c)<=a)or((c+a)<=b)): // check the condition if true then the sides are not the part of the triangle.

 print("It can not form the triangle")

else:

  print("It can form the triangle")

Output:

  • If the user gives the inputs 3,4,5 then it prints "It can form the triangle".
  • If the user gives the input 1,2,3 then it prints "It can not form the triangle".

Here the input() function is used to take the input as a string and int() function converts it into an integer. The if statement checks the three conditions with or in which or operator states true if any of the three conditions is true.

Learn More:

  • Python: https://brainly.in/question/11818321
  • Python program : https://brainly.in/question/5558161
Similar questions