File size: 1,684 Bytes
ce5cd7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "enter side 1\n",
      "1\n",
      "enter side 2\n",
      "2\n",
      "enter side 3\n",
      "3\n",
      "yes, it can form a degenerated triangle\n"
     ]
    }
   ],
   "source": [
    "# ---------------------------------------------------------------\n",
    "# python best courses https://courses.tanpham.org/\n",
    "# ---------------------------------------------------------------\n",
    "# Write a Python program to check a triangle is valid or not\n",
    "\n",
    "def triangle_check(l1,l2,l3):\n",
    "    if (l1>l2+l3) or (l2>l1+l3) or (l3>l1+l2):\n",
    "        print('No, the lengths wont form a triangle')\n",
    "    elif (l1==l2+l3) or (l2==l1+l3) or (l3==l1+l2):\n",
    "        print('yes, it can form a degenerated triangle')\n",
    "    else:\n",
    "        print('Yes, a triangle can be formed out of it')\n",
    "\n",
    "length1 = int(input('enter side 1\\n'))\n",
    "length2 = int(input('enter side 2\\n'))\n",
    "length3 = int(input('enter side 3\\n'))\n",
    "\n",
    "triangle_check(length1,length2,length3)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}