Remaining Assignment X1
Remaining Assignment X1
Problem Statement:
Find the number of times an element occurs in the list.
Code:
data = [10, 20, 20, 30, 40, 50, 50, 50]
target = 50
count = data.count(target)
Output:
Problem Statement:
Read a list of n integers (positive and negative). Create two new list, one having all the positive and other
having all negative numbers from that list. Display all 3 list.
Code:
Enter integer 1: 3
Enter integer 2: -7
Enter integer 3: 10
Enter integer 4: -2
Enter integer 5: 0
Assignment: 14
Problem Statement:
Calculate mean median and mode using Numpy.
Code:
import numpy as np
data = [10,20,30,40,50,50,50]
print("Mean:", np.mean(data))
print("Median:", np.median(data))
mode = max(set(data), key=data.count)
print("Mode:",mode)
Output:
Mean: 35.71
Median: 40.0
Mode: 50
Assignment: 15
Problem Statement:
x = [2, 3, 4, 5, 6, 7, 8, 9]
y = [5 + (10 - 5) * (i - 2) / (9 - 2) for i in x]
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.legend()
plt.grid()
plt.show()
Output: