0% found this document useful (0 votes)
48 views

Python 4th Practical

The document contains 6 Python programs that perform various conditional logic tasks: 1) Check if a number is even or odd. 2) Find the absolute value of a number. 3) Determine the largest of three numbers. 4) Check if a year is a leap year. 5) Check if a number is positive, negative, or zero. 6) Calculate the grade from marks in 5 subjects. Each program uses if/else statements to evaluate conditions and print corresponding outputs.

Uploaded by

sayalimundhe188
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Python 4th Practical

The document contains 6 Python programs that perform various conditional logic tasks: 1) Check if a number is even or odd. 2) Find the absolute value of a number. 3) Determine the largest of three numbers. 4) Check if a year is a leap year. 5) Check if a number is positive, negative, or zero. 6) Calculate the grade from marks in 5 subjects. Each program uses if/else statements to evaluate conditions and print corresponding outputs.

Uploaded by

sayalimundhe188
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 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