Python 4th Practical

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

1.

Write a program to check whether a number is even or odd


num=int(input("Enter a num= "))

if(num%2==0):

print("num is even number",num)

else:

print("num is odd number",num)

2. Write a program to find out absolute value of an input number

num=int(input("enter a num= "))


if(num<0):
num=num*-1
print("absolute number of given num is=",num)
3. Write a program to check the largest number among the three numbers.

num1=int(input("enter first number"))


num2=int(input("enter second number"))
num3=int(input("enter third number"))
if(num1>num2 and num1>num3):
num="num1 is largest number"
if(num2>num3 and num2>num1):
num="num2 is largest number"
if(num3>num2 and num3>num1):
num="num3 is largest number"
print("num",num)
4. Write a program to check if the input year is a leap year of not

year=int(input("enter year"))

if(year%4==0):

print("year is leap year")

else:

print("year is not leap year")


5. Write a program to check if a Number is Positive, Negative or Zero
num=int(input("enter a number"))
if(num>0):
print("number is positive")
if(num<0):
print("number is negative")
if(num==0):
print("number is zero")
6. Write a program that takes the marks of 5 subjects and displays the grade.
mad=int(input("enter mad marks"))
man=int(input("enter man marks"))
pwp=int(input("enter pwp marks"))
nis=int(input("enter nis marks"))
eti=int(input("enter eti marks"))
avg=mad+man+pwp+nis+eti/5
if(avg>=90):
print("a grade ")
elif(avg>=75 and avg<90):
print("b grade ")
elif(avg>=50 and avg<75):
print("c grade ")
else:
print("d grade ")

You might also like