0% found this document useful (0 votes)
4 views12 pages

Python Practical File

The document is a practical file for Python programming experiments conducted by Dayanand Patel at Hitkarini College of Engineering and Technology. It includes ten experiments covering various topics such as data types, arithmetic operations, string manipulation, date formatting, list and tuple operations, dictionary usage, finding the largest number, temperature conversion, and constructing patterns using nested loops. Each experiment outlines the aim, theory, algorithm, code, output, and conclusion.

Uploaded by

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

Python Practical File

The document is a practical file for Python programming experiments conducted by Dayanand Patel at Hitkarini College of Engineering and Technology. It includes ten experiments covering various topics such as data types, arithmetic operations, string manipulation, date formatting, list and tuple operations, dictionary usage, finding the largest number, temperature conversion, and constructing patterns using nested loops. Each experiment outlines the aim, theory, algorithm, code, output, and conclusion.

Uploaded by

guptaji94695
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python Practical File

Department Of Electrical & Electrical Engg.


Hitkarini College Of Engineering And
Technology Jabalpur

Name – DAYANAND PATEL


Roll. N - 0203EX243D0
Index
Experiment No. Title

1 Demonstrate different number data types

2 Perform different Arithmetic Operations

3 Create, concatenate and print string, access


sub-string

4 Print current date in given format

5 Create, append, and remove lists

6 Working with tuples

7 Working with dictionaries

8 Find largest of three numbers

9 Convert temperatures (Celsius, Fahrenheit)

10 Construct pattern using nested loops


Experiment 1: Demonstrate different number data types

Aim:
To demonstrate different number data types in Python.

Theory:
Python supports integers, floats, and complex numbers. We will display their types.

Algorithm / Steps:
 Start program
 Declare integer, float, complex
 Print type of each

Code:
a=5
b = 2.5
c = 3+4j
print(type(a))
print(type(b))
print(type(c))

Output:
<class 'int'>
<class 'float'>
<class 'complex'>

Conclusion:
Successfully demonstrated number data types.
Experiment 2: Perform different Arithmetic Operations

Aim:
To perform arithmetic operations on numbers.

Theory:
We will perform addition, subtraction, multiplication, division, modulus, and power
operations.

Algorithm / Steps:
 Start program
 Input two numbers
 Perform arithmetic operations

Code:
x = 10
y=3
print(x + y, x - y, x * y, x / y, x % y, x ** y)

Output:
13 7 30 3.3333 1 1000

Conclusion:
Arithmetic operations executed successfully.
Experiment 3: Create, concatenate and print string, access sub-string

Aim:
To create, concatenate, print a string and access substring.

Theory:
Python strings can be concatenated and sliced easily.

Algorithm / Steps:
 Create two strings
 Concatenate
 Access substring

Code:
str1 = 'Hello'
str2 = 'World'
final = str1 + ' ' + str2
print(final)
print(final[0:5])

Output:
Hello World
Hello

Conclusion:
String operations performed successfully.
Experiment 4: Print current date in given format

Aim:
To print current date in format 'Sun May 29 [Link] IST 2017'.

Theory:
Using datetime module to format date and time.

Algorithm / Steps:
 Import datetime
 Use strftime for formatting

Code:
import time
print([Link]('%a %b %d %H:%M:%S IST %Y'))

Output:
Mon Aug 04 [Link] IST 2025

Conclusion:
Date displayed successfully in required format.
Experiment 5: Create, append, and remove lists

Aim:
To create, append, and remove elements from a list.

Theory:
Lists are mutable data structures that allow modifications.

Algorithm / Steps:
 Create list
 Append element
 Remove element

Code:
lst = [1,2,3]
[Link](4)
print(lst)
[Link](2)
print(lst)

Output:
[1, 2, 3, 4]
[1, 3, 4]

Conclusion:
List operations executed successfully.
Experiment 6: Working with tuples

Aim:
To demonstrate working with tuples.

Theory:
Tuples are immutable sequences used to store multiple items.

Algorithm / Steps:
 Create tuple
 Access elements
 Slice tuple

Code:
tpl = (1,2,3,4)
print(tpl)
print(tpl[1])
print(tpl[1:3])

Output:
(1, 2, 3, 4)
2
(2, 3)

Conclusion:
Tuple operations demonstrated successfully.
Experiment 7: Working with dictionaries

Aim:
To demonstrate working with dictionaries.

Theory:
Dictionaries store key-value pairs for fast lookups.

Algorithm / Steps:
 Create dictionary
 Access value
 Add key-value
 Delete key

Code:
d = {'a':1, 'b':2}
print(d)
d['c'] = 3
print(d)
[Link]('a')
print(d)

Output:
{'a': 1, 'b': 2}
{'a': 1, 'b': 2, 'c': 3}
{'b': 2, 'c': 3}

Conclusion:
Dictionary operations executed successfully.
Experiment 8: Find largest of three numbers

Aim:
To find largest of three numbers.

Theory:
Using if-else conditions to compare numbers.

Algorithm / Steps:
 Input three numbers
 Use if-else to find max

Code:
a,b,c = 10,20,15
if a>=b and a>=c:
print(a)
elif b>=a and b>=c:
print(b)
else:
print(c)

Output:
20

Conclusion:
Largest number identified successfully.
Experiment 9: Convert temperatures (Celsius, Fahrenheit)

Aim:
To convert temperatures between Celsius and Fahrenheit.

Theory:
Formula: c/5 = (f-32)/9.

Algorithm / Steps:
 Input temperature
 Convert to Celsius or Fahrenheit

Code:
c = 37
f = (c*9/5)+32
print(f)
f = 98.6
c = (f-32)*5/9
print(c)

Output:
98.6
37.0

Conclusion:
Temperature conversion executed successfully.
Experiment 10: Construct pattern using nested loops

Aim:
To construct pattern using nested loops.

Theory:
Using nested for loops to print pyramid pattern.

Algorithm / Steps:
 Use nested loops
 Print stars in increasing order

Code:
for i in range(1,6):
print('* '*i)

Output:
*
**
***
****
*****

Conclusion:
Pattern printed successfully.

You might also like