You are on page 1of 3

1.

Program to Check if a Number is Even or Odd: Develop a program that reads an integer
from the user and determines whether it is even or odd using conditional statements.
SOURCE CODE:
#Function to check odd or even number
def check_num(num):
if(num % 2 == 0):
print(f"{num} is a even number")
else:
print(f"{num} is a odd number")

#main function starts here.


a=int(input("ENTER A NUMBER :>"))
check_num(a)

OUTPUT:
2. Program to Check Divisibility by a Given Number: Write a program that checks if a user-inputted number is
divisible by another specified number.
SOURCE CODE:
#Function to check divisiblity
def check_divisiblity(gnum,snum):
if(gnum % snum == 0):
print(f"{gnum} is divisible by {snum}")
else:
print(f"{gnum} is not divisible by {snum}")

#main function start here


G=int(input("GIVE A NUMBER :>"))
S=int(input("SPECIFY A NUMBER :>"))

check_divisiblity(G,S)
OUTPUT:
3. Find Largest and Smallest Among 3 Numbers: Create a program to compare three numbers input by the user and
determine the largest and smallest among them.
SOURCE CODE:

OUTPUT:

You might also like