# To Add The 4Th Record in Dataframe
# To Add The 4Th Record in Dataframe
4
ROLL NAME MARKS
0 101 RAM 93
1 102 SOHAN 82
2 103 KISHAN 66
3 104 NISHANT 75
(i) Create the above DataFrame named student by importing data from a CSV file.
(ii) Add the following record in the above DataFrame. 4, 105, ‘HARSH’, 59
(iii) Store the updated DataFrame into csv file.
(iv) Display the marks detail of Roll no 103.
Ans. 1
import pandas as pd
student=pd.read_csv("C:\\Users\\xiib23\\Desktop\\df.csv")
print(student)
# TO ADD THE 4TH RECORD IN DATAFRAME
student.loc[4,:]=[105,'HARSH',59]
print(student)
#STORING UPDATED DATFRAME INTO CSV
student.to_csv("C:\\Users\\xiib23\\Desktop\\ankit.csv")
# Display the mark detail of roll no. 103
s=student.iloc[2:3,2:3]
print(s)
OUTPUT:
(i)
ROLLNO NAME MARKS
0 101 RAM 93
1 102 SOHAN 82
2 103 KISHAN 66
3 104 NISHANT 75
(ii)
ROLLNO NAME MARKS
0 101.0 RAM 93.0
1 102.0 SOHAN 82.0
2 103.0 KISHAN 66.0
3 104.0 NISHANT 75.0
4 105.0 HARSH 59.0
ankit.csv
(iii)
(iv) MARKS
2 66.0
Q.2. Write a Python program to generate a line chart for the following information: 4
Programming languages: Java, Python, PHP, JavaScript, C#, C++
Popularity: 22.2, 17.6, 8.8, 8, 7.7, 6.7
(i) The line must be show with proper colour, width and marker.
(ii) There Should be proper labels for X and Y axis with their properties.
(iii) The Title of the chart should be ‘Worldwide Popularity of Programming Language ‘.
(iv) Draw the Chart generated in your PC in the Answer Sheet.
Ans - 2
import matplotlib.pyplot as plt
lang = ['Java', 'Python', 'PHP', 'JavaScript', 'C#', 'C++']
popularity = [22.2, 17.6, 8.8, 8, 7.7, 6.7]
plt.plot(lang, popularity, color = 'green', linewidth = 5, linestyle = ‘solid’, marker ='D', markersize = 5,
markeredgecolor = 'red')
plt.xlabel("Programming Languages", fontsize=10, color=’red’)
plt.ylabel("Popularity", fontsize=10, color=’blue’)
plt.title("Worldwide Popularity of Programming Language ", fontsize=20, color=’green’)
plt.show()
Q3. Consider the following table (salesperson) and Write SQL queries for following: 7
SID Name DOB Salary Zone
S101 Ankit 1981-01-22 65000 North
S102 Bhavya 1984-10-19 75000 South
S103 Bhumi 1983-12-04 64000 East
S104 Vruti 1988-04-05 45000 West
S105 Vikas 1987-05-02 58000 South