4th Practical
4th Practical
Program:
num=int(input("Enter a number to check: "))
if num%2==0:
print("Even")
else:
print("Odd")
Output:
Program:
number=float(input("Enter a value: "))
absolute=abs(number)
print("Absolute value of ",number," is: ",absolute)
Output:
Program:
a=int(input("Enter 1st number: "))
b=int(input("Enter 2nd number: "))
c=int(input("Enter 3rd number: "))
if a>b and a>c:
print(a,"is the largest number")
elif b>c and b>c:
print(b,"is the largest number")
elif c>a and c>b:
print(c,"is the largest number")
else:
print("All are equal")
Output:
Program:
year=int(input("Enter the year to be check: "))
if year%4==0:
print("Leap Year")
else:
print("Non-Leap Year")
Output:
Program:
number=int(input("Enter a number: "))
if number>0:
print("Entered number",number,"is Positive number.")
elif number<0:
print("Entered number",number,"is Negative number.")
else:
print("Entered number",number,"is Zero.")
Output:
6. WAP that takes the marks of 5 subjects and displays the grade.
Program:
#Max marks=100
Sub1=int(input("Enter the marks of 1st subject: "))
Sub2=int(input("Enter the marks of 2nd subject: "))
Sub3=int(input("Enter the marks of 3rd subject: "))
Sub4=int(input("Enter the marks of 4th subject: "))
Sub5=int(input("Enter the marks of 5th subject: "))
total=Sub1+Sub2+Sub3+Sub4+Sub5
percentage=(total/500)*100
if percentage>=90:
grade=("A+ (Excellent)")
elif percentage>=80:
grade=("A (Very Good)")
elif percentage>=70:
grade=("B (Good)")
elif percentage>=60:
grade=("C (Average)")
elif percentage>=40:
grade=("D (Pass)")
else:
grade=("F (Fail)")
print(grade)
Output: