The document contains 6 Python code snippets that use conditional statements like if/else to evaluate inputs and display corresponding outputs. The snippets check if a number is even or odd, positive or negative, determine the greatest of three numbers, identify leap years, and calculate and print a grade based on the average of 5 subjects.
The document contains 6 Python code snippets that use conditional statements like if/else to evaluate inputs and display corresponding outputs. The snippets check if a number is even or odd, positive or negative, determine the greatest of three numbers, identify leap years, and calculate and print a grade based on the average of 5 subjects.
The document contains 6 Python code snippets that use conditional statements like if/else to evaluate inputs and display corresponding outputs. The snippets check if a number is even or odd, positive or negative, determine the greatest of three numbers, identify leap years, and calculate and print a grade based on the average of 5 subjects.
if(i%2==0): print(i," is Even number") else: print(i," is Odd number")
2.
a=int(input("Enter a number " ))
if(a<0): b=(a*(-1)) print("Your number is ",b) else: print("Your absolute number is ",a)
3.
a=int(input("Enter first number:"))
b=int(input("Enter second number: ")) c=int(input("Enter third number: ")) if(a>=b and a>=c): print(a," is greater number ") elif(b>=a and b>=c): print(b," is greater number ") elif(c>=a and c>=b): print(c," is greater number ") else: print("All numbers are equal ")
4.
a=int(input("Enter a year: "))
if(a%4==0): print(a," is a leap year") else: print(a," is not a leap year")
5.
a=int(input("Enter a number: "))
if(a>0): print(a," is a positive number") elif(a<0): print(a," is a negative number") else: print(a," is a zero")
6.
a1=int(input("Marks of 1st sub : "))
a2=int(input("Marks of 2nd sub : ")) a3=int(input("Marks of 3rd sub : ")) a4=int(input("Marks of 4th sub : ")) a5=int(input("Marks of 5th sub : ")) avg=(a1+a2+a3+a4+a5)/5 print("Your Average is ",avg) if(avg<100 and avg>=80): print("Distinction") elif(avg < 80 and avg >= 70): print("A") elif(avg < 70 and avg >= 60): print("B") elif (avg < 60 and avg >= 50): print("C") elif(avg < 50 and avg >= 35): print("D") else: print("Fail")