FACULTY OF ENGINEERING AND
TECHNOLOGY
Programming in Python with
Full Stack Development
(303105257)
BTECH 4th SEMESTER
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
SEM4-
NO: 2403031460393
4444444
LAB MANUAL
CERTIFICATE
This is to certify Mr. G Bharani K umar Reddywith Enrollment no.
2403031460393 that Has successfully completed his Laboratory
Experiments in the Programming in Python with Full Stack
Development (303105257) from the Department of Artificial
Intelligence & Machine Learning (AIML) during the academic year
2025-2026.
Date of Submission:
Head of Department : Staff in Charge:
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
INDEX
Set / TITLE Start End Start End Marks Sign
SR. Page Page Date Date out of 10
No. No. No.
SET – 1 : Python Programming Basics
1 Program to convert temperatures from
Fahrenheit to Celsius and vice versa
2 Program to calculate the area and
perimeter of a rectangle
3 Program to generate a random password
of a specified length
4 Program to calculate the average of a list
of numbers
5 Program to check whether a given year is
a leap year
6 Program to calculate the factorial of a
number
7 Program to check whether a given string
is a palindrome
8 Program to sort a list of numbers in
ascending or descending order
9 Program to generate a multiplication
table for a given number
10 Program to convert a given number from
one base to another
SET – 2 : Object-Oriented Programming & File Handling
1 Program to model a bank account using
classes for account, customer, and bank
2 Program to simulate a school
management system using classes
3 Program to read a text file and count the
number of words
4 Program to read a CSV file and
calculate the average of a specified
column
5 Program to read an Excel file and display
data in tabular format
SET – 3 : Web Application Development
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
1 Program to create a simple web server
and serve a static HTML page
2 Program to create a web application for
user registration and login
3 Program to create a web application for
file upload and download
4 Program to display data from a
database in tabular format using a web
application
5 Program to accept user input and process
it on the server side
SET – 4 : Advanced Web Development
1 Program to generate dynamic HTML
pages using a template engine
2 Program to support AJAX requests and
update web pages without reloading
3 Program to use Django debugging tools
to troubleshoot errors and exceptions
4 Program to implement user
authentication and authorization
5 Program to integrate third-party APIs
into a web application
SET – 5 : RESTful API Development
1 Program to create a RESTful API that
returns user data in JSON format
2 Program to implement CRUD operations
using RESTful APIs
3 Program to authenticate RESTful APIs
using JSON Web Token (JWT)
4 Program to implement pagination in
RESTful APIs
5 Program to implement data validation
and error handling in RESTful APIs
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
SET – 1 : Python Programming Basics
Practical 1 :
Aim
To write a Python program that converts temperature from Fahrenheit to Celsius and vice versa.
Algorithm
1. Input temperature value
2. Ask user for conversion choice
3. Apply appropriate formula
4. Display the converted temperature
Program
temp = float(input("Enter temperature: ")) choice
= input("Convert to (C/F): ")
if [Link]() == 'C':
c = (temp - 32) * 5 / 9
print("Temperature in Celsius:", c)
elif [Link]() == 'F': f = (temp *
9 / 5) + 32 print("Temperature in
Fahrenheit:",
f) else:
print("Invalid choice")
Output
Enter temperature: 98
Convert to (C/F): C
Temperature in Celsius: 36.66
Practical 2 Aim
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
To calculate the area and perimeter of a rectangle. Algorithm
1. Input length and breadth
2. Calculate area = l × b
3. Calculate perimeter = 2(l + b)
4. Display results Program
l = float(input("Enter length: ")) b
= float(input("Enter breadth: "))
area = l * b perimeter
= 2 * (l + b)
print("Area:", area) print("Perimeter:",
perimeter)
Output
Area: 50
Perimeter: 30
Practical 3 Aim
To generate a random password of specified length. Algorithm
1. Input password length
2. Use letters, digits, and symbols
3. Generate random characters
4. Display password
Program
import
random
import string
length =
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
int(input("Ent
er password
length: "))
chars =
string.ascii_let
ters +
[Link] +
[Link]
tion password
=
''.join(random.
choice(chars)
for i in
range(length))
print("Generated Password:", password)
Output
Generated Password: A&9x#2B!
Practical 4 Aim
To calculate the average of a list of numbers.
Algorithm
1. Input numbers as a list
2. Find sum of list
3. Divide by number of elements
4. Display average
Program
nums = list(map(int, input("Enter numbers: ").split()))
avg = sum(nums) / len(nums) print("Average:", avg)
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
Output
Enter numbers: 10 20 30
Average: 20.0
Practical 5 Aim
To check whether a given year is a leap year. Algorithm
1. Input year
2. Apply leap year conditions
3. Display result Program
year = int(input("Enter year: "))
if (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0):
print("Leap Year")
else:
print("Not a Leap Year") Output
Enter year: 2024
Leap Year
Practical 6 Aim
To calculate factorial of a given number. Algorithm
1. Input number
2. Multiply numbers from 1 to n
3. Display factorial Program
n = int(input("Enter number: ")) fact
=1
for i in range(1, n + 1): fact
*= i
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
print("Factorial:", fact)
Output
Enter number: 5
Factorial: 120
Practical 7
Aim
To check whether a string is a palindrome. Algorithm
1. Input string
2. Reverse the string
3. Compare original and reversed
4. Display result Program
s = input("Enter string: ")
if s == s[::-1]:
print("Palindrome")
else:
print("Not a Palindrome")
Output
Enter string: madam
Palindrome
Practical 8 Aim
To sort a list of numbers in ascending or descending order. Algorithm
1. Input list
2. Ask sorting order
3. Sort accordingly
4. Display result
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
Program
nums = list(map(int, input("Enter numbers: ").split())) order
= input("asc or desc: ")
if order ==
"asc":
[Link]() else:
[Link](reverse=True)
print("Sorted List:", nums)
Output
Sorted List: [10, 20, 30]
Practical 9
Aim
To generate a multiplication table for a given number. Algorithm
1. Input number
2. Loop from 1 to 10
3. Print multiplication Program
n = int(input("Enter number: "))
for i in range(1, 11):
print(n, "x", i, "=", n * i)
Output
5x1=55x
2 = 10
...
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
Practical 10
Aim
To convert a given number from one base to another.
Algorithm
1. Input number and base
2. Convert using built-in functions
3. Display result Program
num = int(input("Enter number: "))
print("Binary:", bin(num))
print("Octal:", oct(num))
print("Hexadecimal:", hex(num))
Output
Binary: 0b1010
Octal: 0o12
Hexadecimal: 0xa
SET – 2 : Object-Oriented Programming & File Handling
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
Practical 1 Aim
To model a bank account system using classes for Account, Customer, and Bank.
Algorithm
1. Create Customer class
2. Create Account class with deposit & withdraw
3. Create Bank class to manage accounts
4. Perform operations Program
class Customer:
def init (self, name):
[Link] = name
class Account:
def init (self, acc_no, balance):
self.acc_no = acc_no
[Link] = balance
def deposit(self, amt):
[Link] += amt
def withdraw(self, amt): if
amt <= [Link]:
[Link] -= amt else:
print("Insufficient Balance")
class Bank: def
init (self):
[Link] =
[]
def
add_account(self,acco
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
unt):
[Link]
account)
cust = Customer("Aryan") acc =
Account(101, 5000)
[Link](2000)
[Link](1000) print("Final
Balance:", [Link])
Output
Final Balance: 6000
Practical 2 Aim
To simulate a school management system using classes.
Algorithm
1. Create Student, Teacher, Course classes
2. Assign course to students
3. Display details
Program
class Student: def init
(self, name):
[Link] = name
class Teacher:
def init (self, name):
[Link] = name
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
class Course:
def init (self, cname):
[Link] = cname
s = Student("Bunny") t =
Teacher("[Link]") c
= Course("Python")
print("Student:", [Link])
print("Teacher:", [Link])
print("Course:", [Link])
Output
Student: Bunny
Teacher: Mr. nasrulla
Course: Python
Practical 3 Aim
To read a text file and count the number of words in it.
Algorithm
1. Open text file
2. Read content
3. Split words
4. Count words
Program
file = open("[Link]", "r") text =
[Link]() words = [Link]()
print("Word Count:",len(words))
[Link]()
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
Output
Word Count: 45
Practical 4 Aim
To read a CSV file and calculate the average of values in a specified column. Algorithm
1. Open CSV file
2. Read values from column
3. Calculate average
4. Display result Program
import csv
with open("[Link]", "r") as file: reader
= [Link](file)
next(reader) total =
0 count = 0 for row
in reader: total +=
int(row[1]) count
+= 1
print("Average:",
total / count)
Output
Average: 72.5
Practical 5 Aim
To read an Excel file and display data in tabular format.
Algorithm
1. Load Excel file
2. Read rows
3. Print data Program import openpyxl
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
wb = openpyxl.load_workbook("[Link]")
sheet = [Link]
for row in sheet.iter_rows(values_only=True):
print(row)
Output
('Name', 'Marks')
('Amit', 80)
('Neha', 90)
SET – 3 : Web Application Development (Flask)
Practical 1 Aim
To create a simple web server and serve a static HTML page. Algorithm
1. Install Flask
2. Create Flask app
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
3. Define route
4. Serve HTML page Program
from flask import Flask app
= Flask( name )
@[Link]("/")
def home():
return
"<h1>Welcome
to My Web
Server</h1>"
if name == " main ":
[Link](debug=True)
Output
Web page displays: Welcome to My Web Server
Practical 2 Aim
To create a web application that allows users to register and login.
Algorithm
1. Create registration form
2. Store username & password
3. Validate login credentials
4. Display result
Program
from flask import Flask, request
app = Flask( name ) users =
{}
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
@[Link]("/register", methods=["POST"]) def
register():
users[[Link]['username']] = [Link]['password'] return
"Registered Successfully"
@[Link]("/login", methods=["POST"]) def
login():
if [Link]([Link]['username']) == [Link]['password']:
return "Login Successful"
return "Invalid Credentials"
if name == " main ":
[Link](debug=True)
Output
Login Successful
Practical 3 Aim
To create a web application that allows users to upload and download files. Algorithm
1. Accept file from user
2. Save file on server
3. Allow file download
Program
from flask import Flask, request app
= Flask( name )
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
@[Link]("/upload", methods=["POST"])
def upload():
file = [Link]['file']
[Link]([Link])
return "File Uploaded Successfully"
if name == " main ":
[Link](debug=True)
Output
File Uploaded Successfully
Practical 4 Aim
To display data from a database in tabular format using a web application. Algorithm
1. Connect to database
2. Fetch records
3. Display in HTML table Program
from flask import Flask import
sqlite3
app = Flask( name )
@[Link]("/") def show():
con =
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
[Link]("[Link]") cur =
[Link]()
[Link]("SELECT * FROM student") rows =
[Link]()
return str(rows)
if name == " main ":
[Link](debug=True)
Output
[(1, 'Bunny', 85), (2, 'Abhi', 90)]
Practical 5 Aim
To create a web application that accepts user input and processes it on the server side.
Algorithm
1. Accept input from user
2. Process input
3. Display result Program
from flask import Flask, request app
= Flask( name )
@[Link]("/square", methods=["POST"]) def
square():
num = int([Link]['number']) return
f"Square is {num*num}"
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING & TECHNOLOGY
PPFSD (303105257) -
B. TECH 4th SEM
ENROLLMENT NO: 2403031460393
if name == " main ":
[Link](debug=True)
Output
Square is 25