INDEX
Q1: - WAP to draw a pattern of your name in the given format by using loop.
A
AB
ABC
Q2: - WAP to input three values as sides of a triangle. Check, it is equilateral,
isosceles, scalene and right-angled triangle. Also find the area and perimeter of
the triangle formed.
Q3: - WAP to accept the values of height and radius of a triangle. And find it’s
C.S.A., T.S.A. and Volume.
Q4: - WAP to satisfy the equation for trigonometric identity sin 2 θ + cos 2 θ =1.
Q5: - WAP to make a pattern using while loop.
1
12
123
1234
12345
Q6: - WAP to make a list of 10 elements by using user input. Search an element
by user’s choice by using linear search.
Q7: - WAP to make a dictionary by user’s choice, apply pop(), key(), values()
and popitem() function it. After applying every function generate separate
output for each method.
Q8: -WAP to find the sum of the given series upto 10 terms.
x + (x2/2!) + (x3/3!)…
Q9: - WAP to make a mini-ATM machine in which 5 major function is to be
included.
• Enter pin if correct then enter for other function.
• Withdraw
• Mini statement
• Check last balance
• Change pin
Q10: - Write a program to make a dictionary in which key(value) pair is
marks(value). Find out the sum and percentage of the marks and conclude your
division according to the given data.
• 1st division= 100%-60%
• 2nd division= 59%-45%
• 3rd division= 44%-33%
Show your science and maths marks separately if you got 75% marks in these 2
subjects then leave a message, “You are eligible to take PCM in class11”
otherwise not eligible.
~OUTPUT~
Q1:- Write a program to draw a pattern of your name in given format by using
loop:
A
AB
ABC
~INPUT~
name='VINAMRA'
for i in range(len(name)):
for j in range(i+1):
print(name[j], end=' ')
print()
~OUTPUT~
Q2:- Write a program to input 3 values as sides of a triangle. Check, if it is
equilateral, isosceles, scalene or right angle triangle. Also, find the area and
perimeter of the triangle formed.
~INPUT~
a=int(input("Enter the length of side a:"))
b=int(input("Enter the length of side b:"))
h=int(input("Enter the length of side h:"))
if a==b==h:
print('The given triangle is Equilateral Triangle')
elif a==b!=h or b==h!=a or a==h!=b:
print('The given triangle is Isosceles Triangle')
elif a!=b!=h:
print("The given triangle is a Scalene Triangle")
if h**2 == a**2 + b**2:
print('The given triangle is a right angled triangle')
else:
print('The given triangle is a non-right angled triangle')
print('Perimeter of the triangle=Sum of sides of a Triangle')
P=a+b+h
print('Perimeter of the given triangle=',P)
S=P/2
print('Area of a triangle=[S*(S-a)*(S-b)*(S-h)]**0.5')
Ar=(S*(S-a)*(S-b)*(S-h))**0.5
print('Area of the given triangle=',Ar)
~OUTPUT~
Q3:- Write a program to accept the values of height and radius of a cone and
find it’s C.S.A, T.S.A and Volume.
~INPUT~
h=int(input('Enter the height of the cone:'))
r=int(input('Enter the radius of the cone:'))
l=(r**2+h**2)**0.5
CSA=(22/7)*r*l
print('The CSA of the cone is:',CSA)
TSA=(22/7)*r*(r+l)
print('The TSA of the cone is: ', TSA)
Volume=(1/3)*(22/7)*(r**2)*h
print('The Volume of the cone is :', Volume)
~OUTPUT~
Q4:- Write a program to satisfy the value for trigonometric identities:
sin 2 θ + cos 2 θ =1
~INPUT~
import math
theta = 45 # degrees
theta = [Link](theta) # convert degrees to radians
sin_theta = [Link](theta)
cos_theta = [Link](theta)
result = sin_theta**2 + cos_theta**2
print(f"The value of sin²θ + cos²θ is {result}")
~OUTPUT~
Q5:- Write a program to make a pattern using while loop:
1
12
123
1234
12345
~INPUT~
n=5
i=1
while i <= n:
spaces = n - i
while spaces > 0:
print(' ', end='')
spaces -= 1
j=1
while j <= i:
print(j, end='')
j += 1
print()
i += 1
~OUTPUT~
Q6:- Write a program to make a list of 10 elements by using user’s input.
Search an element by user’s choice by using linear search.
~INPUT~
print(' creating a list of 10 elements using user input')
lst = []
for i in range(0,10):
n=int(input('Enter elements:'))
[Link](n)
print(lst)
print(" search for an element of the user's choice using linear search")
search_element = int(input("Enter the element to search: "))
found = False
for i in range(len(lst)):
if lst[i] == search_element:
print('Element', search_element," found at index", i)
found = True
break
if not found:
print("element not found in the list")
~OUTPUT~
Q7:- Write a program to make a dictionary by user’s choice, apply pop(),
key(), values() and pop item() function on it.
After applying every function generate separate output for each method.
~INPUT~
n=int(input('Enter the number of key value pairs that you want to add to the
dictionary:'))
d=dict()
for i in range (n):
key=input('Enter the key:')
value=input('Enter the value:')
d[key]=value
print(d)
d1=[Link]('2')
print(d1)
d2=[Link]()
print(d2)
d3=[Link]()
print(d3)
d4=[Link]()
print(d4)
~OUTPUT~
Q8:- Write a program to find the sum if the given series upto 10 terms:
x+(x2/2!)+(x3/3!)………………
~INPUT~
import math
x=int(input("Enter the value of your choice for the variable 'x':"))
sum = 0
for i in range(1, 11):
term = x ** i / [Link](i)
sum += term
print(f"The sum of the series up to 10 terms is {sum}")
~OUTPUT~
Q9:- Write a program to make a mini ATM machine in which 5 major functions
are to be included:
• Enter pin if correct then enter for other function.
• Withdraw
• Mini statement
• Check last balance
• Change pin
~INPUT~
account_default=17082007
name='Vinamra Semwal'
Account=int(input('Enter you account number:'))
A=20000
default_PIN=1234
n=input('Enter your name registered with this account:')
if account_default==Account and name==n:
print('Welcome',n)
for i in range(0,3):
PIN=int(input('Enter the PIN:'))
if default_PIN == PIN:
print('The entered PIN is correct')
a=int(input('Enter the amout to be Withdrawn:'))
ad=A-a
if A>a:
print('The withdrawn amount will be processed by the ATM machine
soon.’)
print('The amount withdrawn:',a,'Rupees')
print('The remmaining amount is:', ad,"Rupees")
if A<a:
print("You don't have enough amount of money in your account:")
print('MONEY RECIEPT'.center(120))
print('Account number:',Account)
print('Name of the Account Holder:',n)
print('Amount of money Withdrawn:',a,'Rupees')
print('Balance left in the Account:',ad,'Rupees')
c=input('Would you like to change your PIN from default to the PIN of
your choice(YES/NO):')
print(c)
if c=='YES':
nPIN=input('Enter your new PIN:')
temp=default_PIN
default_PIN=nPIN
nPIN=temp
print('Your PIN was changed from default to the PIN of your
choice.','Your new PIN is:',default_PIN)
if c=='NO':
print('You denied the request for changing the PIN.',"Your PIN didn't
get changed”)
break
else:
print('The entered PIN is incorrect, TRY AGAIN, Number of chances
left to enter the correct pin:',2-i)
else:
print('WE ARE UNABLE TO FIND YOUR ACCOUNT')
~OUTPUT~
Q10: - Write a program to make a dictionary in which key(value) pair is
marks(value). Find out the sum and percentage of the marks and conclude your
division according to the given data.
• 1st division= 100%-60%
• 2nd division= 59%-45%
• 3rd division= 44%-33%
Show your science and maths marks separately if you got 75% marks in these 2
subjects then leave a message, “You are eligible to take PCM in class11”
otherwise not eligible.
~INPUT~
n=int(input('Enter the number of subjects:'))
d=dict()
for i in range(n):
key=input('Enter the name of the subject:')
value=int(input('Enter the marks in subject:'))
d[key]=value
print(d)
sum_d=sum([Link]())
print(sum_d)A
per=(sum_d/n)
print('Your percentage=',per, '%')
if 100>=per>=60:
print('CONGRATULATIONS!!','You have gained 1st division.')
if 59>=per>=45:
print('You have gained 2nd division.')
if 44>=per>=33:
print('You have gained 3rd division.')
s=int(input('Enter your marks in Science:'))
m=int(input('Enter your marks in Maths:'))
if m>=75 and s>=75:
print('YOU ARE ELIGIBLE FOR TAKING PCM AS YOUR MAIN
SUBJECTS')
else:
print('YOU ARE NOT ELIGIBLE FOR TAKING PCM AS YOUR MAIN
SUBJECTS')