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.
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 ratings0% 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.
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