VELAMMAL BODHI CAMPUS- ATTUR WEEK-2 (PRACTICE
PRACTICE THE ILLUSTRATE FLOW CHART AND CODING -
USING SOFTWARE)
CODING CLUB ACTIVITY FOR HIGH COMPARTMENT
1) Odd or even :
PYTHON CODING – AUGUST MONTH
WEEK-1(STATEMENT CONDITION -if statement, if-else statement) x = int(input(“enter the number”))
1. If Statement: The if statement is used to execute a block of code if a condition is true. if x % 2 == 0:
print(x,"Is Even Number")
else:
IF STATEMENT (EXAMPLE-1)
print(x, "Is Odd Number")
X=10
if X>5:
Print (“X is greater than 5”)
2. If-else Statement: The if-else statement allows you to execute one block of code if the
condition is true and another block of code if the condition is false.
IF-ELSE STATEMENT (EXAMPLE-2)
#python
X=10
num1 = 10
if X>5:
num2 = 4
Print (“X is greater than 5”)
else:
if num1 > num2:
print(“X is lesser than 5”) greatest_number = num1
else:
greatest_number = num2
print("The greatest number is:",
greatest_number)
WEEK-4(PRACTICE
PRACTICE THE IL
ILLUSTRATE
LUSTRATE FLOW CHART AND CODING -
USING SOFTWARE)
WEEK-3(STATEMENT
3(STATEMENT CONDITION - if-elif-else statement)
The if statement checks a condition, and if it's true, executes a block of code.
The elif statement (short for "else if") allows you to check additional conditions if
the preceding if statement is false.
The else statement is executed if none of the preceding conditions are true. It's
optional and comes at the end. You can only have one else statement, and it's
usually the last part of the if statement.
SYNTAX
if [statements]:
#block of code to execute if statement is true
elif[statements]:
#block of code to execute if statement is false and elif statement is true
else[statements]: n=int(input(“Enter the number”))
# if the number is positive
#block of code to execute both if statement and elif statement are false
if n > 0:
print("Positive")
# if the number is negative
elif n < 0:
print("Negative")
# if the number is equal to
# zero
else:
print("Equal to zero")
EXAMPLE
price = 50
if price > 100:
print("price is greater than 100")
elif price == 100:
print("price is 100")
else price < 100:
print("price is less than 100")