JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD

EE206ES: APPLIED PYTHON PROGRAMMING LABORATORY

B.Tech I Year II Semester (R22)

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 Course PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 CO1 2 2 1 1 1 1 - - 1 - 1 1 CO2 2 3 2 1 1 2 - - 1 - 1 1 CO3 2 3 2 1 1 2 - - 1 - 1 1

LIST OF EXPERIMENTS:

Cycle - 1

  • 1. Downloading and Installing Python and Modules
  • a) Python 3 on Linux Follow the instructions given in the URL https://docs.python- guide.org/starting/install3/linux/
  • b) Python 3 on Windows Follow the instructions given in the URL https://docs.python.org/3/using/windows.html (Please remember that Windows installation of Python is harder!)
  • c) pip3 on Windows and Linux Install the Python package installer by following the instructions given in the URL https://www.activestate.com/resources/quick-reads/how-to-install-and-use-pip3/
  • 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
  • 2. Introduction to Python3
  • a) Printing your biodata on the screen
  • b) Printing all the primes less than a given number
  • 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
  • 3. 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, 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
  • 4. 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 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
  • 5. The package scipy and pyplot
  • a) Finding if two sets of data have the same mean value
  • b) Plotting data read from a file
  • c) Fitting a function through a set a data points using polyfit function
  • d) Plotting a histogram of a given data set
  • 6. 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
  • 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
  • 7. Installing OS on Raspberry Pi
  • a) Installation using PiImager
  • b) Installation using image file
  • Downloading an Image
  • Writing the image to an SD card
  • using Linux
  • using Windows
  • Booting up Follow the instructions given in the URL https://www.raspberrypi.com/documentation/computers/getting-started.html
  • 8. 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: 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.
  • 9. Collecting Sensor Data
  • a) DHT Sensor interface ◦ Connect the terminals of DHT GPIO pins of Raspberry Pi. ◦ Import the DHT library using import Adafruit_DHT ◦ Read sensor data and display it on screen.

Loading Question Papers

Fetching data from database...