Page 148 - CodePilot V5.0 C8
P. 148
Program 1 A program to display the sum of two numbers using Python functions.
Program1.py Output
File Edit Format Run Options Window Help The sum is: 12
def add(first_number, second_number):
return first_number + second_number
result = add(5, 7)
print("The sum is:", result)
Program A program to check whether the side of the triangle given by the user forms a
2 scalene, isosceles or equilateral triangle.
Program2.py
File Edit Format Run Options Window Help
#Program to check if a triangle is Equilateral, Isosceles or Scalene
def triangle(A,B,C):
if (A == B == C):
print('Equilateral triangle')
elif ((A == B) or (B == C) or (A == C)):
print('Isosceles triangle')
else:
print('Scalene triangle')
print('Input the sides of the triangle: ')
A1 = float(input('A: '))
B1 = float(input('B: '))
C1 = float(input('C: '))
triangle(A1,B1,C1)
On running the above program, you will get the following output:
Output
Input the sides of the triangle:
A: 2.3
B: 5.3
C: 9.5
Scalene triangle
146
CodePilot (V5.0)-VIII

