Lab Report 02
Lab Report 02
SUBMITTED TO:
SUBMITTED BY:
Muhammad Talha
DE- 45 Syn A Mechanical Engineering
REG NO # 481402
Hardware/Software required:
Hardware:
. Laptop
Software Tool:
. VS Code
• Write a python script that asks user to select one of the following operations and
performs the said operation on 2 inputs provided by user such that 0 for Addition, 1 for
Subtraction, 2 Multiplication and 3 for Division operations
Code:
elif (operation == 3): # If user chose to perform Division than this piece
of code will execute
else: # if all of the above entries are false then print Invalid entry
print("Invalid Entry ")
Outputs:
• Write a program that inputs temperature and value of humidity from user and display
related forecast.
Code:
if (temp > 35) and (humid >= 50) and (humid <= 60): # If temperature is
greater than 35 and humidity is between
# 50% and 60% print it is Hot day
elif (temp >= 25) and (temp <= 35) and (humid >= 50) and (humid <= 60): # If
temperature is between 25 and 35 and
# humidity is between 35% to 50% print It is Pleasant Day
elif (temp < 25) and (humid < 50): # If temperature less than 25 and
# humidity is less than 50% print it is Cool Day
print("It is Cool Day")
else: # if all of the above entries are false then print Invalid entry
print("Invalid entry")
Output
• Write a program that takes three nonzero integers as input and determines and prints
whether they’re the sides of a right triangle.
CODE:
# Ask three sides as input from user
else: # if sides are not of right triangle then print Entered sides are
not of Right Triangle
Output:
Write a program that keeps getting and adding the number until negative number is
entered
CODE:
Code:
total_sum = 0 # Initialize the variable total to store the sum
Outputs:
Code:
print("This program calculate interest and returns its value for each
year.") # Discription
# inputs
p = float(input("Enter initial investment: "))
count = 1
# loop
while count<=n:
a = p*(1+r)**count
count+=1 # increment
Output:
Code:
# Discription
length = len(num)
count=0
sum = 0
while count<length:
power= (int(num[count]))**length
count = count+1
if sum == int(num):
else:
Output:
Conclusion:
In this week’s tasks we learned about iterations, using while loops, which is a
strong computing tool in programming languages.