0% found this document useful (0 votes)
18 views22 pages

Lab Manual

Uploaded by

divya.desamala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views22 pages

Lab Manual

Uploaded by

divya.desamala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Introduction of Python:

Installing Python is a straightforward process. Here are the general steps to install Python on different
platforms:

For Windows:

1. Download Installer: Go to the official Python website


(https://www.python.org/downloads/windows/) and download the latest Python installer for
Windows.

2. Run Installer: Run the downloaded installer. Make sure to check the box that says "Add Python
X.X to PATH" during the installation. This will allow you to use Python from the command
prompt.

3. Installation: Follow the on-screen instructions to complete the installation. Python will be
installed in the default location, or you can choose a different location if desired.

4. Verification: Open a Command Prompt and type python to start the Python interpreter. You
should see the Python prompt >>> indicating that Python is installed and working.

Python idle

It seems like you're asking about Python IDLE. IDLE stands for "Integrated Development and Learning
Environment." It's a basic Integrated Development Environment (IDE) that comes bundled with Python
and provides an interactive environment for writing and running Python code. IDLE is commonly used
for quick code testing, learning, and small projects.

Here's how you can use Python IDLE:

1. Open IDLE: Depending on your operating system, you can typically find Python IDLE in your
Start menu (Windows) or Applications folder (macOS). Alternatively, you can open your
terminal or command prompt and type idle or python -m idlelib.idle to launch IDLE.

2. Interactive Shell: When IDLE opens, you'll see the Python shell where you can directly type and
execute Python commands and see their immediate results.

3. Editor Window: IDLE also includes an editor window where you can write longer scripts and
save them as .py files. To open a new editor window, go to "File" > "New File."

4. Writing Code: In the editor window, you can write your Python code. Once you've written the
code, you can run it by clicking the "Run" menu and selecting "Run Module" or by pressing F5.

5. Output and Interaction: The output of your code (print statements, results of calculations, etc.)
will appear in the Python shell or in a new output window, depending on the complexity of your
code.

6. Saving Files: To save your script, go to "File" > "Save" and choose a location on your computer.
You can save the file with a .py extension.
7. Closing IDLE: To exit IDLE, simply close the IDLE window. If you have unsaved work, IDLE
will prompt you to save before exiting.

While IDLE is useful for simple tasks and learning purposes, more advanced projects might benefit from
using more feature-rich IDEs like Visual Studio Code, PyCharm, or Sublime Text. These IDEs offer
advanced code editing features, debugging tools, project management, and integration with version
control systems.

PROGRAMS:

1. Write and execute simple python Program.


print (“hello world”)
hello world

2. Write /execute simple ‘Python’ program: Develop minimum 2 programs using different
data types (numbers, string, tuple, list, and dictionary).
Numbers:
1. a=2
print(a)
#Output:
2
print(type(a))
#Output:
<class 'int'>

2. a=45
b=50
print(a)
#Output:
45
print(b)
#Output:
50
print(type(a))
#Output:
<class 'int'>
print(type(b))
#Output:
<class 'int'>
int
x=10
print(x)
print(type(x))
#output:
10
<class ‘x’>
float:
c=0.5
print(float)
#Output:
0.5
print(type(c))
#Output:
<class 'float'>

d=8.0
print(float)
8.0
print(type(d))
#Output:
<class 'float'>

String:
a=Gita
print(“Name:”,name)
#Output:
Name:Gita

city=Guntur
print(“city:”,city)
#Output:
city:Guntur

list:
#creating numbers list:
mylist=[1,2,3,4]
print(“Numbers list:”,mylist)
#Output:
Numbers list:[1,2,3,4]

#creating list with different types


mylist1=[1,2.2,”Hello”,’c’]
print(“Different list elements:”,mylist1)
#Output:
[1,2.2,’Hello’,’c’]

Tuple :
mytuple=(“Amravathi”,”Vijayawada”)
print(“Tuple elements:”,mytuple,end=” “)
#Output:
Tuple Elements:(‘Amravathi’,’Vijayawada’)

mytuple1=(50,60,70,80)
print(“Tuple Elements:”,mytuple1,end=’’ “)
#Output:
Tuple Elements:(50,60,70,80)

Dictionary:
mydic={1:’mango’,2:’banana’}
print(“My dictionary elements:”,mydic)
#Output:
My dictionary elements:{1: ’mango’,2:’banana’}

mydic1={‘fruit’:’mango’,1:[4,6,8]}
print(“My dictionary elements:”,mydic)
#Output:
My dictionary elements:{ fruit’:’mango’,1:[4,6,8]}

Complex Numbers
y=3+10j
print(y)
print(type(y))
#Output:
3+10j
<class ‘complex’>

z=10-5j
print(z)
print(type(z))
#Output:
10-5j
<class ‘complex’>

3. Write /execute simple ‘Python’ program: Develop minimum 2 programs using Arithmetic
Operators, exhibiting data type conversion
x=10
y=15
print("addition:",x+y)
print("subtraction:",x-y)
print("multiplication:",x*y)
print("division:",x/y)
print("modulus:",x%y)# returns the remainder after division
print("exponentiation:",x**y) #raise a number to a power.
print("floor division:",x//y) #returns the integer part of the division result.
#Output:
addition: 25
subtraction: -5
multiplication: 150
division: 0.6666666666666666
modulus: 10
exponentiation: 1000000000000000
floor division: 0

#Type conversion:
x=10
y=20.7
z=12j
#convert from int to float:
a=float(x)
#convert from float to int:
b=int(y)
#convert from int to complex:
c=complex(x)
print(a)
print(b)
print(c)
print(type(a))
print(type(b))
print(type(c))
#Output:
100.0
20
(100+j)
<class ‘float’>
<class ‘int’>
<class ‘complex’>

4. (i) Write simple programs to convert U.S. dollars to Indian rupees.


Dollar=int (input ("enter a value"))
rs=Dollar*82
print ("converted amount into rupees", rs)
#Output:
enter a value100
converted amount into rupees 8200

( ii) Write simple programs to convert bits to Megabytes, Gigabytes and Terabytes
bits=int(input("enter no. of bits"))
byte=bits/8
Kb=byte/1024
Mb=Kb/1024
Gb=Mb/1024
Tb=Gb/1024
print(Kb)
print(Mb)
print(Gb)
print(Tb)
#Output:
enter no. of bits8
0.0009765625
9.5367431640625e-07
9.313225746154785e-10
9.094947017729282e-13

5. Write simple programs to calculate the area and perimeter of the square, and the volume

and perimeter of the cone.

side=21
area=side*side
perimeter=4*side
r=26
h=36
volume=1/3*22/7*r*r*h
cone=2*22/7*r
print ("area of a square", area)
print ("perimeter of a square", perimeter)
print ("volume of a cone", volume)
print ("perimeter of a cone", cone)
#Output:
area of a square 441
perimeter of a square 84
volume of a cone 25494.857142857145
perimeter of a cone 163.42857142857142

6. Write program to: (i) determine whether a given number is odd or even.
num=int(input("enter a number"))
if (num%2==0):
print ("even number")
else:
print ("odd number")
#Output:
enter a number8
even number
(ii) Find the greatest of the three numbers using conditional operators.
a=20
b=10
c=30
if(a>=b and a>=c):
print(“a is greater”)
elif b>=a and b>=c:
print(“b is greater”)
else:
print(“c is greater”)
#Output:
c is greater

7: Write a program to: i) Find factorial of a given number.


num=int(input("entera number"))
factorial=1
if num<0:
print("factorial doesn't exist for negative numbers")
elif num==0:
print("the factorial of 0 is 1")
else:
for i in range(1,num+1):
factorial=factorial*i
print("the factorial of", num, "is",factorial)

#Output:
enter a number3
the factorial of 3 is 6
ii) Generate multiplication table up to 10 for numbers 1 to 5.
for i in range(1,6):
print(" \n \n multiplication table for %d\n" %(i))
for j in range(1,11):
print(" %d x %d=%d" %(i,j,i*j))
#Output:
multiplication table for 1

