0% found this document useful (0 votes)
8 views

Assignment

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Assignment

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Assignment(VII)

Q1)
Code:
orignalarray=[1,3,5,3,7,1,9,3]

print(orignalarray)

for i in orignalarray:

if i==3:

orignalarray.remove(i)

break

print(orignalarray)

Solution:
[1, 3, 5, 3, 7, 1, 9, 3]
[1, 5, 3, 7, 1, 9, 3]

Q2)
Code:
a=[]

for i in range(6):

b=int(input('enter elements in array'))

a.append(b)

print(a)

Solution:
enter elements in array10
enter elements in array20

enter elements in array30

enter elements in array40

enter elements in array50

enter elements in array60

[10,20,30,40,50,60]

Q3)
Code:
d=[1,2,3,4,4,5]

print(len(d))

Solution:
6

Q4)
Code:
orignalarray=[1,3,5,3,7,1,9,3]

a=int(input('enter no to check='))

count=0

for i in orignalarray:

if i==a:

count=count+1

print(count)

Solution:
enter no to check=3
2

Q5)
Code:
pi=22/7

radian = float(input("Input radians: "))

degree = radian*(180/pi)

print(degree)

Solution:
Input radians: .52
29.78181818181

Q6)
Code:
import math

r=int(input('enter radius='))

angle=int(input('enter angle of sector in degree='))

area=(angle/360)*(math.pi)*r**2

print('area= %f' % area)

Solution:
enter radius=4

enter angle of sector in degree=45

area=6.283185

Q7)
Code:
n=int(input('enter n='))

s1=0

s2=0

for i in range(n+1):

s1=s1+i

s2=s2+i**2

difference=s1**2-s2

print(difference)

Solution:
enter n=12
5434

Q8)
Code:
import matplotlib.pyplot as plt

over=[1,2,3,4,5,6]

runs=[20,12,14,22,23,25]

plt.bar(over,runs,color='r')

plt.xlabel('over')

plt.ylabel('runs')

Solution:
Q9)
Code:
import matplotlib.pyplot as plt

import numpy as np

x = np.array([1, 2, 3, 4])

y = np.array([2,3,1,5])

plt.plot(x, y,'--')

plt.xlabel("X-axis")

plt.ylabel("Y-axis")

plt.title("line graph")
plt.show()

Solution:

Q10)
Code:
import matplotlib.pyplot as plt

import numpy as np

cars = ['AUDI', 'BMW', 'FORD',

'TESLA', 'JAGUAR', 'MERCEDES']

data = [23, 17, 35, 29, 12, 41]

explode=[0,0.1,0,0,0,0]

plt.pie(data, labels=cars,explode=explode)

plt.show()
Solution:

You might also like