Python Practical Assignment Solutions
1. Write a python program to print palindrome from 100 to 500.
for n in range(100, 501):
if str(n) == str(n)[::-1]:
print(n, end=' ')
2. Write a python program to print fibonacci series up to 50.
a, b = 0, 1
while a <= 50:
print(a, end=' ')
a, b = b, a + b
3. Write a python program to print Armstrong number from 100 to 500.
for n in range(100, 501):
s = sum(int(d)**3 for d in str(n))
if s == n:
print(n, end=' ')
17. Practical assignment on exception handling - Write a python program to
handle an exception 'Division by Zero Error'.
try:
x = int(input("Enter dividend: "))
y = int(input("Enter divisor: "))
result = x / y
except ZeroDivisionError:
print("Error: Cannot divide by zero!")
else:
print("Result:", result)