SR PRACTICAL DATE SIGNATUR
NO E
Unit 3 : Advanced Python Programs
1. Write a program to create a Simple Calculator for any two
input numbers
2. Write a program to check whether the given character is
an uppercase letter or lowercase letter or a digit or a
special character.
3. Write a program to input a sales amount and calculate
the discount as per given criteria:
4. Write a program to input a number and check the following, if
the number is
Even and < 50
Even and > 50
Even and = 50
Odd
5 Write a program to print square of all numbers present in a list
[8,2,7,11,20].
6. Write a short program to print the following series up to N
terms
a) 14 7 10 … N term
b) N N-2 N-4 N-6 …
7. Write a program to input a positive number and prints its
factorial. The factorial of a number is as :
● For positive number n is: n*(n-1)*(n-2)*….*1
● For negative number : no factorial for negative number
● For zero is :1
8. Write a program to input a number and prints its reversed
number
9. Write a program to calculate and print the sum of even and
odd integers of the first N natural numbers. ( Use while loop
only)
10. Write a program to find multiple of any number up to N terms.
Unit 4 : Data Science
SR PRACTICAL DATE SIGNATURE
NO
11. Write a program to create array using NumPy.
a) Create one-dimensional array
b) Creating 2D array
12. Creating an array with 3 random values
13. Write a program to perform various array operation on array
elements as : [5,2,3,10,15,4,2,12]
14. Demonstrate 5 essential plots of data
visualization techniques.
a) Write a program to represent the data on the ratings
of mobile games on bar chart.
b) Write a program to represent monthly sales of
salesman on line chart chart.
c) the data on the ratings of mobile games on bar chart
d) Observe the given data for monthly sales of one of
the salesmen for given months. Plot them on the
line chart.
15.
Unit 5: Computer Vision
16. Load Image and Give the title of the image.
17. Change the colour of the image to gray
18. Print the shape of the image (dimension of the image)
19. Crop the image. Display original and cropped image
20. Save the Image (Hint : Use cv2.imwrite() function)
UNIT 3 : ADVANCED PYTHON PROGRAMS
1. Write a program to create a Simple Calculator for any two input numbers
2. Write a program to check whether the given character is an uppercase letter or
lowercase letter or a digit or a special character.
OUTPUT - 1
OUTPUT - 2
3. Write a program to input a sales amount and calculate the discount as :
Salesamount >=10000, 8.5% discount
Salesamount 5000 - 10000, 5% discount
Salesamount 1500 - 5000, 2.5% discount
Salesamount <1500, No discount
OUTPUT - 1
OUTPUT - 2
4. Write a program to input a number and check the following, if the number is
Even and < 50
Even and > 50
Even and = 50
Odd
OUTPUT – 1
OUTPUT - 2
5 Write a program to print square of all numbers present in a list [8,2,7,11,20].
OUTPUT
6 Write a short program to print the following series up to N terms
c) 1 4 7 10 …N term
d) N N-2 N-4 N-6 …
a) ..
OUTPUT
b)
OUTPUT
7 write a program to input a positive number and prints its factorial. The factorial of a
number is as :
For positive number n is: n*(n-1)*(n-2)*….*1
For negative number : no factorial for negative number
For zero is :1
OUTPUT - 1
OUTPUT – 2
OUTPUT - 3
8. Write a program to input a number and prints its reversed number.
OUTPUT
9 Write a program to calculate and print the sum of even and odd integers of the
first N natural numbers. ( Use while loop only)
OUTPUT – 1
OUTPUT – 2
10 Write a program to find multiple of any number up to N terms.
OUTPUT
1. Write a program to create array using NumPy.
a) Create one-dimensional array
OUTPUT
b) Creating 2D
array OR
Write a program to develop a matrix of 3x3 with values from
5 to 50 with increment of 5
OUTPUT
2. Creating an array with 3 random values
OUTPUT
3. Write a program to perform various array operation on array
elements as : [5,2,3,10,15,4,2,12]
OUTPUT
4. Write a program to represent the data on the ratings of mobile games on
bar chart. The sample data is given as:
Game Pubg FreeFire MineCraft Call of duty FIFA 22
Game’s Rating 4.5 4.8 4.7 4.6 4.3
OUTPUT
5. Observe the given data for monthly sales of one of the salesmen
for given months. Plot them on
the LINE CHART
Month January February March April
Sales 2500 1700 3500 1200
Apply the following customizations to the chart:
● Give the title for the chart - "Sales Report"
● Use the "Month" label for X-Axis and "Sales" for Y-Axis.
● Use red color for the line.
OUTPUT
Computer vision is a field of AI that focuses on enabling computers to identify
and understand objects, Intercept and extract information from images and videos,
in a manner similar to human vision
Few examples:
● Facial recognition.
● Self-driving cars.
● Robotic automation.
● Medical anomaly detection.
● Agricultural monitoring.
● Google lens
cv2 is a powerful library for working with images in Python. Few function of cv2 are:
cv2.imread()
This function loads an image from the specified file
syntax : cv2.imread(location of file, file name)
cv2.imshow()
this function is used to display an image in a window .The window automatically fits the image size.
Syntax: cv2.imshow(window_name, image)
cv2.waitKey()
This function display a window for several milliseconds.
cv2.waitKey(0).
If 0 is passed as an argument, it wait/display a window forever until any key is
pressed.
OpenCV images are stored as three-dimensional Numpy arrays to carry out complex
calculations with high speed.
6. Load Image and Give the title of the image.
7. Change the colour of image to gray
8. Print the shape of image(dimension of the image)
OUTPUT
9. Crop the image. Display original and cropped image
OUTPUT
10. Save the Image (Hint : Use cv2.imwrite() function)
OUTPUT :
ACTIVITY
Python Library
● A library is a collection of books or is a room or place where many books are stored to be
used later. Similarly, in the programming world, a library is a collection of precompiled
codes that can be used later on in a program for some specific well-defined operations.
● A Python library is a collection of related modules. It contains bundles of code that can
be used repeatedly in different programs. It makes Python Programming simpler and
convenient for the programmer. As we don’t need to write the same code again and
again for different programs.
● Python libraries play a very vital role in fields of Machine Learning, Data Science, Data
Visualization, etc.
● Numpy, Pandas, TensorFlow are example of python library.
● Numeric, Numarray are package of Numpy library.
PYTHON MODULE
● A Python module is single python file, containing Python definitions and statements.
● A module can define functions, classes, and variables.
● A module can also include runnable code. Grouping related code into a module
makes the code easier to understand and use.
PYTHON PACKAGE
● A Python Package is a collection of different Python
modules Python provides some readymade packages. They are:
1. NumPy –
● It is used for numerical array and its functions.
● It is most useful when we are working with large data sets and
requires calculations.
2. OpenCV :
● It is mainly used for image processing and support various functions related
to image manipulations.
3. Matplotlib :
● It is used to represent the data in visualization mode.
● It helps user to visualize data to understand them.
4. NLTK :
● It stands for Natural Language Tool Kit supports features related to textual data.
● It is used for Natural Language Processing.
5. Pandas :
● Pandas is used to handle 1D and 2D data structures of python.
After installation of packages, you need to import them into the program.
You can import these modules by following ways:
1. import numpy
2. import matplotlib.pyplot as chart
3. import opencv as cv
4. from numpy import array
PROGRAMS OF 2022 – 23
● FOR PRACTICE ONLY
● DON’T WRITE IN PRACTICAL FILE
1. Write a program input three numbers and swap them as this:
● 2nd number gets the value of 1st+2nd number,
● 3rd numbder gets the value of 2nd +3rd number
# Read three numbers
x=int(input("Enter 1s t number”)
y=int(input("Enter 2nd number”)
z=int(input("Enter 3rd number”)
print(“Origional number:”, x, y,z) x=x
y=x+y
z=x+y+z
print(“After swapping”, x, y, z)
2. Write a program to check whether the given character is an uppercase
letter orlowercase letter or a digit or a special character.
3. Write a program to find the maximum number out of the given
three numbers.
#Take input of three number to compare
n1=int(input("Enter the Number1:"))
n2=int(input("Enter the Number2:"))
n3=int(input("Enter the Number3:"))
if n1>n2 and n1>n3:
print(“Greater number is :”, n1)
elif n2>n1 and n2>n3:
print(“Greater number is :”, n2)
elif n3>n1 and n3>n2:
print( “Greater number is :”, n3)
else:
print("All are same")
4. An electric power distribution company charges its
domestic consumers as follows:
CONSUMPTION RATE OF CHARGE
UNITS
0-100 Rs. 1 per unit
101-300 Rs. 100 plus Rs. 1.25 per unit in excess of 100
301-500 Rs. 350 plus Rs. 1.50 per unit in excess of 300
500 and above Rs. 650 plus Rs. 1.75 per unit in excess of 500
Write a program that read the customer number & power consumed and prints the
amount to be paid by the customer. Note that output should be well formatted..
OUTPUT :
5. Program to print sum of natural numbers between 1 to N.
OUTPUT
6. Program to accept a number and print its Multiplication table for N
terms
OUTPUT
7. Write a program to input a number and print its reversed number.
OUTPUT
8. Write a program to create a list of students' marks with
user-defined values and find the maximum.
OUTPUT
9. Write a program to calculate and print the sum of even and odd integers
of the first N natural numbers. ( Use while loop)
OUTPUT
Scatter plot
Bar chart
Histogram
Box plots
Lll
sdsd
OUTPUT