1 x 1=1
1 x 2=2
1 x 3=3
1 x 4=4
1 x 5=5
1 x 6=6
1 x 7=7
1 x 8=8
1 x 9=9
1 x 10=10

multiplication table for 2

2 x 1=2
2 x 2=4
2 x 3=6
2 x 4=8
2 x 5=10
2 x 6=12
2 x 7=14
2 x 8=16
2 x 9=18
2 x 10=20

multiplication table for 3

3 x 1=3
3 x 2=6
3 x 3=9
3 x 4=12
3 x 5=15
3 x 6=18
3 x 7=21
3 x 8=24
3 x 9=27
3 x 10=30

multiplication table for 4

4 x 1=4
4 x 2=8
4 x 3=12
4 x 4=16
4 x 5=20
4 x 6=24
4 x 7=28
4 x 8=32
4 x 9=36
4 x 10=40

multiplication table for 5

5 x 1=5
5 x 2=10
5 x 3=15
5 x 4=20
5 x 5=25
5 x 6=30
5 x 7=35
5 x 8=40
5 x 9=45
5 x 10=50

8. Write a program to: Create a list, add element to list, delete element from the lists.
# Creating a List
List = []
print("Blank List: ")
print(List)
#Output: []
# Creating a List of numbers
List = [10, 20, 14]
print("\nList of numbers: ")
print(List)
#Output:
List of numbers:
[10, 20, 14]

