Class 11 Journal 2024-25
Class 11 Journal 2024-25
Area=(1/2)*b*h
import math
print('To calculate 4x⁴+3y³+9z+6π')
x=float(input('Enter the number x:'))
y=float(input('Enter the number y:'))
z=float(input('Enter the number z:'))
b=(4*math.pow(x,4))+(3*math.pow(y,3))+(9*z)+(6*math.pi)
print('The result of the above expression is:',b)
7. # Write a program to input a number and print its square if it is odd, if it is not odd then print its
square root.
import math
a=math.pow(x,2)
b=math.sqrt(x)
if x%2!=0:
print('The value of square is:',a)
else:
print('The value of square root is:',b)
8. Write a program to input percentage marks of a student and find the grade as per following
criterion:
Marks Grade
>=90 A
75-90 B
60-75 C
Below 60 D
'''
a=float(input('Enter the percentage marks:'))
if a>=90:
print('The student has got an A grade')
elif a>=75 and a<90:
print('The student has got a B grade')
elif a>=60 and a<75:
print('The student has got a C grade')
else:
print('The student has got a D grade')
10. # Write a program to display a menu for calculating area of circle or perimeter of the circle.
while True:
print('1.Calculate perimeter')
print('2.Calculate area')
print('3.Exit')
if choice==1:
peri=2*3.14159*r
elif choice==2:
area=3.14159*r*r
else:
break
11. # Write a program to print whether a given character is an uppercase or a lowercase character or
a digit or any other character.
num=int(input('Enter a number:'))
fact=1
a=1
while a<=num:
fact*=a
a+=1
print('The factorial of',num,'is',fact)
for i in range(1,6):
print()
for j in range(1,i):
print('*',end=' ')
first=0
second=1
print(first, end=' ')
print(second,end=' ')
for a in range(1,9):
third=first+second
print(third,end=' ')
first,second=second,third
'''
1
13
135
1357
'''
for a in range(3,10,2):
print()
for b in range(1,a,2):
print(b, end=' ')
print()
18. #Program that reads a line and print its statistics like:
'''
Number of uppercase letters:
Number of lowercase letters:
Number of alphabets:
Number of digits:
'''
line=input('Enter a line:')
lowercount=uppercount=0
digitcount=alphacount=0
for a in line:
if a.islower():
lowercount+=1
elif a.isupper():
uppercount+=1
elif a.isdigit():
digitcount+=1
if a.isalpha():
alphacount+=1
print('Number of uppercase letters are:',uppercount)
print('Number of lowercase letters are:',lowercount)
print('Number of alphabets are:',alphacount)
print('Number of digits are:',digitcount)
19. #Write a program that reads a line and a substring and displays the number of occurrences of the
given substring in the line.
line=input('Enter line:')
sub=input('Enter substring:')
length=len(line)
lensub=len(sub)
start=count=0
end=length
while True:
pos=line.find(sub,start,end)
if pos!=-1:
count+=1
start=pos+lensub
else:
break
if start>=length:
break
print('No. of occurences of',sub,':',count)
20. #Write a program that takes a string with multiple words and then capitalizes the first letter of
each word and forms a new string out of it.
string=input('Enter a string:')
length=len(string)
a=0
end=length
string2=''
while a<length:
if a==0:
string2+=string[0].upper()
a+=1
elif(string[a]==' ' and string[a+1]!=' '):
string2+=string[a]
string2+=string[a+1].upper()
a+=2
elif (string[a]==',' and string[a+1]!=','):
string2+=string[a]
string2+=string[a+1].upper()
a+=2
else:
string2+=string[a]
a+=1
print('Original string:',string)
print('Capitalized words string:',string2)
21. #Write a program that reads a string and checks whether it is a palindrome string or not.
string=input('Enter a string:')
length=len(string)
mid=length//2
rev=-1
for a in range(mid):
if string[a]==string[rev]:
print(string,'is a palindrome.')
break
else:
print(stri
22. Write a program that reads a string and displays the longest substring of the given string having
just the consonants.
string=input('Enter a string:')
length=len(string)
maxlength=0
maxsub=''
sub=''
lensub=0
for a in range(length):
if string[a] in 'aeiou' or string[a] in 'AEIOU':
if lensub>maxlength:
maxsub=sub
maxlength=lensub
sub=''
lensub=0
else:
sub+=string[a]
lensub=len(sub)
a+=1
print('Maximum length consonant substring is:',maxsub,end=' ')
print('with',maxlength,'characters')
for i in L:
if i not in L2:
x=L.count(i)
L1.append(x)
L2.append(i)
for i in range(len(L1)):
print (L2[i],'\t\t\t',L1[i])
24. # WAP in Python to find and display the sum of all the values which are ending with 3 from a list.
L=[33,13,92,99,3,12]
sum=0
x=len (L)
for i in range(0,x):
if type (L [i])== int:
if L[i]%10==3:
sum+=L[i]
print (s
26.# WAP to input any two tuples and swap their values
t1 = tuple()
n = int (input("Total no of values in First tuple: "))
for i in range(n):
a = input("Enter Elements : ")
t1 = t1 + (a,)
t2 = tuple()
m = int (input("Total no of values in Second tuple: "))
for i in range(m):
a = input("Enter Elements : ")
t2 = t2 + (a,)
print("First Tuple : ")
print(t1)
print("Second Tuple : ")
print(t2)
t1,t2 = t2, t1
27. # Write a program to input total number of sections and stream name in 11th class and display all
information on the output screen.
classxi=dict()
n=int(input("Enter total number of section in xi class: "))
i=1
while i<=n:
a=input("Enter Section: ")
b=input ("Enter stream name: ")
classxi[i]=b
i=i+1
print ("Class",'\t''Section''\t''Stream name')
for i in classxi:
print ("XI",'\t',i,'\t',classxi[i])
28. # WAP to store students’ details like admission number, roll number, name and percentage in a
dictionary and display information on the basis of admission number.
record = dict ()
i=1
n= int (input ("How many records u want to enter: "))
while(i<=n):
Adm = input("Enter Admission number: ")
roll = input("Enter Roll Number: ")
name = input("Enter Name :")
perc = float(input("Enter Percentage : "))
t = (roll,name, perc)
record[Adm] = t
i=i+1
Nkey = record.keys()
for i in Nkey:
print("\nAdmno- ", i, " :")
r = record[i]
print("Roll No\t", "Name\t", "Percentage\t")
for j in r:
print(j, end = "\t")
29. Write a program to input n numbers from the user. Store these numbers in a tuple. Print the
maximum, minimum, sum and mean of number from this tuple.
c. This function returns a random integer between a given start and stop integer.
d. Used for making a random selection from a sequence (list, tuple, string)
import random
random_number=random.random()
print(random_number)
random_number=random.randrange(10,21)
print(random_number)
random_number=random.randint(100,200)
print(random_number)
my_choice=random.choice(["RED","YELLOW","GREEN", "BLUE"])
print(my_choice)
color=["RED","YELLOW","GREEN", "BLUE"]
random.shuffle(color)
print(color)