0% found this document useful (0 votes)
95 views7 pages

XI Practical Mannual

The document contains a series of Python programming problems and their corresponding solutions. It covers various topics including unit conversion, interest calculation, Armstrong numbers, grading systems, LCM and GCD calculations, quadratic equations, factorials, series summation, palindrome checking, word counting, and classification of numbers. Each problem is accompanied by sample input and output for clarity.

Uploaded by

coolsarvesh2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views7 pages

XI Practical Mannual

The document contains a series of Python programming problems and their corresponding solutions. It covers various topics including unit conversion, interest calculation, Armstrong numbers, grading systems, LCM and GCD calculations, quadratic equations, factorials, series summation, palindrome checking, word counting, and classification of numbers. Each problem is accompanied by sample input and output for clarity.

Uploaded by

coolsarvesh2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Problem No.

1 Date: else:
Write a Python Program to convert Centimeters into Inches and Feet. print("The number ",n1," is not an ARMSTRONG number")

PROGRAM CODE:
SAMPLE INPUT AND OUTPUT:
centi = float(input("Enter the height in Centimeters : "))
Enter a number : 153
The number 153 is an ARMSTRONG number
inches = round(0.3937 * centi,0)
ft = round(inches/12,2)
Enter a number : 128

print("Height in Feet = ",ft) The number 128 is not an ARMSTRONG number

print("Height in Inches = ",inches) Problem No. 3 Date:


Write a Python Program to calculate Simple and Compound Interest.

