# SCMA241 Lab : Decision Structure

In [3]:
# a program to find an absolute value
number = float(input('Enter number : '))

if number < 0:
print('Absolute value of',number,'is',-number)
else:
print('Absolute value of',number,'is',number)

Enter number : -9
Absolute value of -9.0 is 9.0

In [6]:
import math

In [10]:
math.sqrt(2)

Out[10]:
1.4142135623730951
In [15]:
# find the median of x_1, x_2, and x_3

x=float(input("number1 : "))
y=float(input("number2 : "))
z=float(input("number3 : "))

if(x==y) and (x==z):
print("median is",x)
elif x==y:
print("median is",x)
elif y==z:
print("median is",y)
elif(x>y) and (x<z):
print("median is",x)
elif(y>x) and (y<z):
print("medain is",y)
elif(x>z) and (y>x):
print("median is",x)
else:
print("medain is",z)

number1 : 6
number2 : 5
number3 : 1
medain is 1.0

In [6]:
# leap year?
year = int(input("Year? "))

if (year%4 == 0) and (year%100!=0):
print(year,'is a leap year.')
elif (year%4 == 0) and (year%100==0) and (year%400==0):
print(year,'is a leap year.')
else:
print(year,'is not a leap year.')

Year? 2000
2000 is a leap year.

In [ ]:


In [ ]: