Statistics and Analytics - Unit 4 - Python Experiments 1
Statistics and Analytics - Unit 4 - Python Experiments 1
20. Write a python program to add 2 integers and 2 strings and print the result.
Example 1:
c=a+b
print("SUM=",c)
Example 2:
# Program to add two integer numbers with user input
x = input ("Type a number: ")
y = input ("Type another number: ")
Example 1:
s3 = s1 + s2
print(s3)
Example 2:
# Program to add two strings with user input
s1 = input ("Type first string: ")
s2 = input ("Type second string: ")
s3 = s1 + s2
print (s3)
21. Write a python program to find the sum of first 10 natural numbers.
22. Write a python program to find whether the number is odd or even.
23. Write a python program to find the variance and standard deviation for the
given data..
# Program to find variance and standard deviation for the given data
# Importing the NumPy module
import numpy as np
data=[4, 8, 6, 5, 3, 2, 8, 9, 2, 5]
24. Write a python program to display student marks from the record (text file).
# Program to display student marks from the record (text file)
# import linecache module
import linecache
# define line_number
line_number = 3
print (line)
25. Write a python program to create a labeled bar graph using matplotlib. pyplot.
# Program to create a labeled bar graph using matplotlib.pyplot
import matplotlib.pyplot as plt
plt.bar(Student, Percentage)
plt.title('Student Vs Percentage')
plt.xlabel('Student Names')
plt.ylabel('Percentage')
plt.show()
26. Write a python program to create a labeled pie chart using matplotlib. pyplot.
# Creating dataset
cars = ['AUDI', 'BMW', 'FORD', 'TESLA', 'JAGUAR', 'MERCEDES']
# Creating plot
plt.pie(data, labels=cars, autopct='%.2f%%')
plt.title('Sales of cars')
# show plot
plt.show()