Experiment : 1
AIM: Write a program to calculate are of a
triangle using heron's formula.
CODE:
a=float(input("Enter the value of first side : "))
b=float(input("Enter the value of second side : "))
c=float(input("Enter the value of third side : "))
print(a,b,c)
s=(a+b+c)/2
A=float((s*(s-a)*(s-b)*(s-c))**0.5)
print("The area of the given triangle is "+str(A))
OUTPUT:
Enter the value of first side : 3
Enter the value of second side : 4
Enter the value of third side : 5
The area of the given triangle is 6.00
EXPERIMENT : 2
AIM: Write a program to perform addition , substraction ,
mulpiplication,division,integer division and modular division
on two integer numbers.
CODE:
A=int(input("Enter the first digit : "))
B=int(input("Enter the second digit : "))
a=A+B
s=A-B
m=A*B
d=float(A/B)
id=int(A/B)
md=A%B
print("The sum of the given two digits is "+str(a))
print("The substraction of the given two digits is "+str(s))
print("The multiplication of the given two digits is "+str(m))
print("The division of the given two digits is {:.2f}".format(d))
print("The integer division of the given two digits is "+str(id))
print("The modular divion of the given two digits is "+str(md))
OUTPUT:
Enter the first digit : 534
Enter the second digit : 32
The sum of the given two digits is 566
The substraction of the given two digits is 502
The multiplication of the given two digits is 17088
The division of the given two digits is 16.69
The integer division of the given two digits is 16
The modular divion of the given two digits is 22
EXPERIMENT : 3
AIM : Write a program to convert a floating point number to
corresponding integer.
CODE :
b=float(input("Enter a number:"))
print("The integer value of "+str(b)+"="+str(int(b)))
OUTPUT:
Enter a number:17.87
The integer value of 17.87=17
EXPERIMENT : 4
AIM : Write a program to convert a integer number to
corresponding floating point number.
CODE:
n=int (input("Enter a number:"))
print("The floating number is : "+ str(float(n)))
OUTPUT:
Enter a number:12
The floating number is : 12.0
EXPERIMENT : 5
AIM: Write a program that demonstrates the relationship
operator
CODE:
a=int(input("Input 1st number :"))
b=int(input("Input 2nd number :"))
print("a==b",a==b)
print("a!=b",a!=b)
print("a<b",a<b)
print("a<=b",a<=b)
print("a>b",a>b)
print("a>=b",a>=b)
OUTPUT:
Input 1st number :51
Input 2nd number :98
a==b False
a!=b True
a<b True
a<=b True
a>b False
a>=b False
EXPERIMENT : 6
AIM : Write a program to enter a number and display it's hex
and octal equivalent and it's square root.
CODE :
number = int(input("Enter a number: "))
hexadecimal = hex(number)
octal = oct(number)
square_root = (number)**0.5
print(f"The hexadecimal equivalent of {number} is
{hexadecimal}")
print(f"The octal equivalent of {number} is {octal}")
print(f"The square root of {number} is {square_root:.2f}")
OUTPUT:
Enter a number: 56
The hexadecimal equivalent of 56 is 0x38
The octal equivalent of 56 is 0o70
The square root of 56 is 7.48