0% found this document useful (0 votes)
3 views4 pages

Python Practical Solutions

The document contains a practical file with 11 solved Python programs, each detailing the objective, tools, program code, output, and conclusion. Programs include basic tasks like printing 'Hello World', swapping numbers, checking data types, and performing list operations. All programs executed successfully, demonstrating fundamental Python concepts and operations.

Uploaded by

kanpurnsti21
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)
3 views4 pages

Python Practical Solutions

The document contains a practical file with 11 solved Python programs, each detailing the objective, tools, program code, output, and conclusion. Programs include basic tasks like printing 'Hello World', swapping numbers, checking data types, and performing list operations. All programs executed successfully, demonstrating fundamental Python concepts and operations.

Uploaded by

kanpurnsti21
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

Python Practical File (Solved Programs)

Experiment No.: 1

Program Title: Hello World

Objective: To write a program for hello world.

Tools & Equipment: Computer, Python

Program:

print('Hello World')

Output:

Hello World

Conclusion: Program executed successfully.

--------------------------------------------------

Experiment No.: 2

Program Title: Swap two numbers

Objective: To write a program for swap two numbers.

Tools & Equipment: Computer, Python

Program:

a=5 b=10 a,b=b,a print(a,b)

Output:

10 5

Conclusion: Program executed successfully.

--------------------------------------------------

Experiment No.: 3

Program Title: Check data type

Objective: To write a program for check data type.

Tools & Equipment: Computer, Python

Program:

x=10 print(type(x))
Output:

Conclusion: Program executed successfully.

--------------------------------------------------

Experiment No.: 4

Program Title: List operations

Objective: To write a program for list operations.

Tools & Equipment: Computer, Python

Program:

l=[1,2,3] [Link](4) print(l)

Output:

[1,2,3,4]

Conclusion: Program executed successfully.

--------------------------------------------------

Experiment No.: 5

Program Title: Even/Odd

Objective: To write a program for even/odd.

Tools & Equipment: Computer, Python

Program:

n=4 print('Even' if n%2==0 else 'Odd')

Output:

Even

Conclusion: Program executed successfully.

--------------------------------------------------

Experiment No.: 6

Program Title: Factorial

Objective: To write a program for factorial.

Tools & Equipment: Computer, Python

Program:
n=5 f=1 for i in range(1,n+1): f*=i print(f)

Output:

120

Conclusion: Program executed successfully.

--------------------------------------------------

Experiment No.: 7

Program Title: Prime check

Objective: To write a program for prime check.

Tools & Equipment: Computer, Python

Program:

n=7 for i in range(2,n): if n%i==0: print('Not Prime') break else:


print('Prime')

Output:

Prime

Conclusion: Program executed successfully.

--------------------------------------------------

Experiment No.: 8

Program Title: Sum of numbers

Objective: To write a program for sum of numbers.

Tools & Equipment: Computer, Python

Program:

print(sum(range(1,6)))

Output:

15

Conclusion: Program executed successfully.

--------------------------------------------------

Experiment No.: 9

Program Title: Function add


Objective: To write a program for function add.

Tools & Equipment: Computer, Python

Program:

def add(a,b): return a+b print(add(2,3))

Output:

Conclusion: Program executed successfully.

--------------------------------------------------

Experiment No.: 10

Program Title: File handling

Objective: To write a program for file handling.

Tools & Equipment: Computer, Python

Program:

f=open('[Link]','w') [Link]('Hi') [Link]()

Output:

File created

Conclusion: Program executed successfully.

--------------------------------------------------

Experiment No.: 11

Program Title: Class program

Objective: To write a program for class program.

Tools & Equipment: Computer, Python

Program:

class A: def __init__(self): print('Hello') A()

Output:

Hello

Conclusion: Program executed successfully.

--------------------------------------------------

You might also like