0% found this document useful (0 votes)
3 views

Python_Practicals_with_Outputs (1)

The document outlines various practical exercises in Python programming, covering topics such as displaying messages, reading user input, operators, conditional statements, looping, list operations, tuple operations, and set operations. Each practical includes code snippets and expected outputs to demonstrate functionality. The exercises are designed to help users understand basic programming concepts in Python.

Uploaded by

Jay U. Mahankar
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 views

Python_Practicals_with_Outputs (1)

The document outlines various practical exercises in Python programming, covering topics such as displaying messages, reading user input, operators, conditional statements, looping, list operations, tuple operations, and set operations. Each practical includes code snippets and expected outputs to demonstrate functionality. The exercises are designed to help users understand basic programming concepts in Python.

Uploaded by

Jay U. Mahankar
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/ 2

Practical 1: Display Message and Read Data

print("Welcome to Python Programming!")


data = input("Enter something: ")
print("You entered:", data)
# Output:
# Welcome to Python Programming!
# Enter something: Hello
# You entered: Hello

Practical 2: Read Data from User and Display


name = input("Enter your name: ")
age = int(input("Enter your age: "))
print(f"Name: {name}, Age: {age}")
# Output:
# Enter your name: Jay
# Enter your age: 20
# Name: Jay, Age: 20

Practical 3: Operators in Python


a, b = 10, 3
print("Arithmetic:", a + b)
print("Relational:", a > b)
print("Logical:", a > 5 and b < 5)
print("Bitwise:", a & b)
print("Identity:", a is b)
# Output:
# Arithmetic: 13
# Relational: True
# Logical: True
# Bitwise: 2
# Identity: False

Practical 4: Conditional Statements


x = int(input("Enter number: "))
if x > 0:
print("Positive")
elif x < 0:
print("Negative")
else:
print("Zero")
# Input: 5 -> Output: Positive
# Input: -2 -> Output: Negative
# Input: 0 -> Output: Zero

Practical 5: Looping Statements


for i in range(5):
print(i)

i = 0
while i < 5:
print(i)
i += 1
# Output:
# 0 1 2 3 4
# 0 1 2 3 4

Practical 6: Loop Control Statements


for i in range(5):
if i == 3:
continue
print(i)
if i == 4:
break
# Output: 0 1 2 4

Practical 7: List Operations


lst = [1, 2, 3]
lst.append(4)
print(lst)
lst.remove(2)
print(lst)
# Output:
# [1, 2, 3, 4]
# [1, 3, 4]

Practical 8: Built-in List Methods


lst = [3, 1, 2]
lst.sort()
print(lst)
lst.reverse()
print(lst)
# Output:
# [1, 2, 3]
# [3, 2, 1]

Practical 9: Tuple Operations


tpl = (1, 2, 3)
print(tpl)
print(tpl[1])
# Output:
# (1, 2, 3)
# 2

Practical 10: Set Operations


s = {1, 2, 3}
s.add(4)
s.remove(2)
print(s)
# Output: {1, 3, 4}

You might also like