You are on page 1of 3

Problem 1: Take three values and find the largest number.

Answer:

Python if...else Statement

Python Input, Output and Import

# program to find the largest number among the three input numbers

#to get value from user

num1 = float(input("Enter first number: "))

num2 = float(input("Enter second number: "))

num3 = float(input("Enter third number: "))

#pre_defined initialization.

#num1 = 11111.

#num2 = 181.

#num3 = 121.

if (num1 >= num2) and (num1 >= num3):

largest = num1

elif (num2 >= num1) and (num2 >= num3):

largest = num2
else:

largest = num3

print("among these three numbers ",num1," ","",num2," ",num3," ","this is the


largest number",largest)

Problem 2: Take hourly rate and no. of hours worked to calculate salary.
Answer:
#This program will calculate salary by getting no of hours and the rate per hour.
#Rate is predefined.
Rate_per_hour=200
Number_of_hours=float(input("Enter working hours"))
Salary=0.0
salary=Rate_per_hour*Number_of_hours
print("Wages according to your working hours in rupees",salary)

Problem 3: List all even numbers from 1-100.


Answer: def is_even_num(l):
enum = []
for n in l:
if n % 2 == 0:
enum.append(n)
return enum
print(is_even_num([1, 2, 3, 4, 5, 6, 7, 8, 9]))

Problem 4: Get marks from user and assign grade as per below chart
Marks Grade
80plus A
70_79 B+
60_69 B
50_59 C
Below F
5o
Answer:

Problem 5: List CNG stations which are within 5 km radius of NUST.


Answer:

Problem 6: List oil wells which are inside the boundary of Punjab
province and operating company is OGDCL.
Answer:

You might also like