Class 11 PRACTICAL FILE
Class 11 PRACTICAL FILE
Class 11 PRACTICAL FILE
print('Hello, world!')
output- Hello, world!
2 Write a program to find the sum of two numbers
Ans- M1
#This program adds two numbers
num1 = 1.5
num2 = 6.3
M2
#Store input numbers
num1 = input('Enter first number: ')
num2 = input('Enter second number: ')
M3
print('The sum is %.1f ' %(float(input('Enter first number: ')) + float(input('Enter second number:
'))))
3 Write a program to calculate average of n numbers.
Ans-M1
n = int(input("Enter number"))
sum = 0
# loop from 1 to n
for num in range(1, n + 1, 1):
sum = sum + num
print("Sum of first ", n, "numbers is: ", sum)
average = sum / n
print("Average of ", n, "numbers is: ", average)
M2
n = 10
res = sum(range(1, n + 1))
print("Sum of first ", n, "numbers is: ", res)
Ans-M1
# Python program to find the largest number among the three input numbers
7 Write a python program that accepts radius of a circle and prints its area.
Ans- M1
r = float(input("Enter radius of circle: "))
a = 3.14159 * r * r
print("Area of circle =", a)
M2
# Default function to implement conditions to check leap year
def CheckLeap(Year):
# Checking if the given year is leap year
if((Year % 400 == 0) or
(Year % 100 != 0) and
(Year % 4 == 0)):
print("Given Year is a leap Year");
# Else it is not a leap year
else:
print ("Given Year is not a leap Year")
# Taking an input year from user
Year = int(input("Enter the number: "))
# Printing result
CheckLeap(Year)
10 Write a program in python to convert °C to °F and vice versa.
Prog.M1
celsius = int(input("enter the no."))
# main function
s = input("enter the string")
ans = isPalindrome(s)
if (ans):
print("Yes")
else:
print("No")
13 Write a program to check a number whether it is perfect number or not.
Ans-
n = int(input("Enter any number: "))
sum1 = 0
for i in range(1, n):
if(n % i == 0):
sum1 = sum1 + i
if (sum1==n):
print("The number is a Perfect number!")
else:
print("The number is not a Perfect number!")
14 Write a program to check a number whether it is armstrong number or not.
Ans-
def is_armstrong(num):
num_str = str(num)
n = len(num_str)
sum = 0
for digit in num_str:
sum += int(digit)**n
if sum == num:
return True
else:
return False
num=int(input("Enter the no."))
print(is_armstrong(num))
15 Write a program to calculate simple interest.
Ans
def simple_interest(p,r,t):
si = (p * r * t)/100
return si
x = 10
y = 50
print("Value of x:", x)
print("Value of y:", y)
18 Write a program to display ASCII code of a character and vice versa.
Ans
# Program to find the ASCII value of the given character
c =input("Enter any character: ")
print("The ASCII value of '" + c + "' is", ord(c))
20 Write a program that reads a string and print its statistics like : Number of Uppercase letters, Number of
lowercase letters, Number of alphabets, Number of digits, Number of symbols.
Ans-
B
*
*
* *
A * *
* * *
* * * *
Ans * * *
n=4
* * * *
for i in range(0, n):
for j in range(0, i+1): * * * * *
print("*", end=" ")
Ans
print()
n=5;i=0
while(i<=n):
print(" " * (n - i) +"*" * i)
i+=1
1
*
2 2
C D * *
3 3 3 * * *
4 4 4 4 * * * *
Ans- * * * * *
Ans-
for i in range(1,6):
n=5;i=0
for j in range(1,i+1): while(i<=n):
print(j,end=" ") print(" " * (n - i) +" *" * i)
print() i+=1
1
F
1 2 F
E
1 2 3
1 2 3 4
1 2 3 4 5
Ans-
for i in range(1,6):
for j in range(1,i+1):
print(j,end=" ")
print()
A 1
B C 2 3
G H
D E F 4 5 6
G H I J 7 8 9 10
Ans-
for i in range (65,70):
# inner loop
for j in range(65,i+1):
print(chr(j),end=" ")
print()
A 10 9 8 7
BB 6 5 4
I J
C CC 3 2
D D DD 1
E E E E E
Ans-
for i in range (65,70):
# inner loop
for j in range(65,i+1):
print(chr(i),end="")
print()
HCF = 1
for i in range(2,a+1):
if(a%i==0 and b%i==0):
HCF = i
print("HCF of the two numbers is: ",HCF)
LCM = int((a*b)/(HCF))
print("LCM of the two numbers is: ",LCM)
27 Write a program to compare two strings.
Ans
str1 = input("Enter the first String: ")
if str1 == str2:
else: