READ THE INSTURCTIONS BEFORE WRITING
1. RECORD NOTE BOOK PAGES 120
2. COVER THE RECORD NOTE
3. ONE SIDE RULED AND OTHER SIDE UNRULED NOTE
4. WRITE THE ALL THE 15 PROGRAMS
5. WRITE THE QUESTION, AIM , SOURSE CODE IN RULED SIDE.
6. WRITE THE OUTPUT IN THE UNRULED SIDE.
7. USE BLACK PEN FOR SUB HEADINGS
8. USE PROPER PEN.
9. WRITE THE SOURCE CODE CORRECTLY AND USE PROPER INDENDATION AS GIVEN IN THE
SOURCE CODE.
PRACTICAL PROGRAMS
Program 1 : Performing all Arithmetic operations
Aim : To calculate all arithmetic operations
Source Code :
a = int(input("Enter first number : "))
b = int(input("Enter second number : "))
c=a+b
d=a-b
e=a*b
f=a/b
g= a%b
h= a**2
print ("Added result is : ", c)
print ("Subtracted result is : ",d)
print ("Multiplied result is : ",e)
print ("Divided result is : ",f)
print ("Remainder result is : ",g)
print ("Power value is : ",h)
Output :
Enter first number : 25
Enter second number : 5
Added result is : 30
Subtracted result is : 20
Multiplied result is : 125
Divided result is : 5.0
Remainder result is : 0
Power value is : 625
Program 2 : Simple Interest
Aim : To find the simple interest for the given Principle, No of years and Rate of interest
Source Code:
pri = int(input(“Enter Principle : “))
noy = int(input(“Enter No of Years : “))
roi = float(input(“Enter Rate of Interest : “))
si = (pri * noy * roi)/100
print (“Simple interest is : “ , si)
Output :
Enter Principle : 10000
Enter No of Years : 5
Enter Rate of Interest : 3.5
Simple interest is : 1750.0
Program - 3 : Swapping of two values
Aim : To swap two value
Source Code :
a = int(input("Enter a number : "))
b = int(input("Enter another number : "))
a,b=b,a
print("Now the new value of A is ",a)
print("Now the new value of B is ",b)
OUTPUT:
Enter a number : 75
Enter another number : 93
Now the new value of A is 93
Now the new value of B is 75
Program 4 : Program to print PASS / FAIL
Aim : To check the mark and print PASS / FAIL using if else statement
Source Code :
m=int(input("Enter mark : "))
if m>=40:
print("You are pass")
else:
print("You are fail")
OUTPUT
Enter mark : 75
You are pass
Enter mark : 23
You are fail
Program 5 : To find the given year is leap year or not
Aim : To find the given year is leap year or not using if..else statement
Source Code :
y = int(input("Enter the year to be checked "))
if y % 4 == 0:
print("Given year is leap year and has 366 days")
else:
print("Given year is not a leap year")
Output
Enter the year to be checked 2021
Given year is not a leap year
Enter the year to be checked 2020
Given year is leap year and has 366 days
Program 6: Write a program to check whether the given number is odd or even
AIM : Program to check whether a given number is odd or even using if… else
statement.
Source Code :
#program to find the given number is odd or even
n = int(input("Enter the number to be checked "))
if n % 2 == 0:
print(n, " is a even number")
else:
print(n, "is a odd number")
Output :
Enter the number to be checked 56
56 is a even number
Enter the number to be checked 95
95 is a odd number
Program 7 : Write a program to print multiplication table
AIM : To print multiplication table using Loops
Source Code :
#printing multiplication table of any no from 1 to 10 nos
i=1
n = int(input("Enter multiplication table for : "))
while i <= 10:
print(n," * ",i," = ",n*i)
i = i +1
Output
Enter multiplication table for : 7
7*1=7
7 * 2 = 14
7 * 3 = 21
7 * 4 = 28
7 * 5 = 35
7 * 6 = 42
7 * 7 = 49
7 * 8 = 56
7 * 9 = 63
7 * 10 = 70
Program 8: Write a program to print first n add and even natural numbers
Aim : Program to print first n odd and even natural numbers
Source Code:
#print odd and even natural numbers upto N
x=int(input("Enter a natural number :"))
print("The first”, n, “ odd numbers are")
for i in range(1,x+1,2):
print(i)
print("The first”, n ,” even numbers are")
for i in range(2,x+1,2):
print(i)
Output
Enter a natural number: 10
The first 10 add numbers are
The first 10 even numbers are
10
Program 9 Akash wants to create a password based smart system for the entry door
of his house for any person to enter his house.
Write a code which can take password as an input from the user and then check for the
correct password which is "SECRET". The user can enter the password only 3 times
and the system should print "You cannot enter the house after that".
AIM : Writing a program to check for the password using looping and selection
statement.
Source code :
flag = 0
for i in range(3):
pwd = input("Enter the password: ")
if pwd == "SECRET":
print("Welcome!")
flag = 1
break
else:
print("Wrong password! \n")
if flag == 0:
print("You can not enter the house.")
OUTPUT :
Enter the password: secret
Wrong password!
Enter the password: rockers
Wrong password
Program 10 : Write program to find the factorial of a number
Aim : Program to find the factorial of a number
Source Code:
#FACTORIAL OF A NUMBER
x=int(input("Enter a natural number : "))
s=1
for i in range(1,x+1,1):
s=s*i
print("THE FACTORIAL OF " , x," IS ", s)
Output
Enter a natural number : 10
THE FACTORIAL OF 10 IS 3628800
Program 11: Write program to check a given number is positive , negative or zero using if else
ladder
Aim: Program to check a given number is positive , negative or zero using if else ladder
Source Code:
#checking postive , negative or zero
a=int(input("Enter the number "))
if a>0:
print(a, " is a positive number ")
elif a<0:
print(a, " is a negative number ")
else:
print(a, " is either positive or negative")
Output
Enter the number 5
5 is a postive number
Enter the number -5
-5 is a negative number
Enter the number0
0 is either positive or negative
Program 12 : To print the following
*
**
***
****
*****
Aim : Program to print the pattern.
Source Code
#TO PRINT PATTERN
x=int(input("enter a natural number to print pattern"))
for i in range(1,x+1,1):
for j in range(1,i+1,1):
print("*",end=' ')
print("\n")
Output
**
***
****
*****
Program 13 : Write a program to find the area and circumference of a circle
Aim : Program to find the area and circumference of a circle
Source Code:
# AREA AND CIRCUMFERENCE OF A CIRCLE
r = float(input("Enter the RADIUS "))
area = 3.14 * r **2
p = 2 * 22/7 * r
print("The Area of the circle is " , area )
print("The Perimeter of the circle is " ,p )
output
Enter the RADIUS 6
The Area of the circle is 113.04
The Perimeter of the circle is 37.71
Program 14: Write a program to reverse a given number
Aim : Program to reverse a given number
Source Code
#REVERSE THE NUMBER
num=int(input("Enter the number"))
reversed_num = 0
while num != 0:
digit = num % 10
reversed_num = reversed_num * 10 + digit
num //= 10
print("Reversed Number: " , str(reversed_num))
Output :
Enter the number4325
Reversed Number: 5234
Program 15: Write a program to print day name in words using if elif else ladder
Aim : Program to print day name in words using if elif else ladder
Source Code
# Print day name in words using if elif else ladder
day = int(input("Enter a number from 1 to 7: "))
if day == 1:
print(day, "is Sunday")
elif day == 2:
print(day, "is Monday")
elif day == 3:
print(day, "is Tuesday")
elif day == 4:
print(day, "is Wednesday")
elif day == 5:
print(day, "is Thursday")
elif day == 6:
print(day, "is Friday")
elif day == 7:
print(day, "is Saturday")
else:
print("Wrong input! Please enter a number from 1 to 7.")
OUTPUT :
Enter a number from 1 to 7: 4
4 is Wednesday
Enter a number from 1 to 7: 0
Wrong input! Please enter a number from 1 to 7