0% found this document useful (0 votes)
6 views4 pages

Prac 4

The document contains a series of Python programming exercises designed for a student named Sumedh Sanjay Raut. Each exercise includes code snippets for checking if a number is even or odd, calculating absolute values, finding the largest of three numbers, determining leap years, identifying positive or negative numbers, and calculating grades based on marks from five subjects. The document provides the code and expected output for each exercise.

Uploaded by

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

Prac 4

The document contains a series of Python programming exercises designed for a student named Sumedh Sanjay Raut. Each exercise includes code snippets for checking if a number is even or odd, calculating absolute values, finding the largest of three numbers, determining leap years, identifying positive or negative numbers, and calculating grades based on marks from five subjects. The document provides the code and expected output for each exercise.

Uploaded by

Sumedh Raut
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

dd

NAME: SUMEDH SANJAY RAUT


CLASS: CO6I(A)
ROLL NO: 532
SUBJECT: PYTHON(22616)

PRACTICAL NO: 4
XI. Exercise
1. Write a program to check whether a number is even or odd
Code:
print("Enter a number:")
var1=int(input())
if(var1%2==0):
print("%d is an even number"%var1)
else:
print("%d is an odd number"%var1)
Output:

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


Code:
num = float(input("Enter a number: "))

abs_value = abs(num)
print(f"The absolute value of {num} is {abs_value}.")
Output:
dd

3. Write a program to check the largest number among the three numbers
Code:
num1=float(input("Enter a First Number:"))
num2=float(input("Enter a Second Number:"))
num3=float(input("Enter a Third Number:"))

largest=max(num1,num2,num3)
print("Largest Number is:",largest)
Output:

4. Write a program to check if the input year is a leap year of not


Code:
year=int(input("Enter a any year"))
if(year%4==0):
print("It is a leap year:",year)
else:
print("It is not a leap year:",year)
Output:
dd

5. Write a program to check if a Number is Positive, Negative or Zero


Code:
num= float(input("Enter a number:"))
if num>0:
print("It is positive Number:",num)
elif num<0:
print("It is a Negative Number:",num)
else:
print("It is a Zero:",num)
Output:
dd

6. Write a program that takes the marks of 5 subjects and displays the grade.
Code:
subject1 = float(input("Enter marks for subject 1: "))
subject2 = float(input("Enter marks for subject 2: "))
subject3 = float(input("Enter marks for subject 3: "))
subject4 = float(input("Enter marks for subject 4: "))
subject5 = float(input("Enter marks for subject 5: "))

total_marks = subject1 + subject2 + subject3 + subject4 + subject5


percentage = (total_marks / 500) * 100

if percentage >= 90:


grade = "A+"
elif percentage >= 80:
grade = "A"
elif percentage >= 70:
grade = "B"
elif percentage >= 60:
grade = "C"
elif percentage >= 50:
grade = "D"
else:
grade = "F"

print(f"\nTotal Marks: {total_marks}/500")


print(f"Percentage: {percentage:.2f}%")
print(f"Grade: {grade}")
Output:

You might also like