Python Practical Questions
Artificial Intelligence – Grade 10
Q1. Write a python program to plot a line chart based on the given data to
depict the Monthly scoring rate of a batsman for four months and also assign
suitable labels and title.
Month=[1,2,3,4]
Scoring rate=[140,132,148,164]
Source Code:-
import matplotlib.pyplot as plt
Month=[1,2,3,4]
Scoring_rate=[140,132,148,164]
plt.xlabel('Month')
plt.ylabel('Scoring rate')
plt.plot(Month,Scoring_rate)
plt.show()
Output-
Q2. Write a python program to plot a line chart based on the given data to
depict the medal tally between four Houses in school.
House=['Shivaji', 'Tagore', 'Raman', 'Ashoka']
Medal_count=[50,60,40,55]
Source Code:-
import matplotlib.pyplot as plt
House=['Shivaji', 'Tagore', 'Raman',
'Ashoka'] Medal_count=[50,60,40,55]
plt.ylabel(“ House names")
plt.xlabel("Medal_count)
plt.plot(House,Medal_Count)
plt.show()
Output-
Q3. Write a program to create a bar chart for India's medal tally.
Info = ['Gold', 'Silver', 'Bronze', 'Total']
India = [26, 20, 20, 66]
i. X axis Label –Medal count
ii. Yaxis Label-Medal Type
Source Code:-
import matplotlib.pyplot as plt
Info = ['Gold', 'Silver', 'Bronze', 'Total']
India = [26, 20, 20, 66]
plt.xlabel('Medal Count')
plt.ylabel('Medal type')
plt.bar(Info,India)
plt.show()
Output-
Q4. Write a program to create a bar chart for House detail with the following
specifications:
i. X axis Label –House
ii. Yaxis Label-Strength
iii. Gridlines must be visible
(* Assume your own values for houses names and strength)
Source Code:-
import matplotlib.pyplot as plt
House = ['Tagore House' , 'Gandhi House' , 'Nehru House' ,'Bose House' ]
Strength=[20,35,56,41]
plt.xlabel("House")
plt.ylabel("Strength")
plt.bar(House,Strength)
plt.show()
Output-
Q5. Take a list of temperature for a week and find:
X = [36.5, 38, 41, 37, 35.6, 35.2, 36.8]
● Mean
● Median
● Mode
Source Code:-
import statistics as st
x=[36.5,38,41,37,35.6,35.2,36.8]
print("Mean:", st.mean(x))
print("Median:", st.median(x))
print("Mode:", st.mode(x))
output-
Mean: 37.15714285714286
Median: 36.8
Mode: 36.5
Q6. Write a program to enter principal, rate and amount and find simple interest.
Q7. Write a program to find area of rectangle and square.
Q8. Write a program to find the area of triangle.
Q9. Write a program to enter age of a person and check if he/ she is eligible for
voting.
Q10 write a program to enterstu percentage of a student and if he scores <33 then
print fail else pass.