# Creating a List of strings and accessing using index


List = ["Geeks", "For", "Geeks"]
print("\nList Items: ")
print(List[0])
print(List[2])
#Output:
List Items:
Geeks
Geeks

# Creating a List with the use of Numbers(Having duplicate values)


List = [1, 2, 4, 4, 3, 3, 3, 6, 5]
print("\nList with the use of Numbers: ")
print(List)
#Output:
List with the use of Numbers:
[1, 2, 4, 4, 3, 3, 3, 6, 5]

# Creating a List with mixed type of values(Having numbers and strings)


List = [1, 2, 'Geeks', 4, 'For', 6, 'Geeks']
print("\nList with the use of Mixed Values: ")
print(List)
#Output:
List with the use of Mixed Values:
[1, 2, 'Geeks', 4, 'For', 6, 'Geeks']

#Adding Elements to a List


#1.Using append() method Creating a List
List = []
print("Initial blank List: ")
print(List)
#Output:
Initial blank List:
[]
# Addition of Elements in the List
List.append(1)
List.append(2)
List.append(4)
print("\nList after Addition of Three elements: ")
print(List)
#Output:
List after Addition of Three elements:
[1, 2, 4]

# Adding elements to the List using Iterator


for i in range(1, 4):
List.append(i)
print("\nList after Addition of elements from 1-3: ")
print(List)
# Adding Tuples to the List
List.append((5, 6))
print("\nList after Addition of a Tuple: ")
print(List)
# Addition of List to a List
List2 = ['For', 'Geeks']
List.append(List2)
print("\nList after Addition of a List: ")
print(List)

#2.Using insert() method


append() method only works for the addition of elements at the end of the List, for the addition of
elements at the desired position, insert() method is used.
# Python program to demonstrate Addition of elements in a List
List = [1,2,3,4]
print("Initial List: ")
print(List)
#Output:
Initial List:
[1, 2, 3, 4]

# Addition of Element at specific Position using (using Insert Method)


List.insert(3, 12)
List.insert(0, 'Geeks')
print("\nList after performing Insert Operation: ")
print(List)
#Output
List after performing Insert Operation:
['Geeks', 1, 2, 3, 12, 4]

3.Using extend() method


this method is used to add multiple elements at the same time at the end of the list.
Note: append() and extend() methods can only add elements at the end.
# Python program to demonstrate using Addition of elements in a List
print("Initial List: ")
print(List)

#output:
Initial List:
[1, 2, 3, 4]

# Addition of multiple elements to the List at the end (using Extend Method)
List.extend([8, 'Geeks', 'Always'])
print("\n List after performing Extend Operation: ")
print(List)
#output:
List after performing Extend Operation:
[1, 2, 3, 4, 8, 'Geeks', 'Always']

# Python program to demonstrate Removal of elements in a List


List = [1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12]
print("Initial List: ")
print(List)
#Output:
Initial List:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

# Removing elements from List using Remove() method


