0% found this document useful (0 votes)
31 views1 page

Python Practical Assignment Solutions Full

Uploaded by

nikhilagarwal284
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)
31 views1 page

Python Practical Assignment Solutions Full

Uploaded by

nikhilagarwal284
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/ 1

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)

You might also like