Lab Workbook PFSD aDVANCED
Lab Workbook PFSD aDVANCED
Lab Workbook PFSD aDVANCED
DEVELOPMENT WITH
DJANGO
22SDCI01 A/P
LAB WORKBOOK
S.N Date Experiment Name Pre- In-Lab (25M) Post- Viva Total Faculty
o Lab Program/ Data and Analysis & Lab Voce (50M) Signature
(10M) Procedure Results Inference (10M) (5M)
(5M) (10M) (10M)
1. Introductory Session -NA-
Aim/Objective: To Working with data types in Python like number, string, list, tuple and Dictionary.
Description: It will explain about the different data types in python their programming.
Pre-Requisites:
In-Lab:
Procedure/Program:
1. What is datatype?
Post-Lab:
a) Print the sum of the current number and the previous number
First, ask employee name, salary, and company name from the user Next, we will assign the input
provided by the user to the variables.
Finally, we will use the print() function to display those variables on the screen.
Procedure/Program:
Description: It will explains about the different operators like arithmetic, relational, Logical
operators.. etc
Pre-Requisites:
Pre-Lab:
a) The programmer wanted the program to swap the values in the variable a and b.
In-Lab:
Procedure/Program:
1 What is operator?
2. What is pep 8?
Post-Lab:
a) Write a program that asks the user to enter two integers. Have the program output how many
times the second number can be divided into the first number. For example if the first number
entered was 23 and the second number entered was 4 the program should report 5 times (i.e. the
fractional bit is ignored). You are required to implement this program using the floor operator.
Procedure/Program:
Aim/Objective: To Work with Conditional like if and if else execution and Looping statements like
for and while statements.
Description: It will explains about the different conditional statements like if, if.. else and looping
statements like for loop and while loop statements.
Pre-Requisites:
In-Lab:
a) Write a program that accepts the lengths of three sides of a triangle as inputs. The
program output should indicate whether or not the triangle is a right triangle (Recall from
the Pythagorean Theorem that in a right triangle, the square of one side equals the sum of
the squares of the other two sides)
b) Write a Python program to construct the following pattern, using a nested for loop.
*
**
***
****
*****
****
***
**
*
Procedure/Program:
i=1
while i < 5:
i + i print(i)
a)It prints 1,2,3,4,5 and then exits
b)It prints 1,2,4 then exits
c)It prints 1 forever
a)Loopy objects
b)Numbers
c)Iterable objects
d)Lines of code
print(x)
A) 1 2 3 4 5
B) 1 2 3 4
C) 0 1 2 3 4
Post-Lab:
a) Write a Python program which accepts a sequence of comma separated 4 digit binary numbers as
its input and print the numbers that are divisible by 5 in a comma separated sequence.
Procedure/Program:
Aim/Objective: To Work with List Processing methods like append(0, insert() and remove()
Description: It explains about the different list methods like append, insert , extend and remove, pop
and del.
Pre-Requisites:
Pre-Lab:
a) Program to convert a tuple of string values to a tuple of integer values. Go to the editor
In-Lab:
Procedure/Program:
Post-Lab:
Procedure/Program:
Description: It explains about the usage of sting operations and tuple methods
Pre-Requisites:
a)Program to remove an empty tuple(s) from a list of Tuples. Sample data: [(), (), ('',), ('a', 'b'), ('a', 'b',
'c'), ('d')] Expected output: [('',), ('a', 'b'), ('a', 'b', 'c'), 'd']
In-Lab:
a)Program to create, concatenate and print a string and accessing substring from a given
string.
Sample list: [(10, 20, 40), (40, 50, 60), (70, 80, 90)]
Expected Output: [(10, 20, 100), (40, 50, 100), (70, 80, 100)]
Procedure/Program:
Post-Lab:
Procedure/Program:
Description: It identifies the dictionary creation, modification methods and parameter passing
mechanism using python in functions.
Pre-Requisites:
Pre-Lab:
a)Python script to concatenate following dictionaries to create a new one. Sample Dictionary:
dic1={1:10, 2:20}
dic2={3:30, 4:40}
dic3={5:50,6:60}
In-Lab:
b)Python function that accepts a string and calculate the number of upper case letters
and lower case letters.
Sample String: 'The quick Brow Fox' Expected Output:
No. of Upper case characters: 3 No. of Lower case Characters: 12
Procedure/Program:
2. What will be the output of the following Python code snippet? test = {1:'A', 2:'B', 3:'C'}
test = {} print(len(test))
del test[1]
test[1] = 'D'
del test[2]
print(len(test))
a) 0
b) 2
d) 1
Post-Lab:
a) Program to remove an empty tuple(s) from a list of tuples. Sample data: [(), (), ('',), ('a', 'b'), ('a',
'b', 'c'), ('d')] Expected output: [('',), ('a', 'b'), ('a', 'b', 'c'), 'd'].
Procedure/Program:
Aim/Objective: To Work with Modules and pre-defined modules like re, OS and Packages
Description: It explains about the usage of different pre-defined modules and packages
Pre-Requisites:
Pre-Lab:
a) Program to generate a random color hex, a random alphabetical string, random value between
two integers (inclusive) and a random multiple of 7 between 0 and 70. Use random.randint()
In-Lab:
Procedure/Program:
1. Explain split (), sub (), subn() methods of “re” module in Python
5. What is the special file that each package in Python must contain?
Post-Lab:
Procedure/Program:
Aim/Objective: To Work with Exceptions (try, except , else and finally) and OOPS Concept like
inheritance and polymorphism.
Description: It explains about oops principles and exception handling techniques in python
Pre-Requisites:
Pre-Lab:
In-Lab:
Procedure/Program:
Post-Lab:
a) Create a class named Student with two attributes student_id, student_name. Add a new attribute
student_class and display the entire attribute and their values of the said class. Now remove the
student_name attribute and display the entire attribute with value
.
Procedure/Program:
Experiment Title : Design and develop a Flask application to demonstrate Student results. Using
Home, Courses, Rankers Gallery.
Description: It explains about the creation of flask and usage for student application
Pre-Requisites:
Installation of Flask
Basic knowledge about Python
Pre-Lab:
a) Hello World: This is a simple program that displays "Hello, World!" in the browser.
In-Lab:
a)Design and develop a Flask application to demonstrate Student results. Using Home,
Courses, Rankers Gallery.
Procedure/Program:
1 What is Flask?
5 Can a single view function have multiple routes associated with it? If yes, how?
Post-Lab:
a) How can I handle different HTTP methods (GET, POST, etc.) in Flask?
In Flask, you can handle different HTTP methods by specifying them in the route decorator using the
methods parameter.
Procedure/Program:
Experiment Title: Use Flask framework to Launch user profile based on login. Example if it's
Faculty as Faculty profile. If it's Student then Student Profile.
Pre-Requisites:
Pre-Lab:
In-Lab:
Use Flask framework to Launch user profile based on login. Example if it's Faculty as Faculty profile.
If it's Student then Student Profile.
Procedure/Program:
2. How do you handle different HTTP methods (GET, POST, etc.) in Flask?
Post-Lab:
Procedure/Program:
Experiment Title : Design and develop Flask application Register, Login page for K L Samyak event.
Design and develop Flask application Register, Login page for K L Samyak event.
Description:
Pre-Requisites:
a) Program to write a Python list of lists to a csv file. After writing the CSV file read the CSV file and
display the content
c) Find the Employees with a salary less than 20000 from the file mentioned in "above csv file".
d) Find the Employees with experience greater than 10 years from the file mentioned in "above
csv file".
e) Find the Employees who applied for leave more than 2 days from the file mentioned in the
"above csv file".
Procedure/Program:
1. How do you handle form data submitted via POST request in Flask?
5) How can you handle static files (CSS, JavaScript, images) in Flask?
Post-Lab:
Procedure/Program:
Pre-Requisites:
Installation of Django
Basic Knowledge of working with Web pages.
Pre-Lab:
In-Lab:
a) The main feature of the application is to manage and display the temperature as per the
location. In this app the user can enter the name of a city and do a search by clicking a
button. The app will show the current weather in that city. It can be directly connected to
the internet using the API and the output should be dynamic.
Then User input can be in the following types:
City name
Pin code
Hints: Use API called Open Weather Map for doing this project.
Procedure/Program:
Post-Lab:
Procedure/Program:
Aim/Objective:
Description: It explains about the Basic Knowledge of working with Web pages using Django
Framework.
Pre-Requisites:
Installation of django
Basic Knowledge of working with Web pages
Pre-Lab:
In-Lab:
a) The main feature of the application is to manage, collect and display only to admin. You
can create a web application using Python Flask, which can act as a feedback form for
collecting the feedback from KL CSE-1 students. And output should be display only to the
admin and the consent faculty.
• django Front-end
• Render Template need to be used for redirecting the correct page as per the input
given in the URL.
• For storing the data, you can use SQLite3 db.
Hints: You can use a free service for your application to send emails.
Procedure/Program:
2. What is the difference between Django and Flask? Why should we choose django?
3. Explain how you can show all errors in the browser for the django?
Post-Lab:
Procedure/Program:
Description: It explains about the how to send the mail using Django Framework
Pre-Requisites:
In-Lab:
a) Jay is an employee in Pooja software solutions. His project manager asked him to mail the
freshers who are recruited newly. Help him to build a project using Django and send the
mails. Help him to install the Django step by step and develop the project.
Procedure/Program:
3. What should be done in case you get a message saying “Please enter the correct username and
password” even after entering the right details to log in to the admin section?
Post-Lab:
Procedure/Program:
Experiment Title : Conduct the quiz using Django Framework and Testing
Aim/Objective:
Description: It explains about Conduct the quiz using Django Framework and Testing
Pre-Requisites:
In-Lab:
a) Abdul is working for KL university, and he got the order from the hod to conduct the quiz
help the Abdul to conduct the quiz by developing the project using Django?
•Users need to create an account and login into the exam portal (data should go to
database).
•After the logging he need to start quick quiz and get the score at last, and marks need to
send database.
b) Fathima need to test security of Abdul project which he had done in the above question.
Because she thinks that website is vulnerable to get attack by hackers. So, help her in the
checking process by using the Nmap tool, make sure to scan the website by domain name or
Ip address or local host address perform different types of scans like quick scan, fast scan,
OS version scan, server scans etc.… and generate the report to Fathima and help Abdul
website from attackers (using Nmap tool).
Procedure/Program:
3. List some caching strategies supported by Django. What is the difference between returning a
callback and just calling a callback?
4. What is “Vulnerability”?
5. What network ports are commonly examined in a pen testing exercise, and what tool can be
used for this?
Post-Lab:
.Procedure/Program:
Aim/Objective:
Description: It explains about the how to Develop a result analysis for survey based on feedback
Pre-Requisites:
A Django view is a Python function or class that takes an HTTP request and returns an HTTP
response.
In-Lab:
Procedure/Program:
Post-Lab:
You can render a template in Django by using the render() function, which takes the request,
template path, and context as arguments.
Procedure/Program:
Aim/Objective:
Description: It explains about the cache and session management in Django framework
Pre-Requisites:
The settings.py file stores various configuration settings for your Django project, including
database connection details, installed apps, middleware, static files configuration, and more.
In-Lab:
1. Mention the ways used for the customization of the functionality of the Django admin interface.
5. What are the ways to customize the functionality of the Django admin interface?
Post-Lab:
In the settings.py file, you can specify the database details, including the engine, name, user,
password, and host, in the DATABASES dictionary to establish a connection to a database.
Procedure/Program:
Aim/Objective:
Pre-Lab:
Django provides form handling functionality through its Form class. You can define a form class,
validate form data, and perform actions based on the submitted data.
In-Lab:
3. What should be done in case you get a message saying “Please enter the correct username and
password” even after entering the right details to log in to the admin section?
4. What to do when you don’t see all objects appearing on the admin site?
Post-Lab:
Django's authentication system provides built-in features for user authentication, including login,
logout, password management, user permissions, and integration with third-party authentication
providers.
Procedure/Program:
Aim/Objective:
Pre-Requisites:
Pre-Lab
Django provides the request.POST attribute to access form submission data in views. You can
validate and process the submitted data accordingly.
In-Lab:
5.What is mixin?
Post-Lab:
URL reversing in Django allows you to generate URLs based on named URL patterns, making your
code more maintainable and flexible.
Procedure/Program:
Aim/Objective:
Pre-Requisites:
Pre-Lab:
You can handle file uploads in Django forms by using the FileField or ImageField in your form
definition. The uploaded file can then be accessed in the view via the request.FILES attribute.
In-Lab:
1. How can you limit admin access so that the objects can only be edited by those users who have
created them?
2. What to do when you don’t see all objects appearing on the admin site?
3. How can you see the raw SQL queries that Django is running?
4. Is Django a CMS?
Post-Lab:
You can perform database queries in Django using the ORM's query API. Methods such as filter(),
get(), and exclude() allow you to retrieve specific records from the database.
Procedure/Program: