Posts

Showing posts from March, 2022

How to calculate Mean, Median and Mode in python

#CALCULATE MEAN import numpy as np speed = [ 99 , 86 , 87 , 88 , 111 , 86 , 103 , 87 , 94 , 78 , 77 , 85 , 86 ] x = np. mean (speed) print (x) #CALCULATE MEDIAN import numpy as np speed = [ 99 , 86 , 87 , 88 , 111 , 86 , 103 , 87 , 94 , 78 , 77 , 85 , 86 ] x = np. median (speed) print (x) #CALCULATE MODE from scipy import stats speed = [ 99 , 86 , 87 , 88 , 111 , 86 , 103 , 87 , 94 , 78 , 77 , 85 , 86 ] x = stats. mode (speed) print (x)

How to use Matplotlib markers

import numpy as np import matplotlib.pyplot as plt ypoints = np. array ([ 3 , 4 , 10 , 12 ]) #for solid line #plt.plot(ypoints, '-') #for dashed line #plt.plot(ypoints,'--') #for dashed and dotted lines #change the colour and size of the marker #plt.plot(ypoints,marker = 'o',ms=20,mec='r') #change the face colour to red plt. plot (ypoints, marker = 'o' , ms = 20 , mfc = 'g' ) plt. show ()

Line chart in python

import matplotlib.pyplot as plt import numpy as np x = np. array ([ 1 , 8 , 7 , 6 , 5 , 4 ]) y = np. array ([ 3 , 10 , 12 , 13 , 23 , 17 ]) #plot dots instead of a line #plot stars plt. plot (x,y, "--" ) plt. show ()

How to generate bar chart in python

import matplotlib.pyplot as plt import numpy as np x = np. array ([ "A" , "B" , "C" , "D" ]) y = np. array ([ 4 , 5 , 3 , 7 ]) #change colour #horizontal bars plt. barh (x,y, color = "g" ) plt. show ()

8-Bit adder circuit diagram

Image
 8-Bit Adder circuit on Proteus