Karan CS Assignment
Karan CS Assignment
CLASS-12C
...
def Area(L,B):
return L*B
def Perimeter(L,B):
return 2*(L+B)
X=Area(L,B)
Y=Perimeter(L,B)
print("area=",X)
print("perimeter=",Y)
...Output
import math as m
P=m.pi
def Radian(D):
return P/180*D
X=Radian(Deg)
print("Radian = ",X)
...output
Radian = 0.7853981633974483...
...
import math as m
P=m.pi
def Degree(R):
return 180/P*R
X=Degree(Rad)
print("Degree = ",X)
...output
Degree = 114.59155902616465
...
...
def Area(P1,P2,H):
return 1/2*(P1+P2)*H
X=Area(s1,s2,s3)
...output
...
...
Q7 Write a program to find the greatest among two variables without using
relational operator.
L=(A+B+abs(A-B))//2
return L
M=Large(A,B)
...output
the largest No : 4
...
...
of Petrol, that can be stored in the container, if the price of petrol is Rs 73 per
litre. [Remember 1 mtr cube = 1000 litre]
import math as m
P=m.pi
def Volume(R,H):
V=22/7*R**2*H
return V
...output
Enter the Radius Of Cylinder : 7
Enter the Height Of Cylinder : 14
The Volume Of Cylinder : 2156.0 mtr cub
Price : 157388000.0
Q9 Write a program to accept Quantity of Fuel (in litre) and Distance travelled (in
KM) from the user, calculate and display the Average of the Vehicle (i.e. KM per
Litre)
def Avg(D,L):
return D/L
...output
def Per(A,B,C,D,E):
P=(A+B+C+D+E)/150*100
return P
...output
Enter the Marks Of Sub1 : 24
Enter the Marks Of Sub2 : 12
Enter the Marks Of Sub3 : 29
Enter the Marks Of Sub4 : 20
Enter the Marks Of Sub5 : 19.5
The Total Percentage : 69.66666666666667
...
Q11 Write a Program to calculate and display Block and Floor No on the basis of
Customer Number. Assume there are 10 Blocks (‘A’ to ‘J’) with 5 floors (0 to 4)
each and allocated to customers sequentially as per their customer number. For
example customer no 1 gets [Block A Floor 0], customer no 2 gets [Block A Floor
2], customer no 7 gets [Block B Floor 1]
Hint :
a) Use Arithmetic operators
b) Use the knowledge of ASCII codes.
c) Use inbuilt function chr(). E.g. chr(65) is ‘A’
def Address(CNO):
X=CNO-1
F=X%5
Q=X//5
B=chr(65+Q)
return [F,B]
FL,BL=Address(N)
...output
Enter the No : 50
[BLOCK J FLOOR 4]
...
Q12 Write a program to calculate total collection of a PARKING area on the basis
of number of vehicles under each category entered by the user. Per vehicle
amounts for each type of vehicle is as follows:
Bus Rs 100; SUV Rs 40; Car Rs 30 and Two-wheeler Rs 10
Sample Output:
Number of Buses
Number of SUV’s
Number of Cars
Number of Two-wheelers Collection for Buses Collection for SUVs Collection for
Cars Collection for Two wheelers Total Collection : 4700
: 10 : 30 : 50
: 100
: 1000 : 1200 : 1500 : 1000
def Bus(B):
return B*100
def SUV(N):
return N*40
def Car(C):
return C*30
def TwoWheeler(T):
return T*10
A=Bus(NB)
B=SUV(NS)
Y=Car(NC)
Z=TwoWheeler(NT)
...output
def Check(N):
X=N%10**2
if X%3==0:
return 1
return 0
Z=Check(A)
if Z==1:
else:
...output
def V_Age(A):
if A>=18:
return 1
return 0
...output
def M_Range(G):
if G == "A":
return "100-90"
if G == "B":
return "89-75"
if G == "C":
return "74-60"
if G == "D":
return "59-45"
if G == "E":
return "44-33"
if G == "F":
return "32-0"
return "Invalid Grade"
Grade=int(input("Enter your grade : "))
R=M_Range(Grade)
if R!="Invalid Grade":
print(F"The range is {R}")
else:
print("Invalid Grade")
...output
Enter your grade : 56
Invalid Grade
Q16
def Grades(M):
if M>=90:
return 'A'
elif M>=75:
return 'B'
elif M>=60:
return 'C'
elif M>=45:
return 'D'
elif M>=33:
return 'E'
else:
return 'F'
while 1:
Mark=float(input("Enter the Marks : "))
if Mark>=0 and Mark<=100:
break
else:
print("Enter a Valid No(0-100)")
X=Grades(Mark)
print(F"The Grade = {X}")
...output
Enter the Marks : -200
Enter a Valid No(0-100)
Enter the Marks : -3.14
Enter a Valid No(0-100)
Enter the Marks : 99.9
The Grade = A
def M_Age(A):
if A>=60:
return "7"
elif A>=20:
return "6"
elif A>=10:
return "5"
else:
return "4"
def F_Age(A):
if A>=58:
return "3"
if A>=18:
return "2"
if A>=10:
return "1"
return"0"
...output
Q18
def H_S(S1,S2,S3,S4,S5):
if S1>S2:
H,S=S1,S2
else:
H,S=S2,S1
if S3>H:
H,S=S3,H
elif S3>S:
S=S3
if S4>H:
H,S=S4,H
elif S4>S:
S=S4
if S5>H:
H,S=S5,H
elif S5>S:
S=S5
return H,S
...output
Enter the No1 :23
Enter the No2 :45
Enter the No3 :67
Enter the No4 :89
Enter the No5 :54
The highest score is 89 and the second highest score
is 67
Q19
def H_L(S1,S2,S3,S4,S5):
if S1>S2:
H,L=S1,S2
else:
H,L=S2,S1
if S3>H:
H=S3
elif S3<L:
L=S3
if S4>H:
H=S4
elif S4<L:
L=S4
if S5>H:
S=S5
elif S5<L:
L=S5
return H,L
...output
Enter the No1 :23
Enter the No2 :67
Enter the No3 :89
Enter the No4 :92
Enter the No5 :13
The highest score is 92 and the lowest score is 13