0% found this document useful (0 votes)
33 views6 pages

Lab 4

The document contains 3 tasks related to Python programming: 1. The first task involves correcting errors in sample Python code snippets and printing the outputs. 2. The second task asks the reader to determine the outputs of additional Python code snippets without errors. 3. The third task instructs the reader to write Python programs to evaluate if a number is even or odd, calculate salary based on years of service and qualifications, and determine a person's stage of life based on age.

Uploaded by

Saboor Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views6 pages

Lab 4

The document contains 3 tasks related to Python programming: 1. The first task involves correcting errors in sample Python code snippets and printing the outputs. 2. The second task asks the reader to determine the outputs of additional Python code snippets without errors. 3. The third task instructs the reader to write Python programs to evaluate if a number is even or odd, calculate salary based on years of service and qualifications, and determine a person's stage of life based on age.

Uploaded by

Saboor Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Lab#4

Task 1:
Objective: Point out the errors, if any, and paste the output also in the
following Python programs.
 a = 500,b,c;
if ( a >= 400 ):
b = 300
c = 200
print( "Value is:", b, c )
Correction:

--------------------------------------------
 &number = eval(input("Enter an integer: "))
print(type(number))
if number % 5 == 0
print("HiFive")
else
print("No answer")
correction:
---------------------------------------------------------------------------------------
 if score >= 60.0
grade = 'D'
elif score >= 70.0
grade = 'C'
elif score >= 80.0
grade = 'B'
elif score >= 90.0
grade = 'A'
else:
grade = 'F'

correction:
Task 2:
Objective: What would be the output of the following programs:

 requested_topping = 'mushrooms'
if requested_topping != 'anchovies':
print("Hold the anchovies!")

Output:

----------------------------------------------------------------------------------------
 num = 3
if num >= 0:
print("Positive or Zero")
else:
print("Negative number")
Output:
 age = 15
if age < 4:
price = 0
elif age < 18:
price = 1500
else:
price = 2000
print("Your admission cost is Rs" + str(price) +
".")
Output:

------------------------------------------
Task 3:
Objective: Write Python programs for the following.
 Any integer is input through the keyboard. Write a program
to find out whether it is an odd number or even number.
---------------------------------------
 Write a program that asks for years of service and qualification
from the user and calculates the salary as per the following table:
Years of Qualifications Salary
Service
>= 10 Masters 150,000
>= 10 Bachelors 100,000
< 10 Masters 100,000
< 10 Bachelors 70,000

Output:

-------------------------------------------------------------------------
 Write an if-elif-else chain that determines a person’s stage of life, take input value for the
variable age, and then apply these conditions:

• If the person is less than 2 years old, print a message that the person is a baby.
• If the person is at least 2 years old but less than 4, print a message that the person is a toddler.
• If the person is at least 4 years old but less than 13, print a message that the person is a kid.
• If the person is at least 13 years old but less than 20, print a message that the person is a
teenager.
• If the person is at least 20 years old but less than 65, print a message that the person is an adult.
• If the person is age 65 or older, print a message that the person is an elder.

You might also like