List.remove(5)
List.remove(6)
print("\nList after Removal of two elements: ")
print(List)
#output:
List after Removal of two elements:
[1, 2, 3, 4, 7, 8, 9, 10, 11, 12]

# Creating a List
List = [1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12]
# Removing elements from List using iterator method
for i in range(1, 5):
List.remove(i)
print("\nList after Removing a range of elements: ")
print(List)
#Output:
List after removing a range of elements:
[5, 6, 7, 8, 9, 10, 11, 12]

9. Write a program to: Sort the list, reverse the list and counting elements in a list.

Sorting the list:


prime_numbers = [11, 3, 7, 5, 2]
# sorting the list in ascending order
prime_numbers.sort()
print(prime_numbers)
# Output: [2, 3, 5, 7, 11]

# Sort a given list through vowels list


vowels = ['e', 'a', 'u', 'o', 'i']
# sort the vowels
vowels.sort()
# print vowels
print('Sorted list:', vowels)
#Output:
Sorted list: ['a', 'e', 'i', 'o', 'u']

#Sort the list in Descending order vowels list


vowels = ['e', 'a', 'u', 'o', 'i']
# sort the vowels
vowels.sort(reverse=True)
# print vowels
print('Sorted list (in Descending):', vowels)
#Output:
Sorted list (in Descending): ['u', 'o', 'i', 'e', 'a']

#Sort the list using key take second element for sort
def takeSecond(elem):
return elem[1]
# random list
random = [(2, 2), (3, 4), (4, 1), (1, 3)]
# sort list with key
random.sort(key=takeSecond)
# print list
print('Sorted list:', random)
#Output
Sorted list: [(4, 1), (2, 2), (1, 3), (3, 4)]

Reverse the list


# create a list of prime numbers
prime_numbers = [2, 3, 5, 7]
# reverse the order of list elements
prime_numbers.reverse()
print('Reversed List:', prime_numbers)
# Output:
Reversed List: [7, 5, 3, 2]

# Reverse a List of Operating System List

systems = ['Windows', 'macOS', 'Linux']

print('Original List:', systems)

# List Reverse
systems.reverse()
# updated list
print('Updated List:', systems)

#output:
Original List: ['Windows', 'macOS', 'Linux']
Updated List: ['Linux', 'macOS', 'Windows']

#Reverse a List Using Slicing Operator using Operating System List


systems = ['Windows', 'macOS', 'Linux']
print('Original List:', systems)
# Reversing a list
# Syntax: reversed_list = systems[start:stop:step]
reversed_list = systems[::-1]
# updated list
print('Updated List:', reversed_list)
#Output:
Original List: ['Windows', 'macOS', 'Linux']
Updated List: ['Linux', 'macOS', 'Windows']

# Accessing Elements in Reversed Order


If you need to access individual elements of a list in the reverse order, it's better to use the
reversed() function.
# Operating System List
systems = ['Windows', 'macOS', 'Linux']
# Printing Elements in Reversed Order
for o in reversed(systems):
print(o)
#Output:
Linux
macOS

counting elements in a list


The count() method returns the number of times the specified element appears in the list.

numbers = [2, 3, 5, 2, 11, 2, 7]


# check the count of 2
count = numbers.count(2)
# Output:
Count of 2: 3

#Return value from count()


The count() method returns the number of times element appears in the list.
# Use of count() using vowels list
vowels = ['a', 'e', 'i', 'o', 'i', 'u']
# count element 'i'
count = vowels.count('i')
# print count
print('The count of i is:', count)
# count element 'p'
count = vowels.count('p')
# print count
print('The count of p is:', count)
#Output

The count of i is: 2


The count of p is: 0
#Count Tuple and List Elements Inside List using random list
random = ['a', ('a', 'b'), ('a', 'b'), [3, 4]]
# count element ('a', 'b')
count = random.count(('a', 'b'))
# print count
print("The count of ('a', 'b') is:", count)
# count element [3, 4]
count = random.count([3, 4])

# print count
print("The count of [3, 4] is:", count)
#Output
The count of ('a', 'b') is: 2
The count of [3, 4] is: 1

