[go: up one dir, main page]

0% found this document useful (0 votes)
22 views12 pages

23IT3036 Samarth Assignment-5

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 12

ASSIGNMENT-5

QUESTION-1
CODE-1
a=int(input("Enter length"))
b=int(input("Enter breadth"))
area=a*b
perimeter=2*(a+b)
print("area is ",area)
print("Perimeter is ",perimeter)
OUTPUT-1

QUESTION-2
CODE-2
a=int(input("Enter first number"))
b=int(input("Enter second nuber"))
multiply=a*b
add=a+b
divide=a/b
subtract=a-b
modulous=a%b
print("multiplication is ",multiply)
print("addition is ",add)
print("division is ",divide)
print("subtraction is ",subtract)
print("modulous is ",modulous)
OUTPUT-2
QUESTION-3
CODE-3
p=int(input("Enter principle "))
r=float(input("Enter rate "))
t=float(input("Enter time "))
si=(p*r*t)/100
print("simple interest is ",si)
OUTPUT-3

QUESTION-4
CODE-4
c=int(input("Enter Temperature in celsius "))
f=(9/5)*c+32
print("Temperature converted in faherenhiet ",f)
OUTPUT-4

QUESTION-5
CODE-5
r=int(input("Enter Radius of the circle "))
d=r*2
area=3.14*r*r
peri=2*3.14*r
print("Diameter of circle is ",d)
print("Area of circle is ",area)
print("Perimeter of circle is ",peri
OUTPUT-5
QUESTION-6
CODE-6
a=int(input("Enter a number "))
sum=0
for i in str(a):
sum=sum+int(i)

print("Sum of digits is ",sum)


OUTPUT-6

QUESTION-10
CODE-10
n=int(input("Enter number of rows "))

for i in range(0,n):
for j in range(0,n):
print("*",end=" ")
n=n-1
print("\n")
OUTPUT-10

QUESTION-8
CODE-8

#Inputing First Mattrix


l=[]
print("Enter first matrix ")
r=int(input("Enter number of rows "))
c=int(input("Enter number of columns "))
for i in range(0,r):
m=[]
print("Enter elements for row ",i+1)
for j in range(0,c):
a=int(input(" "))
m.append(a)
l.append(m)
print(l)
#Inputing Second Mattrix
L=[]
print("Enter second matrix ")
R=int(input("Enter number of rows "))
C=int(input("Enter number of columns "))
for I in range(0,R):
M=[]
print("Enter elements for row ",I+1)
for J in range(0,C):
A=int(input(" "))
M.append(A)
L.append(M)
print(L)

add=0
if (c==R):
H=[]
h=[]
for k in range(0,r):
for j in range(0,C):
for m in range(0,R):
s=l[k][m]*L[m][j]
add=add+s
H.append(add)
add=0
h.append(H)
H=[]
print("Multiplied matrix is ")
for i in range(0,len(h)):
print(h[i])
if (c!=R):
print("Matrix multiplication not possible ")
OUTPUT-8

QUESTION-9
CODE-9
#Inputing a Mattrix
l=[]
print("Enter first matrix ")
r=int(input("Enter number of rows "))
c=int(input("Enter number of columns "))
for i in range(0,r):
m=[]
print("Enter elements for row ",i+1)
for j in range(0,c):
a=int(input(" "))
m.append(a)
l.append(m)
print("Entered matrix is ")
for i in range(0,len(l)):
print(l[i])
#Transposing Matrix
t=[]
h=[]
for i in range(0,c):
for j in range(0,r):
k=l[j][i]
h.append(k)
t.append(h)
print("Transpose of matrix is ")
for m in range(0,len(t)):
print(t[m])

OUTPUT-9

QUESTION-11
CODE-11
n=int(input("enter a number"))
print("Prime number factors are ")
flag=True
for i in range(2,n):
if (n%i==0):
for j in range(2,i):
if (i%j!=0):
flag=True
else:
flag=False
if flag==True :
print(i)
else:
continue
else:
continue

OUTPUT-11

QUESTION-12
CODE-12
n=int(input("Enter a number of elements you want to enter "))
l=[]
check=((n+1)*(n+2))/2
print("Enter numbers ")
for i in range(0,n):
k=int(input(""))
l.append(k)
sum=0
for i in l:
sum=sum+i
if sum==check:
print("All numbers are entered ")
else:
num=check-sum
print("mising number is ",num)

OUTPUT-12

You might also like