Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

KARAN CS ASSIGNMENT

CLASS-12C
...

Q1 Write a program to find the Area and Perimeter of a rectangle.

def Area(L,B):
return L*B

def Perimeter(L,B):
return 2*(L+B)

L=int(input("Enter the Length : "))


B=int(input("Enter the Breadth : "))

X=Area(L,B)
Y=Perimeter(L,B)

print("area=",X)
print("perimeter=",Y)

...Output

Enter the Length : 4


Enter the Breadth : 5
area= 20
perimeter= 18
...
...

Q2 Write a program to convert degree to radian. Input degrees : 45


In Radians : 0.7857142857142857

import math as m

P=m.pi

def Radian(D):

return P/180*D

Deg=int(input("Enter the Degree : "))

X=Radian(Deg)

print("Radian = ",X)

...output

Enter the Degree : 45

Radian = 0.7853981633974483...
...

Q3 Write a program to convert radian to degree. Input radians : 2


In Degree : 114.54545454545455

import math as m

P=m.pi

def Degree(R):

return 180/P*R

Rad=int(input("Enter the Radian : "))

X=Degree(Rad)

print("Degree = ",X)

...output

Enter the Radian : 2

Degree = 114.59155902616465

...
...

Q4 Write a program to calculate the area of a trapezoid. Sample Output:


Height of trapezoid : 10 Top Width : 12 Bottom Width : 18 Area is : 150.0

def Area(P1,P2,H):

return 1/2*(P1+P2)*H

s1=int(input("Enter the 1st Parallel Side : "))

s2=int(input("Enter the 2nd Parallel Side : "))

s3=int(input("Enter the Height : "))

X=Area(s1,s2,s3)

print("The Area of Trapezium = ",X)

...output

Enter the 1st Parallel Side : 12

Enter the 2nd Parallel Side : 18

Enter the Height : 10

The Area = 150.0

...

...
Q7 Write a program to find the greatest among two variables without using
relational operator.

def Large (X,Y):

L=(A+B+abs(A-B))//2

return L

A=int(input("Enter the 1st No : "))

B=int(input("Enter the 2nd No : "))

M=Large(A,B)

print(F"the largest No : {M}")

...output

Enter the 1st No : 3

Enter the 2nd No : 4

the largest No : 4

...
...

Q8 Write a program to calculate the volume of a Cylindrical Oil Container. Also


calculate the Maximum cost

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

A=float(input("Enter the Radius Of Cylinder : "))


B=float(input("Enter the Height Of Cylinder : "))
U=Volume(A,B)
print(F"The Volume Of Cylinder : {U} mtr cub\nPrice :
{U*1000*73}")

...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

Km=float(input("Enter the Distance Travelled in Km:


"))
Ltr=float(input("Enter the Quantity Of Fuel Used :
"))
A=Avg(Km,Ltr)
print(F"Avg = {A}")

...output

Enter the Distance Travelled in Km: 20


Enter the Quantity Of Fuel Used : 500
Avg = 0.04
...

Q10 Write a program to calculate the total percentage of 5 subjects. (Assuming


the maximum marks to be 30)

def Per(A,B,C,D,E):
P=(A+B+C+D+E)/150*100
return P

Sub1=float(input("Enter the Marks Of Sub1 : "))


Sub2=float(input("Enter the Marks Of Sub2 : "))
Sub3=float(input("Enter the Marks Of Sub3 : "))
Sub4=float(input("Enter the Marks Of Sub4 : "))
Sub5=float(input("Enter the Marks Of Sub5 : "))
Percentage=Per(Sub1,Sub2,Sub3,Sub4,Sub5)
print(F"The Total Percentage : {Percentage}")

...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]

Note : This program has to be done without using relational operators

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]

N=int(input("Enter the No : "))

FL,BL=Address(N)

print(F"[BLOCK {BL} FLOOR {FL}]")

...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

NB=int(input("Enter The No Of Buses : "))

NS=int(input("Enter The No Of SUV : "))

NC=int(input("Enter The No Of Cars : "))


NT=int(input("Enter The No Of TwoWheeler : "))

A=Bus(NB)

B=SUV(NS)

Y=Car(NC)

Z=TwoWheeler(NT)

print(F"Collection for Buses : {A}")

print(F"Collection for SUV : {B}")

print(F"Collection for Cars : {Y}")

print(F"Collection for TwoWheeler : {Z}")

print(F"Total Collection = {A+B+Y+Z}")

...output

Enter The No Of Buses : 10

Enter The No Of SUV : 30

Enter The No Of Cars : 50

Enter The No Of TwoWheeler : 100

Collection for Buses : 1000

Collection for SUV : 1200

Collection for Cars : 1500

Collection for TwoWheeler : 1000

Total Collection = 4700


Q13

def Check(N):

X=N%10**2

if X%3==0:

return 1

return 0

A=int(input("Enter the No : "))

Z=Check(A)

if Z==1:

print(F"The Last 2 digits of {A} is divisible by


3")

else:

print(F"The Last 2 digits of {A} is not divisible


by 3")

...output

Enter the No : 3187

The Last 2 digits of 3187 is divisible by 3

Enter the No : 2127

The Last 2 digits of 2127 is divisible by 3


Q14

def V_Age(A):
if A>=18:
return 1
return 0

Age=int(input("Enter the Age : "))


X=V_Age(Age)
if X==1:
print("Age is Valid for driving Licence")
else:
print(F"wait for {18-Age} years")

...output

Enter the Age : 12


wait for 6 years
Q15

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"

Age=int(input("Enter your Age : "))


Gender=input("Enter your Gender(M/F) : ")
if Gender is "Mm":
F=M_Age(Age)
else:
F=F_Age(Age)
print(F"Your Floor is : {}")

...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

M1=int(input("Enter the No1 :"))


M2=int(input("Enter the No2 :"))
M3=int(input("Enter the No3 :"))
M4=int(input("Enter the No4 :"))
M5=int(input("Enter the No5 :"))
X=H_S(M1,M2,M3,M4,M5)
print(F"The highest score is {X[0]} and the second
highest score is {X[1]}")

...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

M1=int(input("Enter the No1 :"))


M2=int(input("Enter the No2 :"))
M3=int(input("Enter the No3 :"))
M4=int(input("Enter the No4 :"))
M5=int(input("Enter the No5 :"))
X=H_L(M1,M2,M3,M4,M5)
print(F"The highest score is {X[0]} and the lowest
score is {X[1]}")

...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

You might also like