r21 - PP Lab Manual
r21 - PP Lab Manual
DEPARTMENT OF
ELECTRONICS & COMMUNICATION ENGINEERING
[Type text]
II B. TECH - I SEM (R-21) ECE: PP LAB
DEPARTMENT OF E.C.E.
NAME
ROLL NO.
ACD.YEAR 2022-23
2. ____________________________
14. Consider turtle object. Write functions to draw triangle, rectangle, polygon, circle and
sphere. Use object-oriented approach.
15. Using turtles concept draw Olympic Symbol.
16. The time module provides a function, also named time that returns the current Greenwich
Mean Time in “the epoch”, which is an arbitrary time used as a reference point
a. >>> import time
b. >>>time.time () 14377460 94.5735958
Write a script that reads the current time and converts it to a time of day in hours,
minutes, and seconds, plus the number of days since the epoch.
17. Given a text of characters, write a program which counts number of vowels, consonants and
special characters.
18. Write program which performs the following operations on list’s. Don’t use built-in
functions a) Updating elements of a list b) Concatenation of list’s c) Check for member in
the list d) Insert into the list e) Sum the elements of the list f) Push and pop element of list
g) Sorting of list h) Finding biggest and smallest elements in the list i) Finding common
elements in the list
19. Design a Python script using the Turtle graphics library to construct a turtle bar chart
representing the grades obtained by N students read from a file categorizing them into
distinction, first class, second class, third class and failed.
20. Develop Python Program to create Login Screen and evaluate user Input?
CO PYTHON PROGRAMMING LABORATORY
Student should be able to understand the basic concepts of Python Programming
CO1
language such as conditional processing, Loops, and other data structures.
CO2 Ability to explore python especially the built-in objects of Python.
Ability to create practical and contemporary applications such as Machine Learning
CO3
algorithms.
INDEX
Name of the student: Roll No:
In this, we will learn to install and run Python on your computer. Once we do that, we will
also write our first Python program.
Python is a cross-platform programming language, which means that it can run on multiple
platforms like Windows, macOS, Linux, and has even been ported to the Java and .NET virtual
machines. It is free and open-source.
Install Python Separately: Here's how we can install and run Python on your computer.
1. Download the latest version of Python (https://www.python.org/downloads/)
The most stable Windows downloads are available from the Python for Windows page.
On Windows, we have a choice between 32-bit (labeled x86) and 64-bit (labeled x86–64)
versions, and several flavors of the installer for each.
2. Run the installer file and follow the steps to install Python
During the install process, check Add Python to environment variables. This will add
Python to environment variables, and you can run Python from any part of the
computer.
Step 1: Select Version of Python to download Full Installer and install
Download windows x86 – 64 executable file only as installer will automatically
install 32 bit or 64 bit of python according to the system configuration.
Step 2: Download Python Executable Installer and install it
Double-click the executable file, which is downloaded.
Click on the Add Path check box, it will set the Python path automatically.
Try typing in 1 + 1 and press enter. We get 2 as the output. This prompt can be used as a
calculator. To exit this mode, type ^Z (ctrl z) or quit() and press enter. To exit the command line,
type exit() and press enter.
Step 5: Run python
Python has been installed in your system, now go to
Windows search
Type IDLE
Open it.
Run your First Python code
Run Python in the Integrated Development Environment (IDE):
We can use any text editing software to write a Python script file.
We just need to save it with the .py extension. But using an IDE can make our life a lot
easier. IDE is a piece of software that provides useful features like code hinting, syntax highlighting
and checking, file explorers, etc. to the programmer for application development.
By the way, when we install Python, an IDE named IDLE is also installed. We can use it to
run Python on your computer. It's a decent IDE for beginners.
When we open IDLE, an interactive Python Shell is opened. IDLE is Python’s Integrated
Development and Learning Environment.
Now we can create a new file and save it with .py extension. For example, hello.py
Write Python code in the file and save it. To run the file, go to Run > Run Module or simply click
F5.
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY:
In this, we will learn all about Python’s math module. Mathematical calculations are an
essential part of most Python development. Whether we are working on a scientific project, a
financial application, or any other type of programming endeavor.
For straightforward mathematical calculations in Python, you can use the built-in
mathematical operators, such as addition (+), subtraction (-), division (/), and multiplication (*).
But more advanced operations, such as exponential, logarithmic, trigonometric, or power functions,
are not built in.
The Python math module is an important feature designed to deal with mathematical
operations. It comes packaged with the standard Python release and has been there from the
beginning.
math.ceil() will return the smallest integer value that is greater than or equal to the given
number.
floor() will return the closest integer value that is less than or equal to the given number.
This function behaves opposite to ceil().
As with ceil(), when the input for floor() is an integer, the result will be the same as the
input number.
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
>>> import math
>>> math.pi
Output: 3.141592653589793
>>> math.tau
Output: 6.283185307179586
>>> # Euler’s number (e) is a constant that is the base of the natural logarithm
>>> math.e
Output: 2.718281828459045
>>> math.factorial(7)
Output: 5040
>>> math.pow(2, 5)
Output: 32.0
>>> 2**5
Output: 32
>>> math.exp(2)
Output: 7.38905609893065
>>> math.ceil(6)
Output: 6
>>> math.ceil(6.4)
Output: 7
>>> math.floor(5.532)
Output: 5
>>> import math
>>> math.sin(3.14159)
Output: 2.65358979335273e-06
>>> math.sin(0)
Output: 0.0
>>> math.sin(90)
Output: 0.8939966636005579
RESULT:
Exp. No. 2
Dt.
SUM OF GIVEN ‘N’ NUMBERS
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY:
Here, we can how to find the sum of n numbers using a function in python.
In this example, I have taken an input. The function is defined as def sum(n).
The if condition is used if the input is less than 1 it returns n itself, if the number is greater
than one the else condition is executed and then n is added to sum(n-1).
The print(“The sum is: “, sum(num)) is used to get the output.
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
OUTPUT:
RESULT:
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY:
The Fibonacci numbers are the numbers in the following integer sequence.
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ……..
In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
OUTPUT:
RESULT:
Exp. No. 4
Dt.
MULTIPLICATION TABLE OF A GIVEN NUMBER
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
OUTPUT:
RESULT:
AIM: Write a Python program to read a list of names from keyboard, sort them and write them into
a File.
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY:
Reading and writing files is an important functionality in every programming language.
Almost every application involves writing and reading operations to and from a file. To enable the
reading and writing of files programming languages provide File I/O libraries with inbuilt methods
that allow the creation, updation as well as reading of data from the files.
The open(filepath, mode) is used to open the required file in the desired mode. The open()
method supports various modes of which three are of main concern:
r: read (default) Python and w: write
write(): Inserts the string str1 in a single line in the text file.
read(): used to read data from the file opened using the open() method.
Read a Text file In Python using read(): The file is opened using the open() method in reading r
mode. The data read from the file is printed to the output screen using read() function. The file
opened is closed using the close() method.
Write in a Text file In Python using write(): The file is opened with the open() method in w+
mode within the with block, the w+ argument will create a new text file in write mode with the help
of write(). The with block ensures that once the entire block is executed the file is closed
automatically.
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
OUTPUT:
RESULT:
AIM: Write a Python program to concatenate two files content and write the result into a new File.
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY:
Let the given two files be file1.txt and file2.txt. Our Task is to merge both files into third file
say file3.txt. The following are steps to merge.
1. Open file1.txt and file2.txt in read mode.
2. Open file3.txt in write mode.
3. Read the data from file1 and add it in a string.
4. Read the data from file2 and concatenate the data of this file to the previous string.
5. Write the data from string to file3
6. Close all the files
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
Output data is
RESULT:
Exp. No. 7
Dt.
ADDITION OF TWO MATRICES
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY: To represent a matrix, we are using the concept of nested lists. All the elements of both
the input matrices are represented as nested lists. All the elements of output list are initialized as
zero. We are iterating the matrix and adding the corresponding elements of both the given matrices
and assigning the value in the output matrix.
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
OUTPUT:
RESULT:
Exp. No. 8
Dt.
COUNT OCCURRENCES OF A WORD IN TEXT FILE
AIM: Write a Python program to search a given word in the given text file and display the number
of occurrences of the string.
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY: To count the number of occurrences of a specific word in a text file, read the content of
text file to a string and use String.count() function with the word passed as argument to the count()
function. Following is the syntax of count() function. i.e., n = String.count(word)
Where word is the string, and count() returns the number of occurrences of word in this String.
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
OUTPUT:
RESULT:
Exp. No. 9
Dt.
LCM AND GCD (HCF) OF TWO GIVEN NUMBERS
AIM: Write a Python program to find the LCM and GCD (HCF) of 2 given numbers.
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY:
Greatest common Divisior (GCD): In Mathematics, the Greatest Common Divisor (GCD) of two
or more integers is the largest positive integer that divides given integer values.
For example, the GCD value of integer 8 and 12 is 4 because both 8 and 12 are divisible by 1, 2,
and 4 (the remainder is 0), and the largest positive integer among them is 4.
The Greatest Common Divisor (GCD) is also known as Highest Common Factor (HCF), or
Greatest Common Factor (GCF), or Highest Common Divisor (HCD), or Greatest Common
Measure (GCM).
Least Common Multiple (LCM): In Mathematics, the Least Common Multiple (LCM) of two or
more integers is the smallest positive integer that is totally divisible by the given integer values.
Remainder should be zero after division.
For example, the LCM value of integer 2 and 3 is 12 because 12 is the smallest positive integer that
is divisible by both 2 and 3 (the remainder is 0).
The least common multiple is also known as lowest common multiple, or smallest common
multiple of two integers.
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
OUTPUT:
RESULT:
AIM: Write a Python program to find mean, median & mode for the given set of numbers in a list.
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY:
We probably start by finding the mean (or average), the median, and the mode of the data.
These are central tendency measures and are often our first look at a dataset. We'll first code a
Python function for each measure followed by using Python's statistics module to accomplish the
same task.
Mean - The average value
Median - The mid-point value
Mode - The most common value
Mean of a Sample: If we have a sample of numeric values, then its mean or the average is the total
sum of the values (or observations) divided by the number of values.
Say we have the sample [4, 8, 6, 5, 3, 2, 8, 9, 2, 5]. We can calculate its mean by performing the
operation: (4 + 8 + 6 + 5 + 3 + 2 + 8 + 9 + 2 + 5) / 10 = 5.2
Median of a Sample: The median of a sample of numeric data is the value that lies in the middle
when we sort the data. The data may be sorted in ascending or descending order, the median
remains the same.
Mode of a Sample: The mode is the most frequent observation (or observations) in a sample. If we
have the sample [4, 1, 2, 2, 3, 5], then its mode is 2 because 2 appears two times in the sample
whereas the other elements only appear once.
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
OUTPUT:
RESULT:
Exp. No. 11
CREATE OWN PYTHON MODULES
Dt.
AIM: Write the Python program for addition, subtraction, multiplication, and division using
function and access them by another Program.
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY:
Create Python modules:
To create a Python module, open a Python script, write some statements and functions, and
save it with .py extension. Later on, we can call and use these modules anywhere in our
program.
Let’s create a new module named “MathOperations”. This module contains functions to
perform addition, subtraction, multiplication, and division.
Now, we can call this (MathOperations) module anywhere using the import command, and
we can use these functions to perform the related tasks. There is no need to write the code
again and again for performing addition, subtraction, multiplication, and division
operations.
Call your module:
Let’s call this module in our other Python script by using the import command. Check out
this, to learn more about the Python import command.
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
OUTPUT:
RESULT:
Exp. No. 12
Dt.
OBJECT-ORIENTED FEATURES USING PYTHON
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY:
In Python, object-oriented Programming (OOPs) is a programming paradigm that uses
objects and classes in programming. It aims to implement real-world entities like inheritance,
polymorphisms, encapsulation, etc. in the programming.
Some points on Python class:
Classes are created by keyword class.
Attributes are the variables that belong to a class.
Attributes are always public and can be accessed using the dot (.) operator. Eg.:
Myclass.Myattribute.
An object consists of:
State: It is represented by the attributes of an object. It also reflects the properties of an
object.
Behavior: It is represented by the methods of an object. It also reflects the response of an
object to other objects.
Identity: It gives a unique name to an object and enables one object to interact with other
objects.
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
OUTPUT:
RESULT:
Exp. No. 13
Dt.
PYRAMID WITH HASHES (#) SYMBOLS
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY: To print pyramid pattern of stars, numbers, or alphabets in python, you have to use two
or more for loops. In most of the program that contains two for loops. The first loop corresponds to
rows, whereas the second loop corresponds to columns.
The range() function returns a sequence of values. By default, the value starts with 0 and
increments by 1. It stops before a number specified as argument of the function.
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
OUTPUT:
RESULT:
Exp. No. 14
Dt.
TURTLE PROGRAMMING IN PYTHON
AIM: Write a program to draw triangle, rectangle, polygon, circle and sphere using python turtle.
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY:
Turtle graphics is a popular way for introducing programming to kids.
Turtle is a Python library which used to create graphics, pictures, and games.
The Logo programming language was popular among the kids because it enables us to draw
attractive graphs to the screen in the simple way. It is like a little object on the screen, which
can move according to the desired position. Similarly, turtle library comes with the
interactive feature that gives the flexibility to work with Python.
Turtle is a pre-installed library in Python that is similar to the virtual canvas that we can
draw pictures and attractive shapes. It provides the onscreen pen that we can use for
drawing.
The Python turtle library consists of all important methods and functions that we will need
to create our designs and images. Import the turtle library using the following command.
>>> import turtle
forward(distance) or turtle.fd(distance): It moves the turtle in the forward direction by a certain
distance. It takes one parameter distance, which can be an integer or float.
back(distance) or turtle.bk or turtle.backward(distance): This method moves the turtle in the
opposite direction the turtle is headed. It doesn't change the turtle heading.
right(angle) or turtle.rt(angle): This method moves the turtle right by angle units.
left(angle) or turtle.lt(angle): This method turn the turtle left by angle units.
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
OUTPUT:
OUTPUT:
OUTPUT:
RESULT:
Exp. No. 15
Dt.
OLYMPIC SYMBOL IN PYTHON USING TURTLE
AIM: Write a program to draw Olympic Symbol using Python turtles concept.
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY:
The standard library of the Python programming language now contains a Turtle graphics
module. Turtle in Python, like its Logo ancestor, allows programmers to manipulate one or more
turtles in a two-dimensional space.
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
OUTPUT:
RESULT:
Exp. No. 16
Dt.
PYTHON TIME FUNCTIONS – TIME MODULE
AIM: The time module provides a function, also named time that returns the current Greenwich
Mean Time (GMT) in “the epoch”, which is an arbitrary time used as a reference point
>>> import time
>>>time.time ()
Write a script that reads the current time and converts it to a time of day in hours, minutes, and
seconds, plus the number of days since the epoch.
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY:
Every computer system comes with a clock pre-programmed to a specific date, time, and
time zone. Python time module provides the ability to read, represent, and reset the time
information in many ways.
Essential facts about the Time module:
The time module wraps around the C runtime library to provide functions for time
manipulation. It has a set of functions which you can call to deal with the system time.
This module follows the EPOCH convention which refers to the point where the time starts.
It supports the dates and times from the epoch to the year 2038.
The Unix EPOCH is midnight on 12:00 am January 1, 1970. To determine the EPOCH
value on your system, use the following code.
>>> import time
>>> time.gmtime(0)
time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0,
tm_wday=3, tm_yday=1, tm_isdst=0)
Note: The function time.gmtime() returns a struct_time object.
The term “Seconds since the Epoch” or the “No. of Ticks since epoch” represents the time
(in seconds) elapsed since the epoch.
Some time functions return time in DST format. DST is the Daylight Saving Time. It is a
mechanism which moves the clocks forward by 1 hour during the summer time, and back again in
the fall.
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
OUTPUT:
RESULT:
AIM: Write a python program which counts number of vowels, consonants and special characters
from the given text of characters or string.
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY:
A string is a sequence of characters. Those characters can be vowels, consonants, digits, or
any special characters. Given a string and the task is to count vowels, consonant, digits and special
character in string. Special character also contains the white space.
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
OUTPUT:
RESULT:
Exp. No. 18
Dt.
OPERATIONS ON PYTHON LIST
AIM: Write a python program which performs the following operations on list’s: (a) Updating
elements of a list, (b) Concatenation of list’s, (c) Check for member in the list, (d) Insert into the
list, (e) Sum the elements of the list, (f) pop element of list, (g) Sorting of list, (h) Finding biggest
and smallest elements in the list, (i) Finding common elements in the list.
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY:
List is a type of data structuring method that allows storing of the integers or the characters
in an order indexed by starting from 0. List operations are the operations that can be performed on
the data in the list data structure.
A few of the basic list operations used in Python programming are extend(), insert(),
append(), remove(), pop(), slice, reverse(), min() & max(), concatenate(), count(), multiply(), sort(),
index(), clear(), etc.
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
OUTPUT:
RESULT:
Exp. No. 19
Dt.
CREATE LOGIN FORM USING PYTHON TKINTER
AIM: write a Python program to create a Login Form in Python GUI application using tkinter.
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
THEORY:
Tkinter is the standard GUI library for Python. Python when combined with Tkinter
provides a fast and easy way to create GUI applications. Tkinter provides a powerful object-
oriented interface to the Tk GUI toolkit.
To create a tkinter app:
1. Importing the module tkinter
2. Create the main window (container)
3. Add any number of widgets to the main window
4. Apply the event Trigger on the widgets.
mainloop(): There is a method known by the name mainloop() is used when your application is
ready to run. mainloop() is an infinite loop used to run the application, wait for an event to occur
and process the event as long as the window is not closed.
Button: To add a button in your application, this widget is used.
The general syntax is: W = Button(parent, options) or w = Button(master, option=value)
Entry: The Entry widget is used to provde the single line text-box to the user to accept a value
from the user. We can use the Entry widget to accept the text strings from the user. It can only be
used for one line of text from the user. For multiple lines of text, we must use the text widget.
The syntax to use the Entry widget is given below.
Syntax: w = Entry(parent, options) or w = Entry(master, option=value)
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PROGRAM CODE:
OUTPUT:
RESULT:
Exp. No. 20
Dt.
CALCULATE GRADE OF STUDENT IN PYTHON
SOFTWARE REQUIRED:
1. PC with Windows 10
2. IDLE Python 3.8.2 or Above Version
PROCEDURE:
1. Double click on Python IDLE shortcut icon on windows desktop or type IDLE in search bar
and press the enter button.
2. Python IDLE opens up in a shell. Here, we can type code in get the result out.
3. To open an editor screen, "File → New File".
4. Type and save ("File → Save As") the program with filename.py extension.
5. Execute the program, Run → Run Module (Press F5).
6. Observe the output values on Python Shell and observe the waveforms on figure window.
PRAGRAM CODE:
OUTPUT:
RESULT:
Exp. No. 21
Dt.
INVERTED PYRAMID WITH HASHE (#) SYMBOLS
PROGRAM CODE:
OUTPUT:
RESULT:
Exp. No. 22
Dt.
MEMBERSHIP OPERATORS
AIM: Write a program to read a list of numbers and write a program to check whether a particular
element is present or not using membership operators.
PROGRAM CODE:
# Membership Operator
# Python program to illustrate
# not 'in' operator
x = 24
y = 20
list = [10, 20, 30, 40, 50]
if (x not in list):
print("x is NOT present in given list")
else:
print("x is present in given list")
if (y in list):
print("y is present in given list")
else:
print("y is NOT present in given list")
OUTPUT:
x is NOT present in given list
y is present in given list
RESULT:
Exp. No. 23
Dt.
DISPLAY 100 YEARS OLD PERSON DETAILS
AIM: Write a Python program to display the year in which you will turn 100 years old.
PROGRAM CODE:
# he/she will turn 100 years old.
name = input ("Enter the Name:: ")
age = int (input("Enter the Age::"))
# Let present year is 2022
user_age = (100 - age) + 2022
print ("The user will in year ", user_age ,"he/she will turn 100 years old.")
OUTPUT:
RESULT:
Exp. No. 24
Dt.
REVERSE A NUMBER IN PYTHON
PROGRAM CODE:
OUTPUT:
RESULT:
PBRVITS was pioneered by technocrats with a lot of industrial and educational experience
with a vision to provide the society with a center of learning that motivates, supports and
encourages the youth to evolve into dynamic professionals with a social commitment. 22 years of
excellence in Engineering education PBRVITS offering both U.G & P.G programs.
PBRVITS is offering a curriculum integrated with soft skills and personality training
through which 100% placements are achieved
HIGHLIGHTS :
VISION:
To be a premier centre of learning in Engineering and Management education that evolves the youth into
dynamic professionals with a social commitment
MISSION
To provide quality teaching-learning practices in engineering and management education by imparting core
instruction and state-of-the-art infrastructure.
To engage the faculty and students in acquiring competency in emerging technologies and research activities
through Industry Institute Interaction.
To foster social commitment in learners by incorporating leadership skills and ethical values through value-
based education