10. Write a program to: Create dictionary, add element to dictionary, delete element from
the dictionary.
#creating dictionary
thisdict = { "brand": "Ford", "model": "Mustang","year": 1964}
print(thisdict)
thisdict = {"brand": "Ford", "model": "Mustang", "year": 1964}
print(thisdict["brand"])
thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964,"year": 2020}
print(thisdict)
print(len(thisdict))
#Output:
{'brand': 'Ford', 'model': 'Mustang', 'year': 1964}
Ford
{'brand': 'Ford', 'model': 'Mustang', 'year': 2020}
3

#1.add element to dictionary

veg_dict = {}

veg_dict[0] = 'Carrot'

veg_dict[1] = 'Raddish'
veg_dict[2] = 'Brinjal'
veg_dict[3] = 'Potato'
print(veg_dict)
#output:
{0: 'Carrot', 1: 'Raddish', 2: 'Brinjal', 3: 'Potato'}

#2.veg_dict = {0: 'Carrot', 1: 'Raddish', 2: 'Brinjal', 3: 'Potato'}


veg_dict.update({4: 'Tomato', 5: 'Spinach'})
print(veg_dict)
#Output:
{0: 'Carrot', 1: 'Raddish', 2: 'Brinjal', 3: 'Potato', 4: 'Tomato', 5: 'Spinach'}

#3.
roll_no = [10, 20, 30, 40, 50]
students = dict(zip(roll_no, names))
print(students)
#Output:
{10: 'Ramesh', 20: 'Mahesh', 30: 'Kamlesh', 40: 'Suresh', 50: 'Dinesh'}

#Converting a list to the dictionary


vegetables = ['Carrot', 'Raddish',
'Brinjal', 'Potato']
veg_dict = dict(enumerate(vegetables))
print(veg_dict)
#Output:
{0: 'Carrot', 1: 'Raddish', 2: 'Brinjal', 3: 'Potato'}

#Add values to dictionary Using the in-place merge( |= ) operator.


veg1 = {0:'Carrot', 1:'Raddish'}
veg2 = {2:'Brinjal', 3:'Potato'}
veg1 |= veg2
print(veg1)
#Output:
{0: 'Carrot', 1: 'Raddish', 2: 'Brinjal', 3: 'Potato'}

#delete element from the dictionary


1.my_dict = {31: 'a', 21: 'b', 14: 'c'}
del my_dict[31]
print(my_dict)
#Output:
{21: 'b', 14: 'c'}

2.Using pop()
my_dict = {31: 'a', 21: 'b', 14: 'c'}
print(my_dict.pop(31))
print(my_dict)
#Output:
{21: 'b', 14: 'c'}
11. Aim: Write a program to: To calculate average, mean, median, and standard deviation
of numbers in a list.
Program:
import statistics
# Input list of numbers
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# Calculate and print the average (mean) of the numbers
average = sum(numbers) / len(numbers)
print("Average:", average)
mean= statistics.mean(numbers)
print("mean:",mean)
# Calculate and print the median of the numbers
median = statistics.median(numbers)
print("Median:", median)
# Calculate and print the standard deviation of the numbers
std_deviation = statistics.stdev(numbers)
print("Standard Deviation:", std_deviation)

Output:
Average: 5.5
mean: 5.5
Median: 5.5
Standard Deviation: 3.0276503540974917

12.Aim: Write a program to: To print Factors of a given Number.


Program:
num = int(input("Enter the values of num: "))
def print_factors(x):
print("The factors of",x,"are:")
for i in range(1, x + 1):
if x % i == 0:
print(i)
print_factors(num)

Output:
Enter the values of num: 3
The factors of 3 are:
1
3
13. Write a Program to: Add two complex number using classes and objects.
class Complex ():
def initComplex(self):
self.realPart = int(input("Enter the Real Part: "))
self.imgPart = int(input("Enter the Imaginary Part: "))
def display(self):
print(self.realPart,"+",self.imgPart,"i", sep="")
def sum(self, c1, c2):
self.realPart = c1.realPart + c2.realPart
self.imgPart = c1.imgPart + c2.imgPart
c1 = Complex()
c2 = Complex()
c3 = Complex()
print("Enter first complex number")
c1.initComplex()
print("First Complex Number: ", end="")
c1.display()
print("Enter second complex number")
c2.initComplex()
print("Second Complex Number: ", end="")
c2.display()
print("Sum of two complex numbers is ", end="")
c3.sum(c1,c2)
c3.display()

