Lab 2 RPT
Lab 2 RPT
APPLICATIONS OF ICT
INTRODUCTION TO CONDITIONAL STATEMENTS AND LOGICAL OPERATIONS IN PYTHON.
SUBMITTED BY:
➢ SALMAN AHMAD KHAN
➢ M. MOBEEN ZAFAR
➢ AREESHA NAEEM
SUBMITTED TO:
➢ DR ASAD MANSOOR
➢ Ms. KASHAF RAHEEM
SUMISSION DATE:
28/09/2024
TOPIC
INTRODUCTION TO CONDITIONAL
STATEMENTS AND LOGICAL
OPERATIONS IN PYTHON .
OBJECTIVES:
• How to write algorithms including conditions.
• Understanding and solving problems.
• Applications of conditional operators.
• Importance of indentation.
• Understanding input validation.
HARDWARE/SOFTWARE USED:
PC
IDLE 3.12
TASKS:
Different tasks were assigned to grasp better understanding of the
above-mentioned. These tasks are as follows:
TASK_01:
Write a python script that asks user to select one of the operations
following performs the said operation on 2 inputs provided by user.
PSEUDO CODE:
Start.
Tell the user to enter number 1.
Tell the user to enter number 2.
Ask the user to select the operation.
Process the sum of the entered numbers.
Process the difference of the entered numbers.
Process the product of the entered numbers.
Process the division of the entered numbers.
If operation chosen is “0” print the sum of the numbers.
If operation chosen is “1” print the difference of the numbers.
If operation chosen is “2” print the product the of numbers.
If operation chosen is “3” print the division of the numbers.
If none of the above-mentioned operations are chosen, print Invalid input.
End.
FLOWCHART:
INPUT:
OUTPUT:
TASK 2:
Modify last week's grocery bill task such that the cashier enters type
of item and its quantity to get the payment. Program allows getting
payment per item.
Pseudo Code :
Start.
Ask the user to enter the item type bought (e.g. bread, eggs, etc.).
Ask the user to enter the no.of items bought.
If item type entered is “0” print the price of eggs ( no.of items *300 )
If item type entered is “1” print the price of eggs. ( no.of items*300 )
If item type entered is “2” print the price of eggs. ( no.of items *300 )
If item type entered is “3” print the price of eggs. ( no.of items *300 )
If none of the above-mentioned item type are chosen, print Invalid input.
End.
FLOWCHART:
INPUT:
OUTPUT:
TASK 3:
Design an algorithm and write a program that takes three nonzero
integers as input and determines and prints whether they’re the
sides of a right triangle.
Pseudo Code :
Start.
Enter the first non-zero integer.
econd non-zero integer.
Enter the third non-zero integer .
If (a**2==b**2+c**2) OR (b**2==c**2+a**2) OR (c**2==a**2 +
b**2) :
print ("These are the sides of a right triangle").
Otherwise, print ("these are not the sides of a right triangle").
End.
FLOWCHART 3:
INPUT:
OUTPUT:
TASK 4:
Draw flowchart and write a program that inputs temperature and
value of humidity from user and display related forecast.
Pseudo code :
Start.
Ask the user to enter the value of Temperature(x).
Ask the user to enter the value of Humidity(y).
If x>35 and(y>=50 and y<=60):
CONCLUSION:
In conclusion, the lab on making conditional statements provided a clear
introduction to essential programming concepts. Key points include: