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

Name: Rais Saaim Ravish Enrollment No: 2105690153 Batch: 2 1.write A Program To Check Whether A Number Is Even or Odd

The document contains 6 Python programs written by a student named Rais Saaim Ravish for their enrollment number 2105690153. The programs include: 1) A program to check if a number is even or odd 2) A program to find the absolute value of a number 3) A program to find the largest of 4 numbers 4) A program to check if a year is a leap year 5) A program to check if a number is positive, negative, or zero 6) A program to calculate the grade from marks in 5 subjects

Uploaded by

ciscopackett498
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)
15 views

Name: Rais Saaim Ravish Enrollment No: 2105690153 Batch: 2 1.write A Program To Check Whether A Number Is Even or Odd

The document contains 6 Python programs written by a student named Rais Saaim Ravish for their enrollment number 2105690153. The programs include: 1) A program to check if a number is even or odd 2) A program to find the absolute value of a number 3) A program to find the largest of 4 numbers 4) A program to check if a year is a leap year 5) A program to check if a number is positive, negative, or zero 6) A program to calculate the grade from marks in 5 subjects

Uploaded by

ciscopackett498
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

Name: Rais Saaim Ravish Enrollment No: 2105690153 Batch: 2

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


print("Even odd program")
num = int(input("Enter the number"))

if (num%2==0):
print("Number is even")

else:
print("Number is odd")

OUTPUT
Even odd program
Enter the number4

Number is even

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


print("Absulute number value")

num = int(input("Enter the number:\t"))

if(num>=0):

print("Absulute value is:\t",num)


else:
num = -num

print("Absulute value is:\t",num)

OUTPUT
Absulute number value
Enter the number: -56

Absulute value is: 56


3. Write a program to check the largest number among the three numbers
print("Program for largest number amoung four")
a = int(input("Enter the value of a:\t"))

b = int(input("Enter the value of b:\t"))

c = int(input("Enter the value of c:\t"))

d = int(input("Enter the value of d:\t"))

if(a>b and a>c and a>d):


print("A is greater")

if(b>a and b>c and b>d):


print("B is greater")

if(c>a and c>b and c>d):

print("C is greater")

if(d>a and d>b and d>c):


print("D is greater")

OUTPUT
Program for largest number amoung four

Enter the value of a: 3

Enter the value of b: 7


Enter the value of c: 3

Enter the value of d: 8


D is greater

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


print("Leap year program")
num = int(input("Enter the Year:\t"))
if (num%4==0):

print("It is a leap year")

else:

print("It is not a leap year")

OUTPUT
Leap year program

Enter the Year:2024

It is a leap year

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


num = int(input("Enter the Number:\t"))

if num >= 0:
if num == 0:

print("Number is zero")
else:

print("Number is positive")
else:
print("Number is negative")

OUTPUT
Enter the Number: 0
Number is zero

6. Write a program that takes the marks of 5 subjects and displays the grade.
sub1 = int(input("Enter the marks of subject 1 :\t"))
sub2 = int(input("Enter the marks of subject 2:\t"))

sub3 = int(input("Enter the marks of subject 3:\t"))


sub4 = int(input("Enter the marks of subject 4:\t"))
sub5 = int(input("Enter the marks of subject 5:\t"))

avg = (sub1+sub2+sub3+sub4+sub5)/5

print(avg)

if (avg>=90):
print("Your grade is A+")

elif(avg>=80 and avg<90):

print("Your grade is A")


elif(avg>=60 and avg<80):

print("Your grade is B+")


elif(avg>=50 and avg<60):

print("Your grade is B")


elif(avg>=40 and avg<50):

print("Your grade is C")


else:

print("Try next time!")

OUTPUT
Enter the marks of subject 1 : 45

Enter the marks of subject 2: 39


Enter the marks of subject 3: 56

Enter the marks of subject 4: 42


Enter the marks of subject 5: 69

50.2

Your grade is B

You might also like