PYTHON....

SOLUTION.....

  1. Create a dataframe using lists.                                   
  2. Display books for class XII.                                                    
  3. Display the books whose price is more than 250.                                                    
  4. Plot these data on line chart. 

OUTPUT…..

import pandas as pd
import matplotlib.pyplot as plt
#Answer 1
data={'BookID':['B0001','B0002','B0003','B0004','B0005','B0006'],\
      'Subject':['Computer Science','Computer Science','Computer Appllications',\
      'Informatics Practices','Artificial Intelligence','Informatics Practices'],\
      'Class':['XII','XII','X','XII','IX','XII'],\
      'Publisher':['NCERT','Dhanpat Rai','BPB','NCERT','KIPS','Oswal books'],\
      'Price':[270,340,120,270,340,299]}
books=pd.DataFrame(data)
print(books)

#Asnwer 2
print("Class XII Books:")
print(books[books['Class']=='XII'].to_string(header=False,index=False))
print("***********************************************************")

#Asnwer 3
print("Books having price more than 250")
print(books[books['Price']>250].to_string(header=False,index=False))

#Answer 4
books.plot(x='Subject',y='Price',kind='bar',color=["green","blue","black"])
plt.show()


Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.