0% found this document useful (0 votes)
5 views65 pages

Python Unitwise Notes Examples Questions

The document contains multiple examples of Python programming concepts including variables and operators, conditional statements, string slicing, list operations, and exception handling. Each concept is illustrated with code snippets demonstrating their functionality. The examples are repeated throughout the document.

Uploaded by

rathorekabit
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)
5 views65 pages

Python Unitwise Notes Examples Questions

The document contains multiple examples of Python programming concepts including variables and operators, conditional statements, string slicing, list operations, and exception handling. Each concept is illustrated with code snippets demonstrating their functionality. The examples are repeated throughout the document.

Uploaded by

rathorekabit
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



# Example: Variables and Operators


a = 10
b = 5
sum = a + b
print("Sum =", sum)

1
2
3
4

1
2
3



# Example: If condition
num = int(input("Enter number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")

1
2
3

1
2
3



# Example: String slicing


text = "Python"
print(text[0:3])

1
2
3

1
2
3



# Example: List operations


numbers = [5,2,9,1]
[Link]()
print(numbers)

1
2
3

1
2
3



# Example: Exception handling


try:
a = 10
b = 0
print(a/b)
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print("Program finished")

1
2
3

1
2
3
# Example: Variables and Operators
a = 10
b = 5
sum = a + b
print("Sum =", sum)

1
2
3
# Example: If condition
num = int(input("Enter number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")

1
2
3
# Example: String slicing
text = "Python"
print(text[0:3])

1
2
3
# Example: List operations
numbers = [5,2,9,1]
[Link]()
print(numbers)

1
2
3
# Example: Exception handling
try:
a = 10
b = 0
print(a/b)
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print("Program finished")

1
2
3
# Example: Variables and Operators
a = 10
b = 5
sum = a + b
print("Sum =", sum)

1
2
3
# Example: If condition
num = int(input("Enter number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")

1
2
3
# Example: String slicing
text = "Python"
print(text[0:3])

1
2
3
# Example: List operations
numbers = [5,2,9,1]
[Link]()
print(numbers)

1
2
3
# Example: Exception handling
try:
a = 10
b = 0
print(a/b)
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print("Program finished")

1
2
3
# Example: Variables and Operators
a = 10
b = 5
sum = a + b
print("Sum =", sum)

1
2
3
# Example: If condition
num = int(input("Enter number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")

1
2
3
# Example: String slicing
text = "Python"
print(text[0:3])

1
2
3
# Example: List operations
numbers = [5,2,9,1]
[Link]()
print(numbers)

1
2
3
# Example: Exception handling
try:
a = 10
b = 0
print(a/b)
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print("Program finished")

1
2
3
# Example: Variables and Operators
a = 10
b = 5
sum = a + b
print("Sum =", sum)

1
2
3
# Example: If condition
num = int(input("Enter number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")

1
2
3
# Example: String slicing
text = "Python"
print(text[0:3])

1
2
3
# Example: List operations
numbers = [5,2,9,1]
[Link]()
print(numbers)

1
2
3
# Example: Exception handling
try:
a = 10
b = 0
print(a/b)
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print("Program finished")

1
2
3
# Example: Variables and Operators
a = 10
b = 5
sum = a + b
print("Sum =", sum)

1
2
3
# Example: If condition
num = int(input("Enter number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")

1
2
3
# Example: String slicing
text = "Python"
print(text[0:3])

1
2
3
# Example: List operations
numbers = [5,2,9,1]
[Link]()
print(numbers)

1
2
3
# Example: Exception handling
try:
a = 10
b = 0
print(a/b)
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print("Program finished")

1
2
3
# Example: Variables and Operators
a = 10
b = 5
sum = a + b
print("Sum =", sum)

1
2
3
# Example: If condition
num = int(input("Enter number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")

1
2
3
# Example: String slicing
text = "Python"
print(text[0:3])

1
2
3
# Example: List operations
numbers = [5,2,9,1]
[Link]()
print(numbers)

1
2
3
# Example: Exception handling
try:
a = 10
b = 0
print(a/b)
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print("Program finished")

1
2
3
# Example: Variables and Operators
a = 10
b = 5
sum = a + b
print("Sum =", sum)

1
2
3
# Example: If condition
num = int(input("Enter number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")

1
2
3
# Example: String slicing
text = "Python"
print(text[0:3])

1
2
3
# Example: List operations
numbers = [5,2,9,1]
[Link]()
print(numbers)

1
2
3
# Example: Exception handling
try:
a = 10
b = 0
print(a/b)
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print("Program finished")

1
2
3
# Example: Variables and Operators
a = 10
b = 5
sum = a + b
print("Sum =", sum)

1
2
3
# Example: If condition
num = int(input("Enter number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")

1
2
3
# Example: String slicing
text = "Python"
print(text[0:3])

1
2
3
# Example: List operations
numbers = [5,2,9,1]
[Link]()
print(numbers)

1
2
3
# Example: Exception handling
try:
a = 10
b = 0
print(a/b)
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print("Program finished")

1
2
3
# Example: Variables and Operators
a = 10
b = 5
sum = a + b
print("Sum =", sum)

1
2
3
# Example: If condition
num = int(input("Enter number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")

1
2
3
# Example: String slicing
text = "Python"
print(text[0:3])

1
2
3
# Example: List operations
numbers = [5,2,9,1]
[Link]()
print(numbers)

1
2
3
# Example: Exception handling
try:
a = 10
b = 0
print(a/b)
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print("Program finished")

1
2
3
# Example: Variables and Operators
a = 10
b = 5
sum = a + b
print("Sum =", sum)

1
2
3
# Example: If condition
num = int(input("Enter number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")

1
2
3
# Example: String slicing
text = "Python"
print(text[0:3])

1
2
3
# Example: List operations
numbers = [5,2,9,1]
[Link]()
print(numbers)

1
2
3
# Example: Exception handling
try:
a = 10
b = 0
print(a/b)
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print("Program finished")

1
2
3
# Example: Variables and Operators
a = 10
b = 5
sum = a + b
print("Sum =", sum)

1
2
3
# Example: If condition
num = int(input("Enter number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")

1
2
3
# Example: String slicing
text = "Python"
print(text[0:3])

1
2
3
# Example: List operations
numbers = [5,2,9,1]
[Link]()
print(numbers)

1
2
3
# Example: Exception handling
try:
a = 10
b = 0
print(a/b)
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print("Program finished")

1
2
3
# Example: Variables and Operators
a = 10
b = 5
sum = a + b
print("Sum =", sum)

1
2
3
# Example: If condition
num = int(input("Enter number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")

1
2
3
# Example: String slicing
text = "Python"
print(text[0:3])

1
2
3
# Example: List operations
numbers = [5,2,9,1]
[Link]()
print(numbers)

1
2
3
# Example: Exception handling
try:
a = 10
b = 0
print(a/b)
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print("Program finished")

1
2
3

You might also like