231ges114l-Pspp Lab Manual-2023r (Students)
231ges114l-Pspp Lab Manual-2023r (Students)
COLLEGE
231GES114L-PROBLEM
SOLVING THROUGH PYTHON
PROGRAMMING
LABORATORY
LAB MANUAL
(Student Copy)
I YEAR IT
LIST OF EXPERIMENTS
1. Identification and solving of simple real life or scientific or technical problems, and developing
flow charts for the same. (Electricity Billing, Retail shop billing, Sin series, weight of a
motorbike, Weight of a steel bar, compute Electrical Current in Three Phase AC Circuit, etc.)
2. Python programming using simple statements and expressions (exchange the values of two
variables, circulate the values of n variables, distance between two points).
3. Scientific problems using Conditionals and Iterative loops. (Number series, Number Patterns,
pyramid pattern)
4. Implementing real-time/technical applications using Lists, Tuples. (Items present in a
library/Components of a car/ Materials required for construction of a building –operations of list
& tuples)
5. Implementing real-time/technical applications using Sets, Dictionaries. (Language, components
of an automobile, Elements of a civil structure, etc.- operations of Sets & Dictionaries)
6. Implementing programs using Functions. (Factorial, largest number in a list, area of shape)
12. Developing a game activity using Pygame like bouncing ball, car race etc.
60 PERIODS
COURSE OUTCOMES:
Upon completion of this course, student will be able to:
CO1: Develop algorithmic solutions to simple computational problems
CO2: Implement programs in Python using conditionals and loops for solving problems
CO3: Deploy functions to decompose a Python program
CO4: Process compound data using Python data structures.
CO5: Design Python programs for file handling and exception handling.
CO6: Create GUI application for user defined requirement.
Ex. No. DATE PROGRAM MARKS SIGNATURE
1.a Identification and solving of simple real
life and developing flow chart for the same
for Electricity Billing
1.b Identification and developing flow chart for
Retail shop billing
1.c Identification and developing flow chart for
Sin series
1.d Develop a flow chart for calculating the
weight of a motorbike / Weight of a steel bar
1.e Develop a flow chart to compute Electrical
Current in Three Phase AC Circuit
2.a Python programming using simple
statements and expressions - exchange the
values of two variables
2.b circulate the values of n variables
Add Python 3 to your path. You can test it first by specifying the full path. You
should add $HOME/python3_install/bin to your PATH bash variable.
$ ~/python3_install/bin/python3
Python 3.4.3 (... size and date information ...)[GCC 4.5.2] on
linux2
Type "help", "copyright", "credits" or "license" for more
information. >>>
The above commands will install Python 3 to your home directory, which is probably
what you want, but if you skip the --prefix=$HOME/python3_install, it will install it to
/usr/local. If you want to use the IDLE graphical code editor, you need to make sure that the
tk and tcl libraries, together with their development files, are installed on the system. You will
get a warning during the make phase if these are not available.
Configuring your PATH environment variable
The PATH environment variable is a list of folders, separated by semicolons, in which
Windows will look for a program whenever you try to execute one by typing its name at a
Command Prompt. You can see the current value of your PATH by typing this command at a
Command Prompt:
The easiest way to permanently change environment variables is to bring up the
built-in environment variable editor in Windows. How you get to this editor is slightly
different on different versions of Windows.
On Windows 8 or Windows 10:
Press the Windows key and type Control Panel to locate the Windows Control Panel.
Once you've opened the Control Panel, select View by: Large Icons,
then click on System. In the window that pops up, click the Advanced System Settings link,
then click the Environment Variables... button.
On Windows 7 or Vista:
Click the Start button in the lower-left corner of the screen, move your mouse over
Computer, right-click, and select Properties from the pop-up menu. Click the Advanced
System Settings link, then click the Environment Variables... button.
On Windows XP:
Right-click the My Computer icon on your desktop and select Properties. Select the
Advanced tab, then click the Environment Variables... button.
Once you've brought up the environment variable editor, you'll do the same thing
regardless of which version of Windows you're running. Under System Variables in the
bottom half of the editor, find a variable called PATH. If there is is one, select it and click
Edit.... Assuming your Python root is C:\Python34, add these two folders to your path (and
make sure you get the semicolons right; there should be a semicolon between each folder in
the list):
>>>
The >>> is Python's way of telling you that you are in interactive mode. In interactive
modewhat you type is immediately run. Try typing 1+1 in. Python will respond with 2.
Interactive mode allows you to test out and see what Python will do. If you ever feel the
need to play with new Python statements, go into interactive mode and try them out. A
sample interactive session:
If you try to enter this as written in the interactive environment, you might be surprised
by the result:
What the interpreter is saying is that the indentation of the second print was
unexpected. You should have entered a blank line to end the first (i.e., "if") statement, before
you started writing the next print statement. For example, you should have entered the
statements as though they were written:
Which would have resulted in the following:
Interactive mode
Instead of Python exiting when the program is finished, you can use the - i flag
tostart an interactive session. This can be very useful for debugging and prototyping.
Exp:1(a) Identification and solving of simple real life or scientific or technical problems
Date: and developing flow chart for Electricity billing
AIM:
To construct an algorithm and flowchart for electricity bill in python.
ALGORITHM:
STEP 1: Start
STEP 2: nput unit consumed by customer
STEP 3: f unit consumed less or equal to 200 units. Then Total_charge = no.of.unit *
2.50
STEP4: f unit consumed more than 201 units but less than 500 units. Then add the first
200 units amounti.e. 2.50. Which is given by Total_charge=
(no.of.unit- 200)*3.50+(200*2.50).
STEP 5: f unit consumed more than 501units. Then add first two units 200 and
500units amount i.e. 2.50& 3.50. Which is given by Total_charge=
no.of.unit- 0)*5.00+(300*3.50)+(200*2.50).
STEP 6: Similarly check rest of the conditions and calculate total amount.
STEP 7: After calculating total amount print the statement in Total charge.
STEP 8: Stop.
RESULT:
Thus the problem is identified and the solution is successfully given with a
flowchart.
Exp:1(b) Identification and solving of simple real life and
Date: developing flow chart for Retail Shop Billing
AIM:
To construct an algorithm and flowchart for retail shop billing in
python.
ALGORITHM:
STEP 1: Start.
STEP 2: Open the APP.
STEP 3: Initialize or select the packages/items.
STEP4: Add product details.(insert/delete/update).
STEP 5: Scan barcode.
STEP 6: Check shopping.
STEP 7: Calculate total, update database and give feedback.
STEP 8: Make payment .
STEP 9: Stop.
FLOWCHART:
RESULT:
Thus the problem is identified and the solution is successfully
given with a flowchart.
Exp:1(c) Identification and solving of simple scientific problems
Date: and developing flow chart for Sin series
AIM:
To construct an algorithm and flowchart for calculating sine series
in python.
ALGORITHM:
STEP 1:
STEP 2:
STEP 3:
STEP4:
STEP 5:
STEP 6:
STEP 7:
STEP 8:
FLOWCHART:
RESULT:
Thus the problem is identified and the solution is successfully
given with a flowchart.
Exp:1(d) Identification and solving of simple real life or
Date: scientific or technical problems and developing flow
charts for calculating weight of steel bar
AIM:
To construct an algorithm and flowchart for calculating weight of
a steel bar in python .
ALGORITHM:
FLOWCHART:
RESULT:
Thus the problem is identified and the solution is successfully
given with a flowchart.
Exp:1(e) Identification and solving of simple real life or
Date: scientific or technical problems and developing flow
charts for Calculating Electrical Current in Three
Phase Ac Circuit
AIM:
To construct an algorithm and flowchart for calculating electrical
current in three phase ac circuit in python
ALGORITHM:
FLOWCHART:
RESULT:
Thus the problem is identified and the solution is successfully
given with a flowchart.
Exp:2 (a) Python programming using simple statements and
expressions
EXCHANGE OF THE VALUES OF TWO VARIABLES
Date:
AIM:
To write a Python program to perform Swapping of two numbers.
ALGORITHM:
Step 1:Define a function swap and call the function. Step 2:Get the
first number
Step 3:Get the second number
Step 4:Print the numbers before swapping
Step 5:Assign the first number with temporary variable ‘temp’ Step
6:Store the second number to the first number
Step 7:Reassign the second number to the temporary variable Step
8:Print the Swapped values.
Step 9: Stop
PROGRAM: Method-1-without using another variable
x=5
y=7
print ("Before swapping: ")
print("Value of x : ", x, " and y : ", y)
x=x+y
y=x-y
x=x-y
RESULT:
Thus the Python programs to exchange the values between
two variables are executed successfully and the output is
verified.
Exp:2 (b) Python programming using simple statements and
Date: expressions
CIRCULATE THE VALUES OF N VARIABLES
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:2 (c) Python programming using simple statements and
Date: expressions
DISTANCE BETWEEN TWO POINTS
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:3 (a) SCIENTIFIC PROBLEMS USING CONDITIONALS AND
ITERATIVE LOOPS NUMBER SERIES
Date:
FIBONACCI SERIES
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:3 (b) SCIENTIFIC PROBLEMS USING CONDITIONALS AND
ITERATIVE LOOPS NUMBER SERIES
Date:
NUMBER PATTERN
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:3 (c) SCIENTIFIC PROBLEMS USING CONDITIONALS AND
ITERATIVE LOOPS NUMBER SERIES
Date:
PYRAMID PATTERN
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:4 (a) Implementing real-time/technical applications using Lists, Tuples
Date: Items present in a library - operations of List and Tuples
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:4 (b) Implementation of car component
Date: Operations of List and Tuples
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:4 (c) Implementing list on construction of a building
Date: Operations of List and Tuples
AIM:
ALGORITHM:
PROGRAM:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:5 (a) Implementing real-time/technical applications using Sets,
Date: Dictionaries.
Components of an automobile
Operations of Sets & Dictionaries
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:5 (b) Implementing real-time/technical applications using Sets,
Date: Dictionaries.
Implement Elements of a civil structure
Operations of Sets & Dictionaries
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:6 (a) Implementing programs using Functions
Date: FACTORIAL
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:6 (b) Implementing programs using Functions
Date: LARGEST OF TWO NUMBER IN A LIST
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:6 (c) Implementing programs using Functions
Date: AREA OF SHAPES
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:7 (a) Implementing programs using Strings
Date: REVERSE WORD IN STRING
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:7 (b) Implementing programs using Strings
Date: PALINDROME
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:7 (c) Implementing programs using Strings
Date: CHARACTER COUNT
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:7 (d) Implementing programs using Strings
Date: REPLACE A CHARACTER
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:8 (a) Implementing programs using written modules and Python
Date: Standard Libraries - Pandas
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:8 (b) Implementing programs using written modules and Python
Date: Standard Libraries - Numpy
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:8 (c) Implementing programs using written modules and Python
Date: Standard Libraries - Matplotlib
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:8 (d) Implementing programs using written modules and Python
Date: Standard Libraries - Scipy
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:9 (a) Implementing real-time/technical applications using File
Date: handling.
FILE COPYING
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:9 (b) Implementing real-time/technical applications using File
Date: handling.
WORD COUNT
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:9 (c) Implementing real-time/technical applications using File
Date: handling.
TO FIND THE LONGEST WORD IN THE GIVEN
CONTENT
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:10 (a) Implementation real time technical application using
Date: Exception Handling
DIVIDED BY ZERO ERROR
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:10 (b) Implementation real time technical application using
Date: Exception Handling
VOTER’S AGE VALIDATION
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:10 (c) Implementation real time technical application using
Date: Exception Handling
STUDENT MARK RANGE VALIDATION
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:11 EXPLORING PYGAME TOOL
Date:
AIM:
PROCEDURE:
PROGRAM:
# Simple pygame program
RESULT:
Thus the program was executed and the output was verified
successfully.
12 (a) Developing a game activity using Pygame
Date: BOUNCING BALL
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
Thus the program was executed and the output was verified
successfully.
Exp:13 MINI PROJECT
Date:
TITLE :
AIM:
ALGORITHM:
PROGRAM:
OUTPUT:
RESULT:
REPORT
SUBMITTED
ON:
COMPLETED
SIGNATURE: