0% found this document useful (0 votes)
19 views10 pages

Python_Practicals_Complete (1)

The document provides a comprehensive guide for installing Python and an IDE, along with practical Python programming exercises covering input/output operations, conditional statements, loops, and data structures such as lists, tuples, and sets. Each section includes explanations, sample code, and expected outputs for various programming tasks. It serves as a practical resource for learning and applying fundamental Python concepts.

Uploaded by

kishorgaikar826
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)
19 views10 pages

Python_Practicals_Complete (1)

The document provides a comprehensive guide for installing Python and an IDE, along with practical Python programming exercises covering input/output operations, conditional statements, loops, and data structures such as lists, tuples, and sets. Each section includes explanations, sample code, and expected outputs for various programming tasks. It serves as a practical resource for learning and applying fundamental Python concepts.

Uploaded by

kishorgaikar826
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
You are on page 1/ 10

Python Practical Programs (MSBTE Format)

Install the given Python IDE.


Explanation:

To install Python and an IDE such as PyCharm, VS Code, or IDLE, follow these steps:
1. Download Python from python.org and install it.
2. Install an IDE such as PyCharm or VS Code.
3. Verify installation by running 'python --version' in the terminal.

Python Code:

Installation steps vary based on the OS.

Expected Output:

Python and IDE installed successfully.

Write a Python program for performing basic input and output operations.
Explanation:

The input() function takes user input, while print() displays output.

Python Code:

name = input("Enter your name: ")


print("Hello, " + name + "! Welcome to Python.")

Expected Output:

Enter your name: John


Hello, John! Welcome to Python.

Write a Python program to solve a given expression using operators.


Explanation:

Operators are used to perform mathematical and logical computations in Python.

Python Code:

a = 10
b=5
result = (a + b) * 2 / 4
print("Result:", result)

Expected Output:
Result: 7.5

Write a Python program for solving given problem using various if statements.
Explanation:

Conditional statements allow decision-making in Python based on conditions.

Python Code:

num = int(input("Enter a number: "))


if num > 0:
print("Positive Number")
elif num == 0:
print("Zero")
else:
print("Negative Number")

Expected Output:

Enter a number: 5
Positive Number

Write a Python program for solving given problems using while loop and for
loop.
Explanation:

Loops in Python are used to execute a block of code multiple times.

Python Code:

# Using a for loop


for i in range(1, 6):
print(i)

# Using a while loop


n=5
while n > 0:
print(n)
n -= 1

Expected Output:

1
2
3
4
5
5
4
3
2
1

Use loop control statements in Python for solving given problem.


Explanation:

Loop control statements such as break, continue, and pass alter loop execution.

Python Code:

# Using break
for i in range(1, 6):
if i == 3:
break
print(i)

# Using continue
for i in range(1, 6):
if i == 3:
continue
print(i)

Expected Output:

1
2
1
2
4
5

Write a Python program to perform operations on lists.


Explanation:

Lists are mutable sequences used to store collections of items.

Python Code:

my_list = [10, 20, 30, 40]


my_list.append(50)
my_list.remove(20)
print(my_list)

Expected Output:
[10, 30, 40, 50]

Write a Python program to use built-in functions on lists.


Explanation:

Python provides various built-in functions to manipulate lists.

Python Code:

numbers = [1, 2, 3, 4, 5]
print("Sum:", sum(numbers))
print("Max:", max(numbers))
print("Min:", min(numbers))
print("Length:", len(numbers))

Expected Output:

Sum: 15
Max: 5
Min: 1
Length: 5

Write a Python program to perform operations on tuples.


Explanation:

Tuples are immutable sequences, typically used to store heterogeneous data.

Python Code:

my_tuple = (10, 20, 30, 40)


print(my_tuple[1]) # Accessing element
print(len(my_tuple)) # Finding length

Expected Output:

20
4

Write a Python program to manipulate sets.


Explanation:

Sets are unordered collections of unique elements.

Python Code:

my_set = {1, 2, 3}
my_set.add(4)
my_set.remove(2)
print(my_set)

Expected Output:

{1, 3, 4}

Write a Python program for Practical 11.


Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}

Write a Python program for Practical 12.


Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}

Write a Python program for Practical 13.


Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}

Write a Python program for Practical 14.


Explanation:

This practical covers important Python concepts.


Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}

Write a Python program for Practical 15.


Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}

Write a Python program for Practical 16.


Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}

Write a Python program for Practical 17.


Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}

Write a Python program for Practical 18.


Explanation:
This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}

Write a Python program for Practical 19.


Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}

Write a Python program for Practical 20.


Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}

Write a Python program for Practical 21.


Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}


Write a Python program for Practical 22.
Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}

Write a Python program for Practical 23.


Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}

Write a Python program for Practical 24.


Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}

Write a Python program for Practical 25.


Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:
Sample Output for Practical {i}

Write a Python program for Practical 26.


Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}

Write a Python program for Practical 27.


Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}

Write a Python program for Practical 28.


Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}

Write a Python program for Practical 29.


Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')


Expected Output:

Sample Output for Practical {i}

Write a Python program for Practical 30.


Explanation:

This practical covers important Python concepts.

Python Code:

print('Sample Code for Practical {i}')

Expected Output:

Sample Output for Practical {i}

You might also like