DR.
MAHALINGAM COLLEGE OF ENGINEERING AND
TECHNOLOGY, POLLACHI – 642003.
(An Autonomous Institution) DEPARTMENT OF
COMPUTER APPLICATIONS
LAB MANUAL
19CACN2201/ PYTHON PROGRAMMING LAB
MCET /MCA /LM/
ACTIVITY NAME OF THE DESIGNATION SIGNATURE
FACULTY
ASSISTANT
PREPARED Ms. G. DEEPA
BY PROFESSOR
ASSISTANT
VERIFIED BY MS.V.SATHYA
PROFESSOR
APPROVED Dr. R. MUTHUSAMI HOD/MCA
BY
2
INDEX
S.NO EXPRIMENT PAGE
NO
4
1 Develop a simple GUI database application using tkinter package.
2 Install and configure the packages required to develop a website 7
using Django.
3 8
Develop a Django project working with database connection.
4 9
Implement the numpy packages for arrays in python.
5 11
Experiment with Pandas library to perform data analysis in python.
19CACN2201 - PYTHON PROGRAMMING
LABORATORY
Course Code: 19CACN2201 Course Title: PYTHON PROGRAMMING LABORATORY
Core/Elective: Professional L : T : P : C : M – 0 : 0 : 4 : 2 : 100
Core
Type: Lab Total Contact Hours:45
Prerequisites:
➢ 19CACN1102 Programming in C
Course Objectives
At the end of the course students will be able to:
1. Apply the tkinter package in python
2. Implement the packages using Django framework
3. Develop a project using django with database connection
4. Build the numpy packages in python
5. Apply the pandas library in python
List of Experiments:
1. Develop a simple GUI database application using tkinter package.
2. Install and configure the packages required to develop a website using Django.
3. Develop a Django project working with database connection.
4. Implement the numpy packages for arrays in python.
5. Experiment with Pandas library to perform data analysis in python.
Course Outcomes
At the end of the course students will be able to:
CO 1: Apply the tkinter package in python for GUI application
CO 2: Implement the packages using django framework for website development.
CO 2: Develop a django project with database connection for real time application
CO 3: Build the numpy packages for arrays in python
CO 4: Apply the pandas library for data analysis in python
19CACN2201-PYTHON PROGRAMMING
LABORATORY
4
Ex.No:1 DEVELOP A SIMPLE GUI DATABASE APPLICATION USING
TINKER PACKAGE
AIM
To develop a simple GUI database application using tinker
package
ALGORITHM
STEP 1: Start the Process.
STEP 2: Import the tkinter and sqlite3 packages.
STEP 3: Create a Calculator.
STEP 4: Declare the Necessary Variables Like Add,
Subtract, Multiply, Divide.
STEP 5: Insert the Data for Calculation.
STEP 6: Commit the data and Save the program.
STEP 7: Run the Program.
STEP 8: Stop the process
CODING:
from tkinter import *
expression = ""
def press(num):
global expression
expression = expression + str(num)
equation.set(expression)
def equalpress():
try:
global expression
total = str(eval(expression))
equation.set(total)
expression = ""
except:
equation.set(" error ")
expression = ""
def clear():
global expression
expression = ""
equation.set("")
if __name__ == "__main__":
gui = Tk()
gui.configure(background="Dark blue")
gui.title("Simple Calculator")
gui.geometry("270x150")
141CA0307R-JAVA PROGRAMMING LABORATORY
5
equation = StringVar()
expression_field = Entry(gui, textvariable=equation)
expression_field.grid(columnspan=4, ipadx=70)
button1 = Button(gui, text=' 1 ', fg='black', bg='yellow',
command=lambda: press(1), height=1, width=7)
button1.grid(row=2, column=0)
button2 = Button(gui, text=' 2 ', fg='black', bg='yellow',
command=lambda: press(2), height=1, width=7)
button2.grid(row=2, column=1)
button3 = Button(gui, text=' 3 ', fg='black', bg='yellow',
command=lambda: press(3), height=1, width=7)
button3.grid(row=2, column=2)
button4 = Button(gui, text=' 4 ', fg='black', bg='yellow',
command=lambda: press(4), height=1, width=7)
button4.grid(row=3, column=0)
button5 = Button(gui, text=' 5 ', fg='black', bg='yellow',
command=lambda: press(5), height=1, width=7)
button5.grid(row=3, column=1)
button6 = Button(gui, text=' 6 ', fg='black', bg='yellow',
command=lambda: press(6), height=1, width=7)
button6.grid(row=3, column=2)
button7 = Button(gui, text=' 7 ', fg='black', bg='yellow',
command=lambda: press(7), height=1, width=7)
button7.grid(row=4, column=0)
button8 = Button(gui, text=' 8 ', fg='black', bg='yellow',
command=lambda: press(8), height=1, width=7)
button8.grid(row=4, column=1)
button9 = Button(gui, text=' 9 ', fg='black', bg='yellow',
command=lambda: press(9), height=1, width=7)
button9.grid(row=4, column=2)
button0 = Button(gui, text=' 0 ', fg='black', bg='yellow',
command=lambda: press(0), height=1, width=7)
button0.grid(row=5, column=0)
plus = Button(gui, text=' + ', fg='black', bg='yellow',
command=lambda: press("+"), height=1, width=7)
plus.grid(row=2, column=3)
minus = Button(gui, text=' - ', fg='black', bg='yellow',
command=lambda: press("-"), height=1, width=7)
minus.grid(row=3, column=3)
multiply = Button(gui, text=' * ', fg='black', bg='yellow',
command=lambda: press("*"), height=1, width=7)
multiply.grid(row=4, column=3)
divide = Button(gui, text=' / ', fg='black', bg='yellow',
command=lambda: press("/"), height=1, width=7)
divide.grid(row=5, column=3)
equal = Button(gui, text=' = ', fg='black', bg='yellow',
command=equalpress, height=1, width=7)
equal.grid(row=5, column=2)
clear = Button(gui, text='Clear', fg='black', bg='yellow',
command=clear, height=1, width=7)
clear.grid(row=5, column='1')
Decimal= Button(gui, text='.', fg='black', bg='yellow',
command=lambda: press('.'), height=1, width=7)
141CA0307R-JAVA PROGRAMMING LABORATORY
6
Decimal.grid(row=6, column=0)
gui.mainloop()
OUTPUT
RESULT:
Thus the above program has been executed successfully.
141CA0307R-JAVA PROGRAMMING LABORATORY
7
Ex.No:2 INSTALL AND CONFIGURE THE PACKAGES REQUIRED TO
DEVELOP A WEBSITE USING DJANGO
Aim:
To Install and configure the packages required to develop a website using Django.
Algorithm:
Step 1:Start the project.
Step 2:Create required workspace folder for install Django.
Step 3:Open Power shell and go to project folder.
Step 4:Using pip comment install Django and their packages.
Step 5:Use cd.. comment for accessing Django admin site.
Step 6:Use “manage,py runserver” for running localhost port for running Django server.
Step 7:Stop the server
OUTPUT:
RESULT:
Thus the above program is executed and verified successfully.
19CACN2202 – Java Programming Lab
8
Ex. No:3 DEVELOP A DJANGO PROJECT WORKING WITH DATABASE
CONNECTION
Aim:
Develop a Django project working with database connection.
Algorithm:
Step 1:Start the project.
Step 2:Create required workspace folder for install Django.
Step 3:Open Power shell and go to project folder.
Step 4:Using pip comment install Django and their packages.
Step 5:Use cd.. comment for accessing Django admin site.
Step 6:Install SQLite Portable Database and SQLite3 for database connection.
Step 7:Create a new database and enter the datas.
Step 8:Call the database in the command prompt.
Step 9:Run the program.
Step 10:Stop the processCODING:
OUTPUT:
RESULT:
Thus the above program has been executed successfully.
19CACN2202 – Java Programming Lab
9
Ex.No: 4 IMPLEMENT THE NUMPY PACAKAGES FOR ARRAYS IN PYTHON
Aim:
To implement the numpy pacakages for arrays in python
Algorithm:
Step 1:Start the project.
Step 2: Install the numpy packages .
Step 3:Open IDLE shell.
Step 4: Import the numpy packages.
Step 5:Create an array using desired variable .
Step 6: Insert the values and perform operations.
Step 7:Print the values of arrays using the variable.
Step 8:Stop the process.
Output:
19CACN2202 – Java Programming Lab
1
0
RESULT:
Thus the above code has been created and executed successfully.
19CACN2202 – Java Programming Lab
1
1
Ex.No: 5 Experiment with pandas library to perform data analysis in python.
Aim:
To experiment with pandas library to perform data analysis in python.
Algorithm:
Step 1: Start the project.
Step 2: Install required package for pandas.
Step 3: Import pandas in the project.
Step 4: Collect the data set .
Step 5: Start analyse the data using pandas library
Step 6: Collect the report.
Step 7: Stop the project
Output:
19CACN2202 – Java Programming Lab
1
2
19CACN2202 – Java Programming Lab
1
3
RESULT:
Thus the above code has been created and executed successfully.
###END###
19CACN2202 – Java Programming Lab