Chapter 16 - if Selection Structure
- Authors
- Ms. Samavi Salman
- Dr. Rao Muhammad Adeel Nawab
- Supporting Material
IF Statement in Python
- If Statement
- Definition
- if statement is an expression that can be evaluated as True or False and is called a conditional test
- It executes a set of statements conditionally, based on the value of a logical expression
- Purpose
- The main purpose if statement is that it takes the form of an if test, followed by one or more optional elif (“else if”) tests and a final optional else block
- Python if Statement is used for decision-making operations
- The main purpose if statement is that it takes the form of an if test, followed by one or more optional elif (“else if”) tests and a final optional else block
- Importance
- When the if statement runs, Python executes the block of code associated with the first test that evaluates to true, or the else block if all tests prove false
- Python uses the if keyword to implement decision control
- Strengths
- If statement is used to satisfy the given condition(s) and then execute the particular set of code(s)
- Weakness
- If statement checks all the conditions mentioned in a program which results in slow compilation and increases computational cost
- Suitable to Use
- if statement to perform operations when there are multiple possibilities and each must be evaluated differently
Single if Statement
- Syntax – Single if Statement
'''
if Condition is True the block will be executed otherwise the control will move to the endif statement
'''
if condition:
….
endif
- Flowchart – Single if Statement
- Note
- If Condition is True, then
- Statements after if-Statement will be executed
- If Condition is False, then
- Statements after if-Statement will not be executed
- If Condition is True, then
- Conclusion
- In Decision Making
- Some Statements will be executed and
- Some statements will be skipped
- In Decision Making
Multiple if Statement
- Syntax – Multiple if Statement
'''
if Condition is True the block will be executed otherwise the control will move to the next if statement. If the condition is True, the block of if condition will be executed.
'''
if condition:
….
if condition:
….
if condition:
….
endif
- Flowchart – Multiple if Statement
- Note
- If Condition is True, then
- Statements after if-Statement will be executed
- If Condition is False, then
- Statements after if-Statement will not be executed and the control will be moved to next if condition
- If Condition is True, then
- Conclusion
- In Decision Making
- Some Statements will be executed and
- Some statements will be skipped
- In Decision Making
- Example 1 – IF Statement
Completely and Correctly Understand a Task |
Task Description |
|
Sample Outputs |
Sample Output 01 Enter an Integer Number: 5 5 is an Odd Number ——————————————————- Sample Output 02 Enter an Integer Number: 100 100 is an Even Number ——————————————————- Sample Output 03 Enter an Integer Number: 10.25 Sorry Invalid Input!!! Please Enter an Integer Number ——————————————————- Sample Output 04 Enter an Integer Number: honest Sorry Invalid Input!!! Please Enter an Integer Number |
Plan and Design Solution to the Task |
Input-Processing-Output |
|
Pseudo Code |
Step 1: Start Step 2: Input – number (Integer Value) Step 3: if Modulus of number with 2 is equal to 0 Print – Even Number endif if Modulus of number with 2 is equal to 1 Print – Odd Number endif Step 4: Stop |
Flow Chart |
Implementation in Python |
Code |
'''
__author__ = Ms. Samavi Salman
__copyright__= Copyright I 2020 Ms. Samavi Salman
__license__ = Public Domain
__version__ = 1.0
'''
'''
The main purpose of this Program is to take an Integer Number as Input from User and check whether it’s an Even Number or an Odd Number?
'''
try:
# Take an Integer Number as Input from User
number = int(input("Enter an Integer Number: "))
# Decision Making - Check whether Condition is True or False
if number % 2 == 0:
print(number, "is an Even Number")
# Decision Making - Check whether Condition is True or False
if number % 2 == 1:
print(number, "is an Odd Number")
except ValueError:
print("Sorry Invalid Input!!! Please Enter an Integer Number")
Execution of Code (Dry Run) | ||||
Python Statement | Calculations | Variable(s) | Output Screen | |
try: | ||||
number = int(input(“Enter an Integer Number: “)) | number = 5 | Enter an Integer Number: 5 | ||
if number % 2 == 0: | Decision Making – Check Whether Condition is True or False number % 2 == 0 5 % 2 == 0 1 == 0 False (i.e., Statement(s) will be executed after if-Statement) | number = 5 | Enter an Integer Number: 5 | |
print(number, “is an Even Number”) | This Statement will not be executed because Condition is False in above if-Statement (see Output Screen) | number = 5 | Enter an Integer Number: 5 | |
if number % 2 == 1: | Decision Making – Check Whether Condition is True or False number % 2 == 0 5 % 2 == 1 1 == 1 True (i.e., Statement(s) will be executed after if-Statement) | number = 5
| Enter an Integer Number: 5 | |
print(number, “is an Odd Number”) | This Statement will be executed because Condition is True in above if-Statement (see Output Screen) | number = 5 | Enter an Integer Number: 5 5 is an Odd Number | |
except: | number = 5 | Enter an Integer Number: 5 5 is an Odd Number | ||
print(“Sorry Invalid Input!!! Please Enter an Integer Number”) | number = 5 | Enter an Integer Number: 5 5 is an Odd Number | ||
Output of Code | ||||
Enter an Integer Number: 5 |
- Example 2 – IF Statement
Completely and Correctly Understand a Task |
Task Description |
|
Sample Outputs |
Sample Output 01 Enter First Number: 10 Enter Second Number: 20 Enter an Operator: + 10 + 20 = 30 —————————————- Sample Output 02 Enter First Number: 10 Enter Second Number: 20 Enter an Operator: – 10 – 20 = -10 —————————————- Sample Output 03 Enter First Number: 10 Enter Second Number: 20 Enter an Operator: * 10 * 20 = 200 —————————————- Sample Output 04 Enter First Number: 10 Enter Second Number: 20 Enter an Operator: / 10 / 20 = 0 —————————————- Sample Output 05 Enter First Number: 5 Enter Second Number: 2 Enter an Operator: ** 5 ** 2 = 25 —————————————- Sample Output 06 Enter First Number: 10.25 Enter Second Number: 20.50 Enter an Operator: + 10.25 + 20.50 = 30.37 —————————————- Sample Output 07 Enter First Number: 10.25 Enter Second Number: 20.50 Enter an Operator: – 10.25 – 20.50 = -10.25 —————————————- Sample Output 08 Enter First Number: 10.25 Enter Second Number: 20.50 Enter an Operator: * 10.25 * 20.50 = 210.12 —————————————- Sample Output 09 Enter First Number: 10.25 Enter Second Number: 20.50 Enter an Operator: / 10.25 / 20.50 = 0.5 —————————————- Sample Output 10 Enter First Number: 10 Enter Second Number: 0 Enter an Operator: / Sorry Invalid Division. Please enter Integer / Float Number other than ZERO —————————————- Sample Output 11 Enter First Number: faith Sorry Invalid Input. Please enter Integer / Float Number —————————————- Sample Output 12 Enter First Number: 10 Enter Second Number: faith Sorry Invalid Input. Please enter Integer / Float Number —————————————- Sample Output 13 Enter First Number: 10 Enter Second Number: 20 Enter an Operator: # Sorry Invalid Input. Please enter a Valid Operator |
Plan and Design Solution to the Task |
Input-Processing-Output |
|
Pseudo Code |
Step 1: Start Step 2: Input – number1 Step 3: Input – number2 Step 4: Input – operator (Arithmetic Operator) Step 5: if operator is equal to ‘+’ Print – Sum of number1 and number2 endif if operator is equal to ‘-‘ Print – Subtraction of number2 from number1 endif if operator is equal to ‘*’ Print – Product (Multiplication) of number1 and number2 endif if operator is equal to ‘/’ Print – Division of number1 by number2 endif if operator is equal to ‘**’ Print – Exponent of number1 with number2 endif Step 6: Stop |
Flow Chart |
Implementation in Python |
Code |
'''
__author__ = Ms. Samavi Salman
__copyright__= Copyright I 2020 Ms. Samavi Salman
__license__ = Public Domain
__version__ = 1.0
'''
'''
The main Purpose of the Program is to take two Numbers (Integer / Float) and an Operator as Input from User and perform Arithmetic Operation on Operands (Two Numbers) based on Value of Operator
'''
try:
# Take Two Numbers (Integer / Float) as Input from User
number1 = float(input("Enter First Number: "))
number2 = float(input("Enter Second Number: "))
# Take Operator as input from User
operator = input("Enter an Operator: ")
# Decision Making Check whether Value of Operator is + or not
if operator == '+':
print(number1,"+",number2,"=", number1 + number2)
# Decision Making Check whether Value of Operator is - or not
if operator == '-':
print(number1,"-",number2,"=", number1 - number2)
# Decision Making Check whether Value of Operator is * or not
if operator == '*':
print(number1,"*",number2,"=", number1 * number2)
# Decision Making Check whether Value of Operator is / or not
if operator == '/':
print(number1,"/",number2,"=", number1 / number2)
# Decision Making Check whether Value of Operator is ** or not
if operator == '**':
print(number1,"**",number2,"=", number1 ** number2)
except ValueError:
print("Sorry Invalid Input. Please enter Integer / Float Number")
except ZeroDivisionError:
print("Sorry Invalid Division. Please enter Integer / Float Number other than ZERO")
Execution of Code (Dry Run) | |||
Python Statement | Calculations | Variable(s) | Output Screen |
try: | |||
number1 = float(input(“Enter First Number: “)) | number1 = 10 | Enter First Number: 10 | |
number2 = float(input(“Enter Second Number: “)) | number1 = 10 number2 = 30 | Enter First Number: 10 Enter Second Number: 30 | |
operator = input(“Enter an Operator: “) | number1 = 10 number2 = 30 operators = ‘+’, ‘-‘, ‘*’, ‘/’ operator = / | Enter First Number: 10 Enter Second Number: 30 Enter an Operator: / | |
if operator == ‘+’: | Decision Making – Check Whether Condition is True or False operator == + / == + False (i.e., Statement(s) will be executed after if-Statement) | number1 = 10 number2 = 30 operators = ‘+’, ‘-‘, ‘*’, ‘/’ operator = / | Enter First Number: 10 Enter Second Number: 30 Enter an Operator: / |
print(number1,”+”,number2,”=”, number1 + number2) | This Statement will not be executed because Condition is False in above if-Statement (see Output Screen) | number1 = 10 number2 = 30 operators = ‘+’, ‘-‘, ‘*’, ‘/’ operator = / | Enter First Number: 10 Enter Second Number: 30 Enter an Operator: / |
if operator == ‘-‘: | Decision Making – Check Whether Condition is True or False / == – False (i.e., Statement(s) will be executed after if-Statement) | number1 = 10 number2 = 30 operators = ‘+’, ‘-‘, ‘*’, ‘/’ operator = / | Enter First Number: 10 Enter Second Number: 30 Enter an Operator: / |
print(number1,”-“,number2,”=”, number1 – number2) | This Statement will not be executed because Condition is False in above if-Statement (see Output Screen) | number1 = 10 number2 = 30 operators = ‘+’, ‘-‘, ‘*’, ‘/’ operator = / | Enter First Number: 10 Enter Second Number: 30 Enter an Operator: / |
if operator == ‘*’: | Decision Making – Check Whether Condition is True or False / == * False (i.e., Statement(s) will be executed after if-Statement) | number1 = 10 number2 = 30 operators = ‘+’, ‘-‘, ‘*’, ‘/’ operator = / | Enter First Number: 10 Enter Second Number: 30 Enter an Operator: / |
print(number1,”*”,number2,”=”, number1 * number2) | This Statement will not be executed because Condition is False in above if-Statement (see Output Screen) | number1 = 10 number2 = 30 operators = ‘+’, ‘-‘, ‘*’, ‘/’ operator = / | Enter First Number: 10 Enter Second Number: 30 Enter an Operator: / |
if operator == ‘/’: | Decision Making – Check Whether Condition is True or False / == / True (i.e., Statement(s) will be executed after if-Statement) | number1 = 10 number2 = 30 operators = ‘+’, ‘-‘, ‘*’, ‘/’ operator = / | Enter First Number: 10 Enter Second Number: 30 Enter an Operator: / |
print(number1,”/”,number2,”=”, number1 / number2) | 10 / 30 = 0.33 This Statement will be executed because Condition is True in above if-Statement (see Output Screen) | number1 = 10 number2 = 30 operators = ‘+’, ‘-‘, ‘*’, ‘/’ operator = / 10 / 30 = 0.33 | Enter First Integer Number: 10 Enter Second Integer Number: 30 Enter an Integer Number: / Calculate Division of Numbers 10 30 10 / 30 = 0.33 |
if operator == ‘**’: | Decision Making – Check Whether Condition is True or False / == ** False (i.e., Statement(s) will be executed after if-Statement) | number1 = 10 number2 = 30 operators = ‘+’, ‘-‘, ‘*’, ‘/’ operator = / 10 / 30 = 0.33 | Enter First Number: 10 Enter Second Number: 30 Enter an Operator: / 10 / 30 = 0.33 |
print(number1,”**”,number2,”=”, number1 ** number2) | This Statement will not be executed because Condition is False in above if-Statement (see Output Screen) | number1 = 10 number2 = 30 operators = ‘+’, ‘-‘, ‘*’, ‘/’ operator = / 10 / 30 = 0.33 | Enter First Number: 10 Enter Second Number: 30 Enter an Operator: / 10 / 30 = 0.33 |
except ValueError: | number1 = 10 number2 = 30 operators = ‘+’, ‘-‘, ‘*’, ‘/’ operator = / 10 / 30 = 0.33 | Enter First Number: 10 Enter Second Number: 30 Enter an Operator: / 10 / 30 = 0.33 | |
print(“Sorry Invalid Input. Please enter Integer / Float Number”) | number1 = 10 number2 = 30 operators = ‘+’, ‘-‘, ‘*’, ‘/’ operator = / 10 / 30 = 0.33 | Enter First Number: 10 Enter Second Number: 30 Enter an Operator: / 10 / 30 = 0.33 | |
except ZeroDivisionError: | number1 = 10 number2 = 30 operators = ‘+’, ‘-‘, ‘*’, ‘/’ operator = / 10 / 30 = 0.33 | Enter First Number: 10 Enter Second Number: 30 Enter an Operator: / 10 / 30 = 0.33 | |
print(“Sorry Invalid Division. Please enter Integer Number other than ZERO”) | number1 = 10 number2 = 30 operators = ‘+’, ‘-‘, ‘*’, ‘/’ operator = / 10 / 30 = 0.33 | Enter First Number: 10 Enter Second Number: 30 Enter an Operator: / 10 / 30 = 0.33 | |
Output of Code | |||
Enter First Number: 10 |
- Example 3 – IF Statement
Completely and Correctly Understand a Task |
Task Description |
|
Sample Outputs |
Sample Output 01 Enter First Number: 2000 Enter Second Number: 1000 number1 is greater than number2 —————————————————— Sample Output 02 Enter First Number: 4000 Enter Second Number: 6000 number2 is greater tan number1 —————————————————— Sample Output 03 Enter First Number: 60.90 Enter Second Number: 60.90 number1 is equal to number2 —————————————————— Sample Output 04 Enter First Number: loyal Sorry Invalid Input !!! Please enter Integer / Float Number —————————————————— Sample Output 05 Enter First Number: 60 Enter Second Number: loyal Sorry Invalid Input !!! Please enter Integer / Float Number |
Plan and Design Solution to the Task |
Input-Processing-Output |
|
Pseudo Code |
Step 1: Start Step 2: Input – number1 (Integer / Float Value) Step 3: Input – number2 (Integer / Float Value) Step 3: if number1 is greater than number2 Print – number1 is greater than number2 endif if number2 is greater than number2 Print – number2 is greater than number1 endif if number1 is equal to number2 Print – number1 is equal to number2 endif Step 4: Stop |
Flow Chart |
Implementation in Python |
Code |
'''
__author__ = Ms. Samavi Salman
__copyright__= Copyright I 2020 Ms. Samavi Salman
__license__ = Public Domain
__version__ = 1.0
'''
'''
The main purpose of this Program is to take two Numbers (Integer / Float) as Input from User and check which number1 is Greater than number2 or vice versa or both numbers are Equal?
'''
try:
# Take Two Numbers as Input from User
number1 = float(input("Enter First Number: "))
number2 = float(input("Enter Second Number: "))
# Decision Making - Check whether Condition is True or False
if number1 > number2:
print("number1 is greater than number2")
if number2 > number1:
print("number2 is greater than number1")
if number1 == number2:
print("number1 is equal to number2")
except ValueError:
print("Sorry Invalid Input !!! Please enter Integer / Float Number")
Execution of Code (Dry Run) | |||
Python Statement | Calculations | Variable(s) | Output Screen |
try: | |||
number1 = float(input(“Enter First Number: “)) | number1 = 10 | Enter First Number: 10 | |
number2 = float(input(“Enter Second Number: “)) | number1 = 10 number2 = 5 | Enter First Number: 10 Enter Second Number: 5 | |
if number1 > number2: | Decision Making – Check Whether Condition is True or False 10 > 5 True (i.e., Statement(s) will be executed after if-Statement) | number1 = 10 number2 = 5 | Enter First Number: 10 Enter Second Number: 5 |
print(“number1 is greater than number2”) | This Statement will be executed because Condition is True in above if-Statement (see Output Screen) | number1 = 10 number2 = 5 | Enter First Number: 10 Enter Second Number: 5 number1 is greater than number2 |
if number2 > number1: | Decision Making – Check Whether Condition is True or False 10 < 5 False (i.e., Statement(s) will be executed after if-Statement) | number1 = 10 number2 = 5 | Enter First Number: 10 Enter Second Number: 5 number1 is greater than number2 |
print(“number2 is greater than number1”) | This Statement will not be executed because Condition is False in above if-Statement (see Output Screen) | number1 = 10 number2 = 5 | Enter First Number: 10 Enter Second Number: 5 number1 is greater than number2 |
if number1 == number2: | Decision Making – Check Whether Condition is True or False 10 == 5 False (i.e., Statement(s) will be executed after if-Statement) | number1 = 10 number2 = 5 | Enter First Number: 10 Enter Second Number: 5 number1 is greater than number2 |
print(“number1 is equal to number2”) | This Statement will not be executed because Condition is False in above if-Statement (see Output Screen) | number1 = 10 number2 = 5 | Enter First Number: 10 Enter Second Number: 5 number1 is greater than number2 |
except ValueError: | number1 = 10 number2 = 5 | Enter First Number: 10 Enter Second Number: 5 number1 is greater than number2 | |
print(“Sorry Invalid Input !!! Please enter Integer / Float Number”) | number1 = 10 number2 = 5 | Enter First Number: 10 Enter Second Number: 5 number1 is greater than number2 | |
Output of Code | |||
Enter First Number: 10 |
- Example 4 – IF Statement
Completely and Correctly Understand a Task |
Task Description |
|
Sample Outputs |
Sample Output 01 Enter Marks in Course: 89.5 You Passed the Course of Introduction to Python ————————————————————– Sample Output 02 Enter Marks in Course: 49.9 You Failed the Course of Introduction to Python ————————————————————– Sample Output 03 Enter Marks in Course: 50 You Passed the Course of Introduction to Python ————————————————————– Sample Output 04 Enter Marks in Course: 45 You Failed the Course of Introduction to Python ————————————————————– Sample Output 05 Enter Marks in Course: passion Sorry !!!. Invalid Input. Please enter Integer / Float Number |
Plan and Design Solution to the Task |
Input-Processing-Output |
|
Pseudo Code |
Step 1: Start Step 2: Input – number (Integer Value) Step 3: if marks are greater than or equal to 50.0 Print – You Passed the Course endif
if marks are less than 50.0 Print – You Failed the Course endif Step 4: Stop |
Flow Chart |
Implementation in Python |
Code |
'''
__author__ = Ms. Samavi Salman
__copyright__= Copyright I 2020 Ms. Samavi Salman
__license__ = Public Domain
__version__ = 1.0
'''
'''
The main purpose of this Program is to take Marks in Introduction to Python course as Input from User and check whether the Student Passed the Course or Not
'''
try:
# Take a Marks (Integer / Float) as Input from User
marks = float(input("Enter Marks in Course: "))
# Decision Making - Check whether Condition is True or False
if marks >= 50.0:
print("You Passed the Course of Introduction to Python")
if marks < 50:
print("You Failed the Course of Introduction to Python")
except ValueError:
print("Sorry !!!. Invalid Input. Please enter Integer / Float Number")
Execution of Code (Dry Run) | ||||
Python Statement | Calculations | Variable(s) | Output Screen | |
try: | ||||
marks = float(input(“Enter Marks in Course: “)) | marks = 49.99 | Enter Marks in Course: 49.99 | ||
if marks >= 50.0: | Decision Making – Check Whether Condition is True or False marks >= 50.0 49.99 >= 50.0 False (i.e., Statement(s) will be executed after if-Statement) | marks = 49.99 | Enter Marks in Course: 49.99 | |
print(“You Passed the Course of Introduction to Python”) | This Statement will not be executed because Condition is False in above if-Statement (see Output Screen) | marks = 49.99 | Enter Marks in Course: 60 | |
if marks < 50.0: | Decision Making – Check Whether Condition is True or False marks < 50.0 49.99 < 50.0 True (i.e., Statement(s) will be executed after if-Statement) | marks = 49.99 | Enter Marks in Course: 49.99 | |
print(“You Failed the Course of Introduction to Python”) | This Statement will be executed because Condition is True in above if-Statement (see Output Screen) | marks = 49.99 | Enter Marks in Course: 49.99 You Failed the Course of Introduction to Python | |
except ValueError: | marks = 49.99 | Enter Marks in Course: 49.99 You Failed the Course of Introduction to Python | ||
print(“Sorry !!!. Invalid Input. Please enter Integer / Float Number”) | marks = 49.99 | Enter Marks in Course: 49.99 You Failed the Course of Introduction to Python | ||
Output of Code | ||||
Enter Marks in Course: 49.99 |
- Example 5 – IF Statement
Completely and Correctly Understand a Task |
Task Description |
|
Sample Outputs |
Sample Output 01 Enter a Number: 50.45 50.45 is a Positive Number ———————————————— Sample Output 02 Enter a Number: 0 0 is a Positive Number ———————————————— Sample Output 03 Enter a Number: -45.76 -45.76 is a Negative Number ———————————————— Sample Output 04 Enter a Number: -1000 -1000 is a Negative Number ———————————————— Sample Output 05 Enter a Number: courage Sorry !!!. Invalid Input. Please enter Integer / Float Number |
Plan and Design Solution to the Task |
Input-Processing-Output |
|
Pseudo Code |
Step 1: Start Step 2: Input – number Step 3: if number is greater than or equal to 0.0 Print – Positive Number endif
if number is less than 0.0 Print – Negative Number endif Step 6: Stop |
Flow Chart |
Implementation in Python |
Code |
'''
__author__ = Ms. Samavi Salman
__copyright__= Copyright I 2020 Ms. Samavi Salman
__license__ = Public Domain
__version__ = 1.0
'''
'''
The main purpose of this Program is to take a Number (Integer / Float) as Input from User and check whether it’s a Positive Number or a Negative Number?
'''
try:
# Take a Number (Integer / Float) as Input from User
number = float(input("Enter a Number: "))
# Decision Making - Check whether Condition is True or False
if number >= 0.0:
print(number, "is a Positive Number")
if number < 0.0:
print(number, "is a Negative Number")
except ValueError:
print("Sorry !!!. Invalid Input. Please enter Integer / Float Number")
Execution of Code (Dry Run) | |||
Python Statement | Calculations | Variable(s) | Output Screen |
number = int(input(“Enter an Integer Number: “)) | number = -100 | Enter an Integer Number: -100 | |
if number >= 0: | Decision Making – Check Whether Condition is True or False number > 0 -100 > 0 False (i.e., Statement(s) will be executed after if-Statement) | number = -100 | Enter an Integer Number: -100 |
print(number, “is a Positive Number”) | This Statement will not be executed because Condition is False in above if-Statement (see Output Screen) | number = -100 | Enter an Integer Number: -100 |
if number < 0.0: | Decision Making – Check Whether Condition is True or False number < 0.0 -100 < 0.0 True (i.e., Statement(s) will be executed after if-Statement) | number = -100 | Enter an Integer Number: -100 |
print(number, ” is a Negative Number “) | This Statement will be executed because Condition is True in above if-Statement (see Output Screen) | number = -100 | Enter an Integer Number: -100 -100 is a Negative Number |
Output of Code | |||
Enter an Integer Number: -100 |
TODO and Your Turn
TODO Task 1
- Task
- Consider the following Tasks and answer the questions given below
- Note
- Your answer should be
- Well Justified
- Your answer should be
- Questions
- Write Python Programs for all the Tasks given below by following
- If Statement
- Write Python Programs for all the Tasks given below by following
Task 1 |
Completely and Correctly Understand the Task |
Task Description |
|
Sample Output |
Sample 1 —————————- Enter an Integer Number: 49 Number is divisible by 7 Sample 2 —————————- Enter an Integer Number: 25 Number is divisible by 5 Sample 3 —————————- Enter an Integer Number: 81 Number is divisible by 3 Number is divisible by 9 |
Task 2 |
Completely and Correctly Understand the Task |
Task Description |
|
Sample Output |
Enter Salary: 50000 Bonus: 40% of Basic Salary |
Your Turn Task 1
- Task
- Write at least 4 different Tasks which are very similar to the ones given in the TODO Tasks
- For each Task write a Python Program for all the Tasks given below by following
- If Statement
- For each Task write a Python Program for all the Tasks given below by following
- Write at least 4 different Tasks which are very similar to the ones given in the TODO Tasks