Assignment 2
Assignment 2
and F(0-59).
Sol: -
Leap Year Checker:
Create a python program that checks if a given year is a leap
year. A leap year is divisible by 4, except for years that are
divisible by 100 but not divisible by 400.
Sol: -
Positive/Negative/Zero Checker
Write a python program that takes a number as input and prints
whether it’s positive, negative, or zero.
Sol: -
Largest of three number:
Develop a python program that takes three number as input and
prints the largest among them.
Sol: -
Temperature Converter:
Creative a python program that converts temperature
between Celsius and Fahrenheit. The user should be able to
input a temperature and its unit, and the program should
output the converted temperature.
Sol: -
Looping
Print Even Number
Write a python program to print all even numbers from 1 to
20 using a for loop
Factorial Calculator:
Develop a python program that calculates the factorial of a
given number using a while loop. The factorial of a non-
integer n is the product of all positive integers less than or
equal to n.
Sol: -
Exception Handling
11. Safe Division:
Write a Python program that takes two numbers as input
and performs division. Handle the ZeroDivisionError by
displaying a message indicating that division by zero is not
allowed.
12. File Reader with Exception Handling:
Create a Python program that reads content from a user-
specified file. Handle the FileNotFoundError by displaying a
message if the file is not found.
13. Input Validation with a Loop:
Implement a program that asks the user to input a positive
integer. Use a loop and exception handling to ensure that
the user enters a valid positive integer.
14. Dictionary Access with Exception Handling:
Write a Python program that accesses a key in a dictionary.
Handle the KeyError by displaying a message if the key is
not present in the dictionary.