APPLIED PYTHON PROGRAMMING LABORATORY
I Year II Semester
Course Code Category Hours / Week Credits Maximum Marks
L T P C CIA SEE Total
A6EE03 ESC
0 0 2 1 40 60 100
Course Outcomes:
Course Outcomes: Upon completing this course, the students will be able to
1. Build basic programs using fundamental programming constructs
2. Write and execute python codes for different applications
3. Capable to implement on hardware boards
LIST OF EXPERIMENTS
Cycle – 1
Downloading and Installing Python and Modules
a) Python 3 on Linux
Follow the instructions given in the URL [Link]
org/starting/install3/linux/
b) Python 3 on Windows
Follow the instructions given in the URL [Link]
(Please remember that Windows installation of Python is harder!)
1
c) pip3 on Windows and Linux
Install the Python package installer by following the instructions given in the URL
[Link]
d) Installing numpy and scipy
You can install any python3 package using the command pip3 install <packagename>
e) Installing jupyterlab
Install from pip using the command pip install jupyterlab
Introduction to Python3
a) Printing your biodata on the screen
b) Printing all the primes less than a given number
2
c) Finding all the factors of a number and show whether it is a perfect number, i.e., the sum
of all its factors (excluding the number itself) is equal to the number itself
Defining and Using Functions
a) Write a function to read data from a file and display it on the screen
b) Define a boolean function is palindrome(<input>)
c) Write a function collatz(x) which does the following: if x is odd, x = 3x + 1; if x is even,
3
then x = x/2. Return the number of steps it takes for x = 1
d) Write a function N(m, s) = exp(-(x-m)2/(2s2))/sqrt(2π)s that computes the Normal
distribution
The package numpy
a) Creating a matrix of given order m x n containing random numbers in the range 1 to
99999
b) Write a program that adds, subtracts and multiplies two matrices. Provide an interface
4
such that, based on the prompt, the function (addition, subtraction, multiplication)
should be performed
c) Write a program to solve a system of n linear equations in n variables using matrix inverse
The package scipy and pyplot
a) Finding if two sets of data have the same mean value
b) Plotting data read from a file
5
c) Fitting a function through a set a data points using polyfit function
d) Plotting a histogram of a given data set
The strings package
a) Read text from a file and print the number of lines, words and characters
b) Read text from a file and return a list of all n letter words beginning with a vowel
6
c) Finding a secret message hidden in a paragraph of text
d) Plot a histogram of words according to their length from text read from a file
Cycle – 2
. Installing OS on Raspberry Pi
a) Installation using PiImager
b) Installation using image file
Downloading an Image
Writing the image to an SD card
7 using Linux
using Windows
Booting up
Follow the instructions given in the URL
[Link]
Accessing GPIO pins using Python
a) Installing GPIO Zero library.
First, update your repositories list:
sudo apt update
Then install the package for Python 3:
8 sudo apt install python3-gpiozero
b) Blinking an LED connected to one of the GPIO pin
c) Adjusting the brightness of an LED
Adjust the brightness of an LED (0 to 100, where 100 means maximum brightness)
using the in-built PWM wavelength.
Collecting Sensor Data
a) DHT Sensor interface
◦ Connect the terminals of DHT GPIO pins of Raspberry Pi.
9
◦ Import the DHT library using import Adafruit_DHT
◦ Read sensor data and display it on screen.