PRACTICAL 1
Question:
Print if a number is odd or even using Python.
CODE / RESULT:
PRACTICAL 2
Question:
Print if a number is Positive, Negative or Zero.
CODE / RESULT:
PRACTICAL 3
Question:
Write a program that prints:
i. Greater than equal to 90 Excellent
ii. Greater than equal to 75 very good
iii. Greater than equal to 50 good
iv. Needs improvement for marks below 50
CODE / RESULT:
PRACTICAL 4
Question:
Write a python program to find the greatest of three numbers.
CODE / RESULT:
PRACTICAL 5
Question:
Create a list of numbers 10,20,30,40,60,70
i. Remove 40 from the list and add 50 in it's place
ii. Find the count of all elements in the list
iii. Find the sum of all elements and calculate the average
iv. Display the final list
CODE / RESULT:
PRACTICAL 6
Question:
Create a dictionary named book with 5 key value pairs:
i. Title
ii. Author
iii. Year
iv. Price
v. Publisher
vi. Print the title and price of the book
CODE / RESULT:
PRACTICAL 7
Question:
Multiplication of 5 using for loop.
CODE / RESULT:
PRACTICAL 8
Question:
Write a python program using ‘for’ loop to print odd numbers.
CODE / RESULT:
PRACTICAL 9
Question:
Write a python program using while loop to print even numbers from 2-10.
CODE / RESULT:
PRACTICAL 10
Question:
Write a python program using while loop to print numbers from 5 to 1.
CODE / RESULT:
PRACTICAL 11
Question:
Create an array of even numbers 1-20 (20 inclusive).
CODE / RESULT:
PRACTICAL 12
Question:
Create an array of numbers 1-12 and re shape it to a 3x4 matrix.
CODE / RESULT:
PRACTICAL 13
Question:
Create 8 numbers between 10 and 50.
CODE / RESULT:
PRACTICAL 14
Question:
Create an array of integers from 1-20 and extract the last 5 elements.
CODE / RESULT:
PRACTICAL 15
Question:
Create an array of even numbers from 2-20 and print the numbers greater than 10.
CODE / RESULT:
PRACTICAL 16
Question:
Write a Python program using NumPy that does the following:
i. Create a NumPy array containing the elements: 1, 2, 3.
ii. Compute the sum of the elements of the array.
iii. If the sum of the array is greater than 5, multiply each element of the array by 2.
iv. Otherwise, add 2 to each element of the array.
v. Print the final array.
CODE / RESULT:
PRACTICAL 17
Question:
Find the inverse and determinant of the matrix [1,2], [3,4].
CODE / RESULT:
PRACTICAL 18
Question:
Minimize the function f(x)= x2+4x+1.
CODE / RESULT:
PRACTICAL 19
Question:
Compute the following integration Integrate over 0 to 2, f(x)=x2.
CODE / RESULT:
PRACTICAL 20
Question:
Compute the following integration. Integrate over 0 to 1, f(x)= 3x2+1.
CODE / RESULT:
PRACTICAL 21
Question:
Given a list of integers count how many are positive, negative and zero.
List= 3,-1,0,5,-7,0,2,-4.
CODE / RESULT:
PRACTICAL 22
Question:
Check whether a given number is prime or not.
CODE / RESULT:
PRACTICAL 23
Question:
Create a dictionary with numbers 1-5 as key and their squares as values using ‘for’ loop.
CODE / RESULT:
PRACTICAL 24
Question:
Count how many vowels are there in the word, STATISTICS.
CODE / RESULT:
PRACTICAL 25
Question:
From a numpy array, consider only the even elements and compute their mean and standard
deviation.
CODE / RESULT:
PRACTICAL 26
Question:
Write a program to find the second largest number in a list (without using sort).
CODE / RESULT:
PRACTICAL 27
Question:
Given a list of numbers replace all the negative numbers with 0 and print the new list.
CODE / RESULT:
PRACTICAL 28
Question:
Take a list of numbers from the user and arrange it in ascending and descending order.
CODE / RESULT:
PRACTICAL 29
Question:
Take a string and check whether it is a palindrome.
CODE / RESULT:
PRACTICAL 30
Question:
Keep taking numbers from the user until they enter 0, then print the sum of all entered numbers.
CODE / RESULT:
PRACTICAL 31
Question:
The following data shows the number of hours studied (X) and the marks obtained (Y) by a
student:
Hours studied (X) 1 2 3 4 5
Marks (Y) 2 4 5 4 5
Fit a simple linear regression model of the form:
Y=mX+c. Find the values of slope (m) and intercept (c) using Python.
Predict the marks when the student studies for 6 hours.
CODE / RESULT:
PRACTICAL 32
Question:
Three different teaching methods are used for three groups of students. Their test scores are:
Group A: 85, 88, 90, 87, 86
Group B: 78, 75, 80, 77, 76
Group C: 92, 94, 91, 93, 95
Tasks:
i. Perform a one-way ANOVA using Python to test whether the mean scores of the three
groups are equal.
ii. State the null hypothesis and alternative hypothesis.
iii. Print the F-statistic and p-value.
CODE / RESULT:
PRACTICAL 33
Question:
Two different teaching methods are used in two classes. Their test scores are:
Class A: 78, 80, 82, 79, 81
Class B: 74, 76, 75, 73, 77
Tasks:
Test whether the mean scores of the two classes are significantly different using a t-test.
Use 5% significance level.
CODE / RESULT:
PRACTICAL 34
Question:
The weights (kg) of 5 people are measured before and after a fitness program:
Before: 70, 72, 68, 75, 71
After: 68, 70, 67, 73, 69
Tasks:
Test whether the fitness program has significantly changed the weights using a paired t-test.
Use 5% significance level.
CODE / RESULT:
PRACTICAL 35
Question:
Time spent by users on 3 website designs are given below. Perform one way ANOVA to check if
the average time spent across the 3 designs differ significantly.
Design A- 5,6,5,7,6
Design B- 8,9,7,8,9
Design C- 4,3,5,4,4
CODE / RESULT:
PRACTICAL 36
Question:
The blood pressure of 7 patients was measured before and after giving a drug. Check whether the
drug reduces bp using a suitable t test. Also state the null and alternative hypothesis.
Before- 150,148,152,149,151,147,153
After- 145,143,147,144,146,142,148
CODE / RESULT:
PRACTICAL 37
Question:
The daily output (in units) from 2 independent machines is recorded as follows:
Machine A- 102,98,100,101,99
Machine B- 95,97,96,94,98
Test whether there is a significant difference in the mean output of the 2 machines (use 5% level
of significance).
CODE / RESULT:
PRACTICAL 38
Question:
1. Load the Excel file into Python using Pandas.
2. Display the first 5 rows of the dataset.
3. Display the last 5 rows of the dataset.
4. Show complete information about the dataset (data types and non-null values).
5. Generate descriptive statistics of the dataset.
6. Check for missing values in each column.
7. Find the average (mean) marks of students.
8. Find the maximum marks scored by students.
9. Display students who scored more than 80 marks.
10. Display students who scored more than 85 marks.
11. Sort the dataset in descending order based on marks.
12. Count the number of students in each department.
13. Find the average marks of students in each department.
14. Fill missing values in the dataset using the mean of respective columns.
15. Display the dataset after filling missing values.
CODE / RESULT:
PRACTICAL 39
Question:
1. Load the Excel dataset into Python using Pandas.
2. Display the first five rows of the dataset.
3. Display basic information about the dataset (data types and number of entries).
4. Generate descriptive statistics for numerical columns.
5. Create a new column Total_Sales such that:
Total_Sales = Price × Quantity
6. Display products where Total_Sales is greater than 50,000.
7. Sort the dataset based on Total_Sales in descending order.
8. Find the total sales for each product category.
9. Count how many orders each salesperson handled.
10. Find the average price of products in each category.
CODE / RESULT: