Practical N0:-4 Name:-Shweta Chavan Patil Roll No:-3207 1.if
Practical N0:-4 Name:-Shweta Chavan Patil Roll No:-3207 1.if
1.If
if a>=18:
Output:-
2.If else
if a>b:
else:
3.Nested If
a=int(input("Enter value"))
if a>0:
print("a is positive")
elif a<0:
print("a is negative")
else:
print("a is 0")
Output:-
Exercise:-
1.
Output:-
2.
num = float(input("Enter a number: "))
abs_value = abs(num)
print("The absolute value is:", abs_value)
Output:-
3.
Output:-
4.
year = int(input("Enter a year: "))
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
print(f"{year} is a leap year.")
else:
print(f"{year} is not a leap year.")
Output:
5.
Output:-