Program5-Write To Make A Program A Pattern by Using While Loop: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
Program5-Write To Make A Program A Pattern by Using While Loop: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
1
12
123
1234
12345
Programming:-
n=5
for i in range(n):
for j in range(n-i-1):
print(" ",end=" ")
for j in range(i+1):
print(j+1,end=" ")
print( )
Program6- Write a program to make a list of 10 elements by using user input. Search an
element by user’s choice by using linear search.
Programming:-
Programming:-
𝑥+ !
+ !
+ ⋯.
Programming:-
Programming:-
D={}
n=int(input("Enter number of items in the dictionary"))
for i in range(1,n+1):
a=input("Enter value of key")
D[i]=a
print('Dictionary=',D)
b=D.keys()
c=D.values()
print("The output of keys():",b)
print("The output of values():",c)
d=int(input('Enter the key of that item which have to be deleted'))
pop=D.pop(y)
p=D.popitem()
print("The output of pop():",pop)
print("The output of popitem():",p)
Program10- Write a program to create a dictionary in which key value pair is your subject(key)
and marks(values) of 10th class. Find out the sum and percentage of your marks and conclude
your division according to given data:
60%-100% - 1st
45%-59% -2nd
33%-44%-3rd
Show your maths and science marks separately. If you got 75% in these two subject. Then leave
a message “You are eligible to take PCM in class11th” otherwise not.
Programming:-
Programming:-
Programming:-
h=float(input("height of cone="))
r=float(input("radius of cone="))
l=(h**2+r**2)**(1/2)
π=3.14
CSA=π*r*l
TSA=π*r*(l+r)
Volume=(π*h*r**2)*1/3
print("CSA of cone=",CSA)
print("TSA of cone=",TSA)
print("volume of cone=",Volume)
INDEX
1. Write a program to draw a pattern of your name in given format by using for
loop.
1
12
123
1234
𝑥+ + + ⋯.
! !