The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
(Due tonight by 11:59pm!)  I need help completing this worksheet packet. I need to know the answers for exercises #1-5. PLEASE, can somebody help me with this?! It is due tonight by 11:59pm!
Â
CIS115_Lab04.docx
_______________________________________________________________________
CIS115
INTRODUCTION TO PROGRAMMING AND LOGIC
_______________________________________________________________________
LAB 04 DECISION STRUCTURES [PART 1] OBJECTIVES
In this lab assignment, students will learn:
- How to use the if statement
- How to use the if-else statement
- How to compare strings
- How to use logical operators
GOALS
In this lab assignment, students will demonstrate the abilities to:
- Use the if statement
- Use the if-else statement
- Compare strings
- Use logical operators
INSTRUCTION AND PROBLEMS Write a Python program for each of the problems in this lab. The following is
an example.
A bank requires customers to have a minimum salary of $30,000 and at
least 2 years on the job to qualify for a loan. Write a program to check
whether a customer qualifies.
Python program:
__author__ = 'Man-Chi Leung'
#This program determines whether a customer qualifies for a
loan
min_salary = 30000.0
min_years = 2 ______________________________________________________________________________________________________________________________________________________________________________________________________________________ CIS115 Lab 04 Page 2 ______________________________________________________________________________________________________________________________________________________________________________________________________________________ salary = float(input('Enter your annual salary: '))
years_on_job = float(input('Enter the number of years employed: '))
if salary >= min_salary and years_on_job >= min_years:
print('You qualify for the loan')
else:
print('You do not qualify for this loan')
Please use PyCharm to type and test your programs. Submit the Python files
to Blackboard for credit. In this lab, you should submit 4 Python files, one for
each problem.
PROBLEM 1
There are two exams in a programming course. Write a program to calculate
a student’s total score. To encourage students to do better in the final exam,
if a student has improved by more than 20 points from midterm to final, the
student will receive 5 bonus points in the total. Write a Python program to
do the following. Calculate and display total score before bonus. If a student
receives extra points, display a text message about improvement bonus and
new total score. The following are two examples.
Enter midterm score: 80
Enter final score: 85
Total Score: 165
Enter midterm score: 70
Enter final score: 95
Total Score: 165
5 bonus points added to total for meeting improvement target.
New total score: 170
Save the correct program in a file named Lab04P1.py. Submit the file to
Blackboard for credit.
PROBLEM 2
A town uses a two-tier system to calculate bill for water usage. For the first
8000 gallons, it is $0.004 per gallon. After the first 8000 gallons, the rate will
be $0.007 per gallon. Suppose a customer uses 8500 gallons of water. He
will pay $0.004 per gallon for the first 8000 gallons, and $0.007 per gallon
for the last 500 gallons. Write a Python program to determine how much a
customer needs to pay. Ask the user how much water he has used.
Calculate and display the water bill. The following are two examples. ______________________________________________________________________________________________________________________________________________________________________________________________________________________ CIS115 Lab 04 Page 3 ______________________________________________________________________________________________________________________________________________________________________________________________________________________ Enter gallons of water used: 2100
Please pay this amount: $8.4
Enter gallons of water used: 8500
Please pay this amount: $35.5
Save your Python program in a file named Lab04P2.py. Submit the file to
Blackboard for credit.
PROBLEM 3
We saw a program about determining the number of BTU needed to cool a
room before. The program asks the user to enter the room’s length, width
and height, and uses the following formula to calculate the number of BTU
needed:
BTU needed = room volume * 3.5
Now we want to add one more consideration. If the room gets a lot of
sunlight, number of BTU needed will increase by 20%. The program needs
to ask the user whether the room gets a lot of sunlight. The user answers
‘yes’ or ‘no’. Adjust the number of BTU needed if necessary. The following
are two examples.
Enter room length: 15
Enter room width: 12
Enter room height: 10
Does the room get a lot of sunlight? [yes/no] no
BTU needed for the air conditioner: 6300
Enter room length: 15
Enter room width: 12
Enter room height: 10
Does the room get a lot of sunlight? [yes/no] yes
BTU needed for the air conditioner: 7560
Save your Python program in a file named Lab04P3.py. Submit the file to
Blackboard for credit.
PROBLEM 4
North Carolina state law requires all children to ride in a booster seat until
either the child has reached age 8 or has exceeded 70 pounds. Write a
program to determine whether a child needs to ride in a booster seat. Ask ______________________________________________________________________________________________________________________________________________________________________________________________________________________ CIS115 Lab 04 Page 4 ______________________________________________________________________________________________________________________________________________________________________________________________________________________ the age and weight of the child, then decide whether booster seat is
required. The following are two examples.
Enter age: 7
Enter weight: 60
This child must use a booster seat.
Enter age: 7
Enter weight: 75
This child does not need a booster seat.
Save your Python program in a file named Lab04P4.py. Submit the file to
Blackboard for credit.
GRADING RUBRIC FOR EACH PROBLEM Writing correct if/if-else statement [15 points]
Other statements [10 points]
-----------