Ractical I and O
Ractical I and O
Python Program in Jupyter Notebook 12: Python program to find the sum of digits in a
number.
INPUT
n=int(input("Enter a number:"))
tot=0
while(n>0):
dig=n%10
tot=tot+dig
n=n//10
print("The total sum of digits is :",tot)
OUTPUT
Enter a number:5555
The total sum of digits is : 20
Python Program in Jupyter Notebook 13: Python program to reverse a given number.
INPUT
n=int(input("Enter a number:"))
rev=0
while(n>0):
dig=n%10
rev=rev*10+dig
n=n//10
print("The total sum of digits is :",rev)
OUTPUT
Enter a number:1234567
The total sum of digits is : 7654321
print("Mean is:",(statistics.mean(datasets)))
print("Median of data-set is:",(statistics.median(datasets)))
print("Mode of data-set is:",(statistics.mode(datasets)))
print("Standard Deviation of data-set is:",(statistics.stdev(datasets)))
print("Calculated variance of data-set is:",(statistics.variance(datasets)))
OUTPUT
Mean is: 5.857142857142857
Median of data-set is: 6
Mode of data-set is: 5
Standard Deviation of data-set is: 2.410295378065479
Calculated variance of data-set is: 5.809523809523809
Python Program in Jupyter Notebook 16: Draw a Line Graph in Python using
Matplotlib.
INPUT
# importing matplotlib module
from matplotlib import pyplot as plt
# x-axis values
x = [5,2,9,4,7]
# y-axis values
y = [10,5,8,4,2]
# Function to plot
plt.plot(x,y)
# Function to show the plot
plt.show()
OUTPUT
Python Program in Jupyter Notebook 17: Draw a Bar Graph in Python using
Matplotlib.
INPUT
# importing matplotlib module
from matplotlib import pyplot as plt
players=['Virat','Rohit','Shikhar','Hardik']
runs=[91,47,75,31]
plt.bar(players,runs,color='orange')
plt.title('Score Card')
plt.xlabel('Players')
plt.ylabel('Runs')
plt.show()
OUTPUT
Python Program in Jupyter Notebook 18: Draw a Pie Chart in Python using Matplotlib.