CSC121 Lab02

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

_______________________________________________________________________

CSC121 PYTHON PROGRAMMING


_______________________________________________________________________

LAB 02 WRITING SIMPLE PYTHON PORGRAMS

OBJECTIVES

In this lab assignment, students will learn:


- How to write Python statements to get input from keyboard
- How to write Python statements to convert data type
- How to write Python statements to perform calculations
- How to write Python statements to display output

GOALS

In this lab assignment, students will demonstrate the abilities to:


- Write Python statements to get input from keyboard
- Write Python statements to convert data type
- Write Python statements to perform calculations
- Write Python statements to display output

INSTRUCTION AND PROBLEMS

Write a Python program for each of the problems in this lab. The following is an
example.

The power of an air conditioner is measured in British Thermal Units (BTU). The
higher the BTU, the more heat the air conditioner can bring away. When people
buy an air conditioner, they need to know how many BTU they need to keep the
room cool. Design a program to estimate how many BTU we need when we install
a window air conditioner in a room. This number is determined by the volume of
the room. The rule of thumb is that we need 3.5 BTU per cubic foot. The program
should ask the user to enter the length, width and height of the room. It should
calculate and display the number of BTU needed for the air conditioner.

Python program:

room_length = float(input('Enter room length: '))


room_width = float(input('Enter room width: '))
room_height = float(input('Enter room height: '))
______________________________________________________________________________________________________________________________________________________________________________________________________________________

CSC121 Lab 02 Page 2


______________________________________________________________________________________________________________________________________________________________________________________________________________________

room_volume = room_length * room_width * room_height


btu_needed = room_volume * 3.5
print('BTU needed for this room:', format(btu_needed,".2f"))

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

A hotdog stand sells hotdogs, potato chips and sodas. Hotdogs are $2.50 each. Potato
chips are $1.50 per bag. Sodas are $1.25 per cans. Design a program to do the
following. Ask the user to enter number of hotdogs, chips and sodas ordered by the
customer. The program will calculate and display the total amount due.

PROBLEM 2

Each student in a course needs to submit 3 lab assignments and take 2 tests. Design a
program to do the following. Ask the user to enter 3 lab scores and 2 test scores.
Calculate and display the lab average and the test average. Also calculate and display
the course grade, which equals 55% of the lab average plus 45% of the test average.

PROBLEM 3

Admission to an aquarium is $14 per person. There is also an IMAX theatre in the
building, which charges $8 per ticket for a 3D shark show. Customers have three
choices: admission to the aquarium only without watching 3D show, watch 3D show
only with no admission to the aquarium, or do both with a 25% discount. Design a
program for group orders. Ask the group to enter number of people who want
admission only but no 3D show, number of people who want 3D show only but no
admission to the aquarium, and number of people who want both. Calculate and
display the total amount due from the group.

PROBLEM 4

The jackpot of a lottery is paid in 20 annual installments. There is also a cash option,
which pays the winner 65% of the jackpot instantly. In either case 30% of the
winnings will be withheld for tax. Design a program to do the following. Ask the user to
enter the jackpot amount. Calculate and display how much money the winner will
receive annually before tax and after tax if annual installments is chosen. Also calculate
______________________________________________________________________________________________________________________________________________________________________________________________________________________

CSC121 Lab 02 Page 3


______________________________________________________________________________________________________________________________________________________________________________________________________________________

and display how much money the winner will receive instantly before and after tax if
cash option is chosen.

GRADING RUBRIC FOR EACH PROBLEM

Getting user input [5 points]


Performing calculations [15 points]
Displaying output [5 points]

You might also like