output:
Enter first complex number
Enter the Real Part: 3
Enter the Imaginary Part: 4
First Complex Number: 3+4i
Enter second complex number
Enter the Real Part: 5
Enter the Imaginary Part: 6
Second Complex Number: 5+6i
Sum of two complex numbers is 8+10i

14. Write a Program to: Subtract two complex number using classes and objects.
class ComplexNumber():
def init(self):
self.real = int(input("Enter Real part: "))
self.imaginary = int(input("Enter Imaginary part: "))
def display(self):
sign = "+" if(self.imaginary >= 0) else ""
print(self.real, sign, self.imaginary, "j", sep="")
def subtract(self, c1, c2):
self.real = c1.real - c2.real
self.imaginary = c1.imaginary - c2.imaginary
print("First complex number: ")
c1 = ComplexNumber()
c1.init()
print("Second complex number: ")
c2 = ComplexNumber()
c2.init()
print ("Subtraction of two complex number: ")
c3 = Complex Number ()
c3.subtract (c1, c2)
c3.display ()

Output:
First complex number:
Enter Real part: 2
Enter Imaginary part: 3
Second complex number:
Enter Real part: 5
Enter Imaginary part: 4
Subtraction of two complex number:
-3-1j

15. Write a Program to: Create a package and accessing a package.


module1.py
def Hello():
print("welcome to packages in python")
module2.py
def Test():
print("package is created")
--init--.py
from module1 import Hello
from module2 import Test
Hello()
Test()
#Output:
welcome to packages in python
package is created

16. File Input/output: Write a program to: i) To create simple file and write “Hello World”
in it.
file = open("program.txt","r")
for ch in file:
print("file content is:",ch)
Output:
file content is: hello world

ii) To open a file in write mode and append Hello world at the end of a file.
file1 = open("sample.txt","a")
file1.write("hello world")
file1.close()
file1=open("sample.txt","r")
print("file content is:",file1.read())
Output:
file content is: hello world hello world

17. Write a program to :i) To open a file in read mode and write its contents to another file
but replace every occurrence of character ‘h’
# Step 1: Open the source file in read mode
source_file_name = "sample.txt"
destination_file_name = "python.txt"

try:
with open(source_file_name, 'r') as source_file:
# Step 2: Read the contents of the source file
source_contents = source_file.read()

# Step 3: Replace 'h' with the desired character(s)


modified_contents = source_contents.replace('h', 'X') # Replace 'h' with 'X'

# Step 4: Open the destination file in write mode


with open(destination_file_name, 'w') as destination_file:
# Step 5: Write the modified contents to the destination file
destination_file.write(modified_contents)

print(f"File '{source_file_name}' contents have been processed and saved to


'{destination_file_name}'.")

except FileNotFoundError:
print(f"File '{source_file_name}' not found.")
except Exception as e:
print(f"An error occurred: {e}")

#Output:
File 'sample.txt' contents have been processed and saved to 'python.txt'.
ii) To open a file in read mode and print the number of occurrences of a character ‘a’.

# Step 1: Open the source file in read mode

source_file_name = "sample.txt"

destination_file_name = "python.txt"

try:

with open(source_file_name, 'r') as source_file:

# Step 2: Read the contents of the source file

source_contents = source_file.read()

# Step 3: Replace 'h' with the desired character(s)

modified_contents = source_contents.replace('a', 'X')

# Replace 'a' with 'X'

# Step 4: Open the destination file in write mode

with open(destination_file_name, 'w') as destination_file:

# Step 5: Write the modified contents to the destination file

destination_file.write(modified_contents)

print(f"File '{source_file_name}' contents have been processed and saved to


'{destination_file_name}' ")

except FileNotFoundError:

print(f"File '{source_file_name}' not found.")

except Exception as e:

print(f"An error occurred: {e}")

#Output

File 'sample.txt' contents have been processed and saved to 'python.txt'

You might also like