Lab Ex 1-3
Lab Ex 1-3
a) Addition program
Direct input
a=6
b=10
c=a=b
print("The value of c is:", c)
Input from user
a=int(input("Enter the value of a:"))
b= int(input("Enter the value of b:"))
c=a=b
print("The value of c is:", c)
b) Odd or Even number
num=int(input("Enter a number"))
mod=num%2
if mod>0:
print("The number is odd")
else:
print("The number is even")
c) Area of triangle
b=int(input("The base is"))
h=int(input("The height is"))
area=b*h/2
print("The area of triangle is:", area)
3. Exponentiation
AIM:
To implement a python program to find the exponentiation of a given
number
ALGORITHM:
Step 1: Start the program
Step 2: Enter the x value and n value
Step 3: Set a loop upto n
Step 4: Find the exponent value of x
temp=temp*x/i
sum=sum+temp
Step 5: After execution of the loop print the exponent value of x
Step 6: Stop the program
PROGRAM:
n=int(input('Enter number;'))
e=int(input('Enter exponent:'))
r=n
for i in range(1,e):
r=n*r
print'Exponentiation is:',r