Advertisement
GamerBhai02

DS Exp 2

Mar 12th, 2025 (edited)
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | Source Code | 0 0
  1. #!/usr/bin/env python
  2. # coding: utf-8
  3.  
  4. # In[85]:
  5.  
  6.  
  7. import pandas as pd
  8. import matplotlib.pyplot as plt
  9. import numpy as np
  10. import seaborn as sns
  11.  
  12.  
  13. # In[86]:
  14.  
  15.  
  16. d1 = np.random.normal(100,10,200)
  17. d2 = np.random.normal(90,20,200)
  18. d3 = np.random.normal(80,30,200)
  19. d4 = np.random.normal(70,40,200)
  20. data = [d1,d2,d3,d4]
  21.  
  22.  
  23. # In[87]:
  24.  
  25.  
  26. fig = plt.figure(figsize=(5,3))
  27. ax = fig.add_axes([0,0,1,1])
  28. bp = ax.boxplot(data,vert=False)
  29. plt.show()
  30.  
  31.  
  32. # In[88]:
  33.  
  34.  
  35. x = np.random.normal(10,100,20)
  36. y = np.random.normal(20,90,20)
  37. plt.scatter(x,y)
  38. plt.show()
  39.  
  40.  
  41. # In[89]:
  42.  
  43.  
  44. arr = np.random.normal(10,100,20)
  45. fig,ax = plt.subplots(figsize=(7,4))
  46. ax.hist(arr,bins=[25,50,75,100])
  47. plt.show()
  48.  
  49.  
  50. # In[90]:
  51.  
  52.  
  53. data = {'Maths':90,'Physics':85,'Chemistry':95,'English':100}
  54. subjects = list(data.keys())
  55. marks = list(data.values())
  56. fig = plt.figure(figsize=(7,4))
  57. plt.bar(subjects,marks,color='silver',width=0.4)
  58. plt.xlabel("Subjects")
  59. plt.ylabel("Marks")
  60. plt.show()
  61.  
  62.  
  63. # In[91]:
  64.  
  65.  
  66. name = ['Alice', 'Bob', 'Charlie', 'Diana', 'Ethan', 'Fiona', 'George']
  67. age = [12, 23, 15, 18, 9, 14, 9]
  68. fig = plt.figure(figsize=(8,5))
  69. plt.pie(age,labels=name)
  70. plt.show()
  71.  
  72.  
  73. # In[92]:
  74.  
  75.  
  76. data = np.random.randint(low=1,high=100,size=(7,7))
  77. sns.heatmap(data,cmap='Greens',annot=True)
  78. plt.show()
  79.  
  80.  
Tags: Exp 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement