Informatics practical., Assignments of Computer science

This will all about the project that is based on the informatics practical.

Typology: Assignments

2020/2021

Uploaded on 03/03/2021

chinky-kumari
chinky-kumari 🇲🇬

1 document

1 / 34

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pg. 1
INFORMATICS
PRACTICES
PRACTICAL FILE
AKSHAT AGARWAL
4323
ROLL NO. 4
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22

Partial preview of the text

Download Informatics practical. and more Assignments Computer science in PDF only on Docsity!

INFORMATICS

PRACTICES

PRACTICAL FILE

AKSHAT AGARWAL 4323 ROLL NO. 4

Q.1 WRITE A PROGRAM THAT CALCULATES THE FOLLOWING:

. AREA OF A CIRCLE

.CIRCUMFERENCE OF A CIRCLE

.AREA OF RECTANGLE

.PERIMETER OF A RECTANGLE

PROGRAM:

while True: print('1. for area of circle') print('2. for area of rectangle') print('3. for circumference of circle') print('4. for area of square') ch=int(input('enter your choice:enter 0 to exit')) if ch==1: r=int(input('enter the radius of the circle:')) a=3.14rr print('area of circle:',a) elif ch==2: l=int(input('enter the length:')) b=int(input('enter the breath:')) a=lb print('area of rectangle:',a) elif ch==3: r=int(input('enter the radius of the circle:')) c=2(int(3.14*r))

PYTHON

maxlength=x maxword=i print('substring with maximum length is:',maxword) OUTPUT: Q.3 WRITE A PROGRAM T0 CHECK WHETHER THE STRING IS A PALINDROME OR NOT. PROGRAM: str=input('enter the string:') l=len(str) p=l-l index= while(index<p): if(str[index]==str[p]): index=index+ p=p- else: print('string is not a palindrome') break else: print('string is a palinndrome')

OUTPUT:

Q.4 WRITE A PROGRAM TO STORE STUDENTS INFORMATION

LIKE ADMISSION NUMBER, ROLL NO. , NAME AND MARKS IN A

DICTIONARY AND DISPLAY INFORMATION ON THE BASIS OF

ADMISSION NO.

PROGRAM:

SCL=dict() i= flag= n=int(input('enter number of entries:')) while i<=n: adm=input('\nenter admission no. of a student:') nm=input('enter name of the student') section=input('enter class and section:') per=float(input('enter the percentage of a student')) b=(nm,section,per) SCL[adm]=b l=SCL.keys() for i in l: print('\nadmno-',i,':') z=SCL[i] print('name\t','class\t','per\t') for j in z:

Q.6 WAP USING PYPLOT TO PLOT A LINE CHART TO DEPICT THE

CHANGING WEEKLY ONION PRICES FOR FOUR WEEKS.

PROGRAM:

import matplotlib.pyplot as plt weeks=(1,2,3,4) prices=(25,30,60,40) plt.plot(weeks,prices,'r-.') plt.xlabel('no. of weeks') plt.ylabel('prices of onion') plt.title('change in price of onion') plt.show() OUTPUT: Q.7 First 10 terms of a Fibonacci series in a list namely fib:

fib=[0,1,1,2,3,5,8,13,21,34] WAP to plot Fibonacci terms and their square roots with two separate lines on the same plot. · The Fibonacci series should be plotted as a cyan line with ‘o’ markers having size as ‘5’ and edge-color as red PROGRAM: import matplotlib.pyplot as plt fib=(0,1,1,2,3,5,8,13,21,34) x=(1,2,3,4,5,6,7,8,9,10) sq=(0,1,1,4,9,25,64,169,441,1156) plt.plot(x,fib,color='cyan',marker='o',markersize=5,markeredg ecolor="red",label='fibonnaci series') plt.plot(x,sq,color='black',marker='+',markersize=7,markeredg ecolor="red",label='its square') plt.legend() plt.xlabel('no. os series') plt.ylabel('squares and series')

plt.ylabel("height") plt.title("painting") plt.show() OUTPUT: Q.9 Cosider the reference table given above and write a program to plat a bar chart from the medals won by Australia. PROGRAM: import matplotlib.pyplot as plt medals=('gold','silver','bronze') x=(1,2,3) y=(80,59,59) plt.bar(x,y,color='red') plt.xticks(x,medals) plt.title('Medals won my australia') plt.xlabel('medals categories')

plt.ylabel('no. of medals') plt.show() OUTPUT: Q.10 Cosider the reference table given above and write a program to plat a bar chart from the medals won by India. Make sure that the Gold, Silver, Bronze and Total tally is represented through different colours. PROGRAM: import matplotlib.pyplot as plt plt.xkcd() x=(1) y=(26) x1=(2)

plt.show() OUTPUT: Q.11 Cosider the reference table given above and write a program to plat a bar chart from the medals won by top four countries. Make sure that bars are separately visible. PROGRAM: import matplotlib.pyplot as plt medals=('gold','silver','bronze') x=(1,2,3) y=(80,59,59) x1=(1,2,3) y1=(45,45,46) x2=(1,2,3)

y2=(26,20,20) x3=(1,2,3) y3=(15,40,27) plt.subplot(4,1,1) plt.bar(x,y,color='red') plt.title('AUSTRALIA') plt.xticks(x,medals) plt.subplot(4,1,2) plt.bar(x1,y1,color='yellow') plt.title('ENGLAND') plt.xticks(x,medals) plt.subplot(4,1,3) plt.bar(x2,y2,color='blue') plt.title('INDIA') plt.xticks(x,medals) plt.subplot(4,1,4) plt.bar(x3,y3,color='green') plt.title('CANADA') plt.xlabel('medals categories') plt.tight_layout() plt.xticks(x,medals) plt.show() OUTPUT:

Q.13 WAP that gathers height and weights of 100participants and recorded participants ages as : ages= [1,1,2,3,……………………..100 values](take any random values) WAP to plot a histogram from above data with 20 bins. PROGRAM: import matplotlib.pyplot as plt import numpy as np

ages=np.random.randn(100) wieght=np.random.randn(100) plt.hist(ages,bins=20,weights=wieght,edgecolor='red',facecolo r='blue') plt.xlabel('ages') plt.ylabel('wieghts') plt.title('wieghts of 100 students') plt.show() OUTPUT: Q.14 WAP TO PLOT A HISTOGRAM OF RANDOM VALUES. PROGRAM: import matplotlib.pyplot as plt import numpy as np

Q.16 WAP TO CREATE A SERIES AS S WITH INDEX AS [A,B,C,D]

AND VALUES AS [10,20,30,40].

PROGRAM:

import pandas as pd s=pd.Series([10,20,30,40],index=['a','b','c','d']) print(s) OUTPUT: Q.17 WAP TO CREATE SERIES USING ARANGE FUNCTION OF NP ARRAY.

PROGRAM:

import pandas as pd import numpy as np s=pd.Series(np.arange(2,7)) print(s) OUTPUT: Q.18 WAP TO PERFORM ARTHEMETIC OPERATIONS ON SERIES. PROGRAM: import pandas as pd s1=pd.Series([1,2,3,4,5]) s2=pd.Series([3,4,5,6,7]) s3=pd.Series([5,6,7,8,9]) r1=s1+s print('sum') print(r1) r2=s1-s print('difference') print(r2) r3=s1*s print('multiplication') print(r3)