( )
T
SAMPLE INPUT AND OUTPUT: PRT R
S.I. = C.I. = P 1+ -P
100 100
Enter the height in cms : 165
Height in feet = 5.42
PROGRAM CODE:
Height in inches = 65.0
p=float(input("Enter the Principle Amount :"))
*************************************************************
r=float(input("Enter the Rate of Interest (per Month) :"))
***************
t=float(input("Enter the Time Duration (in Months) : "))
Problem No. 2 Date:
Write a Python Program to find the given three digit number is
si = p* r * t/100
ARMSTRONG Number or Not.
ci = p*(1+r/100)**t - p
PROGRAM CODE:
sum =0 print("Simple Interest : ",chr(0x20B9),round(si,2))
num=int(input("Enter a number : ")) print("Compound Interest : ",chr(0x20B9),round(ci,2))
n1 = num
SAMPLE INPUT AND OUTPUT:
while num != 0: Enter the Principle Amount :10000
r1 = num%10 Enter the Rate of Interest (per Month) :2
sum = sum + r1**3 Enter the Time Duration (in Months) : 10
num=num//10
Simple Interest : ₹ 2000.0
if n1==sum:
Compound Interest : ₹ 2189.94
print("The number ",n1," is an ARMSTRONG number")
*************************************************************
**************** else:
Problem No. 4 Date: grade = 'E'
Write a Python Program to get five subject marks and find the grade
according to the table given below. print("\nThe Subject Marks are : ", end = "")
Average Grade print(m1,m2,m3,m4,m5,sep=",")
>=90 O
print("Average : ",avg)
>=80 A
print("The grade is : ",grade)
>=70 B
>=60 C
>=50 D SAMPLE INPUT AND OUTPUT:
<50 E Enter the Mark in Subject1 : 85
PROGRAM CODE: Enter the Mark in Subject2 : 79
m1 = int(input("Enter the Mark in Subject1 : ")) Enter the Mark in Subject3 : 89
m2 = int(input("Enter the Mark in Subject2 : ")) Enter the Mark in Subject4 : 93
m3 = int(input("Enter the Mark in Subject3 : ")) Enter the Mark in Subject5 : 79
m4 = int(input("Enter the Mark in Subject4 : "))
m5 = int(input("Enter the Mark in Subject5 : ")) The Subject Marks are : 85,79,89,93,79
Average : 85.0
sum =m1+m2+m3+m4+m5 The grade is : A
avg = sum/5 *************************************************************
***************
if avg>100: Problem No. 5 Date:
grade = "Error" Write a Python script to input two numbers and print their LCM (Least
elif avg>=90: Common Multiple) and GCD (Gretest Common Divisor).
grade = 'O'
elif avg>=80:
PROGRAM CODE:
grade = 'A'
x = int(input("Enter first number : "))
elif avg>=70:
y = int(input("Enter second number : "))
grade = 'B'
smaller = x if x < y else y
elif avg>=60:
grade = 'C' for i in range(1, smaller + 1):
elif avg>=50: if((x % i == 0) and (y % i == 0)):
grade = 'D' hcf = i
lcm = (x * y) / hcf else:
print("The H.C.F. of", x, "and", y, "is", hcf) print ("Roots are COMPLEX and IMAGINARY")
print("The L.C.M. of", x, "and", y, "is", lcm)
SAMPLE INPUT AND OUTPUT:
SAMPLE INPUT AND OUTPUT:
For Quadratic Equation, ax**2+bx+c=0, enter the coefficients
Enter first number : 15 below
Enter second number : 21 Enter a : 1
The H.C.F. of 15 and 21 is 3 Enter b : 2
The L.C.M. of 15 and 21 is 105.0 Enter c : 2
************************************************************* Roots are COMPLEX and IMAGINARY
**************
Problem No. 6 Date: For Quadratic Equation, ax**2+bx+c=0, enter the coefficients
Write a Python Program to calculate and print roots of a quadratic below
equation : ax2 + bx + c = 0 (a≠0) Enter a : 1
Enter b : 3
PROGRAM CODE:
Enter c : 2
import math Roots are REAL and UNEQUAL
print("For Quadratic Equation, ax**2+bx+c=0, enter the Root1 = -1.0 , Root2 = -2.0
coefficients below ")
a=int(input("Enter a : ")) For Quadratic Equation, ax**2+bx+c=0, enter the coefficients
b=int(input("Enter b : ")) below
c=int(input("Enter c : ")) Enter a : 1
if a==0: Enter b : 2
print("Value of ",a,' should not be zero') Enter c : 1
print("Aborting!!!") Roots are REAL and EQUAL
else: Root1 = -1.0 , Root2 = -1.0
delta = b*b - 4*a*c *************************************************************
if delta > 0: ****************
root1 = ( - b + math.sqrt(delta)) / (2 * a) Problem No. 7 Date:
root2 = (-b - math.sqrt(delta)) / (2 * a) Write a Python Program to find the factorial of a given number using
print ("Roots are REAL and UNEQUAL") function
print ("Root1 = ", root1, ", Root2 = ", root2)
elif delta == 0: PROGRAM CODE:
root1 = - b / (2 * a);
def facto(n):
print ("Roots are REAL and EQUAL")
f=1
print ("Root1 = ", root1, ", Root2 = ", root1)
for i in range(1,n+1):
f *= i The sum of the series is : 0.9333333333333333
return f *************************************************************
**************
num=int(input("Enter a number to find the Factorial : ")) Problem No. 9 Date:
fac = facto(num)
Write a Python Program to print the following pattern:
print("Factorial of ",num," is ",fac)
CEGIK
DFHJ
SAMPLE INPUT AND OUTPUT:
EGI
Enter a number to find the Factorial : 5 FH
Factorial of 5 is 120 G
PROGRAM CODE:
#Printing the Pattern
Problem No. 8 Date:
ch = 67
Write a Python Program to find the sum of the following series : start = ch
3 5 n
x x x for i in range(5,-1,-1):
x- + +…+
3! 5! n!
for j in range(i):
PROGRAM CODE:
print(chr(ch),end=" ")
print("TO FIND THE SUM OF SERIES OF X-X^3/3!+X^5/5!+...")
ch+=2
x= int(input("Enter the value of x : ")) start = start+1
n = int(input("Enter the value of n : ")) ch=start
print()
a=1
sum_series = 0
SAMPLE INPUT AND OUTPUT:
for i in range(1,n+1,2): CEGIK
fact=1 DFHJ
for j in range(1,i+1): EGI
fact *=j
FH
sum_series += x**i*a/fact
G
a *= -1
*************************************************************
print("The sum of the series is :",sum_series) ***************
Problem No. 10 Date:
SAMPLE INPUT AND OUTPUT:
Write a Python Program to find the factors of a given number using
TO FIND THE SUM OF SERIES OF X-X^3/3!+X^5/5!+...
while loop.
Enter the value of x : 2
Enter the value of n : 5
PROGRAM CODE: else:
n=int(input("Enter an integer : ")) print("The string is NOT PALINDROME")
print("Factors are : ")
SAMPLE INPUT AND OUTPUT:
i=2
Enter any string: TAMIL
while i<n: Reversed String : LIMAT
if n%i==0: The string is NOT PALINDROME
print(i)
i+=1 Enter any string: MADAM
Reversed String : MADAM
SAMPLE INPUT AND OUTPUT: The string is PALINDROME
Enter an integer : 21 *************************************************************
Factors are : ***************
3 Problem No. 12 Date:
7 Write a Python Program to count the following in the given string:
************************************************************* (i) Number of two letter words
*************** (ii) Number of Capital Letters
Problem No. 11 Date: (iii) Number of Small Letters
Write a Python Program to find the given string is PALINDROME or
NOT. PROGRAM CODE:
string = input("Enter the text : ")
PROGRAM CODE: word_cnt=upper_cnt=lower_cnt=0
string = input("Enter any string: ") words = string.split(" ")
rev=""
for i in words:
for i in range(len(string)-1,-1,-1): if len(i)==2:
rev = rev+string[i] word_cnt += 1

print("Reversed String : ",rev) for i in string:


if rev == string: if i.isupper():
print("The string is PALINDROME") upper_cnt += 1
elif i.islower(): print("The smallest number of the list is :",small)
lower_cnt+=1
SAMPLE INPUT AND OUTPUT:
print("Count of TWO letter Words : ",word_cnt) Enter the LIST of numbers : [43,2,73,987,-5,23]
print("Upper Case Letters : ",upper_cnt) The biggest number of the list is : 987
print("Lower Case Letters : ",lower_cnt) The smallest number of the list is : -5
*************************************************************
SAMPLE INPUT AND OUTPUT: ***************
Enter the text : He is playing in the park with his friend Problem No. 14 Date:
ARJUN Write a Python Program to classify the numbers of a LIST as Prime or
Count of TWO letter Words : 3 Composite.
Upper Case Letters : 6
Lower Case Letters : 32 PROGRAM CODE:
************************************************************* L = eval(input("Enter the Numbers in the LIST : "))
***************
Problem No. 13 Date: prime = composite =""
Write a Python Program to find the biggest and smallest numbers in the f=0
List.
for i in L:
PROGRAM CODE: lim = i//2
L = eval(input("Enter the LIST of numbers : ")) for j in range(2,lim+1):
if i%j==0:
small = L[0] composite += str(i)+","
big = L[0] f=1
break
for i in range(1,len(L)): if f!=1:
if L[i]<small: prime += str(i)+","
small = L[i] f=0
if L[i]>big: print("The prime numbers are ",prime)
big = L[i] print("The composite numbers are ",composite)

print("The biggest number of the list is :",big) SAMPLE INPUT AND OUTPUT:
*************************************************************
Enter the Numbers in the LIST : [3,9,7,13,4] ***************
The prime numbers are 3,7,13, Problem No. 16 Date:
The composite numbers are 9,4, Write a Python Program to create a List of Tuples contains the given
************************************************************* List of numbers and their cubs.
***************
Problem No. 15 Date: PROGRAM CODE:
Write a Python Program to create a Dictionary with the count frequency
of the elements of the given List. List = eval(input("Enter the numbers of the List : "))

PROGRAM CODE: new_List = []


L = eval(input("Enter the numbers of the list : "))
dict_cnt = {} for i in List:
temp_List = [] tup = (i,i**3)
cnt = 0 new_List.append(tup)
while True:
if len(L)!=0: print("List of Tuples with the number and its cube:",new_List)
n = L[0]
dict_cnt[n]= L.count(n) SAMPLE INPUT AND OUTPUT:
for i in range(L.count(n)): Enter the numbers of the List : [2,3,4]
L.remove(n) List of Tuples with the number and its cube: [(2, 8), (3, 27), (4, 64)]
else:
break

print("The dictionary with the count of frequency of \


elements of the list is : \n",dict_cnt)

SAMPLE INPUT AND OUTPUT:

Enter the numbers of the list : [3,3,2,5,5,7,5,8,7,3,9,4,8]


The dictionary with the count of frequency of elements of the list is :
{3: 3, 2: 1, 5: 3, 7: 2, 8: 2, 9: 1, 4: 1}

You might also like