Welcome to your first lab assignment
for CSCI 102 (week 00)! Each week, you
should work on the homework assignment (lab). This lab is to
be done on your own (not pair programming), and needs to be
completed and submitted to Canvas no later than the due
date. Unlike CSCI 101, we will place all assignments for a
given week on one HTML page. This is your Week 00 CSCI 102
Assignment page.
You have TWO problems to do this week, both of which you will
SUBMIT to Canvas. Details on Part A and Part B are below.
NOTE: skip to Step 2 if you are using Python on
a lab machine (i.e., NOT installing Python on a laptop).
Step 0: Download Python
Programming languages are how we communicate with our computers.
To ensure that your computer speaks Python (and therefore
understands the instructions you'll be giving it), you'll need
to download a Python
interpreter.
The interpreter we'll be using is for Python 3 (a slightly
different dialect from Python 2). Head over to
python.org and find the download button
for the latest Python 3 version for your computer's operating
system. Click it!
The button circled in green is
probably the one you want (verify that the number starts
with a 3,
and that the OS I've circled in red matches your computer's
OS).
Step 2: Try Out IDLE
One of the things your installer should have given you is a
program called IDLE.

IDLE is an
Integrated
Development
and
Learning
Environment. It
also happens to be the last name of
this dude from the British comedy group
(Monty Python) whose name inspired the name Python (
yes, I'm serious).
One of the most useful things to do in a program is to
get
output. In Python 3, we do this using the
print()
function:

Let's talk terminology for a minute:
print() is a
function which takes
input
(e.g.,
"Hello, world!" in our example), does things
(in this case, prints the input to the console), and returns
things.
The input to a function is called its
argument(s),
which go in the parentheses of a function
call.
The argument to the
print() function is the
string
"Hello, world!". Notice that a string is like a quote
in a paper – it starts and ends with quotation marks, and what
gets printed is
exactly what you type between those
quotes. Why call it a "string"? It's a bunch of letters,
strung
together in a particular order.
To run code in IDLE, you can just type it in after the
>>>
prompt. But you have to type every command in
every time. It can be very useful to save your commands in a
separate file, called a
script or sometimes
even a
program.
In IDLE, select File > New File (click the "File" menu and
find the "New File" option). In this new window, type
print("Hello,
world!") and then save the file as
Week0A_helloworld.py.
Then, with your script file selected, select Run > Run
Module. This will take you back to the first IDLE window and
show you the output of your program.
Comments
All Python files should include a header with your name,
section, assignment info, references (i.e., who did you collaborate
with on this assignment?; what resource did you use?), and approximate
time taken to do the assignment. Be sure to cite
any allowed external references used to complete the
assignment. Any code without this header will lose 1
point. Here's an example:
# Tracy Camp
# CSCI 102 – Section A
# Week 0 - Lab A - Hello World!
# References: Dr. Liebe, who helped me get Python installed
# Time: 35 minutes
Part B: Receipt Generator (5 points)
Introduction
To get started, open IDLE and create a New File via the File menu. We
suggest you immediately save this file in the CSCI102 directory managing all
your Python Labs this semester. Please save this file with the following name:
Week0B-receipt_generator.py.
Assignment
Most businesses use a sales receipt (i.e., a physical slip of paper
generated by a cash register or sent via email in online sales) to
keep record of all sales made each day. Customers also rely on receipts to
confirm their purchase amount and return (or exchange) items purchased in the future.
The purpose of this lab is to write a program that generates a receipt for three products purchased (and entered) by the user.
(In today's world, items purchased are typically scanned with a bar code scanner instead of being
typed by a human; prior to scanners though, items had to be typed!)
Your program should comply with the following algorithm.
- Ask the user for their company name, city/state, cashier name, and favorite thank-you message. Store the values entered as
variables.
- Ask the user to enter three product/items they would like to purchase (name followed by the price). Store
the values entered as variables with appropriate names. You may assume that the user will only enter a positive amount of dollars.
- Follow the format in the sample execution to print/display the receipt to the console.
- Calculate the total cost and round up to two decimal digits.
- HINT: You can use the round() function or an f-string format, i.e., f"{decimal_variable:.2}",
to display the number of digits after the decimal place. For additional practice, refer
to the problem 7-Python-CleopatraPyramid on Autograder.
Example Execution
Enter company name: The Real Mines Market
Enter company city/state: Golden, Colorado
Enter cashier name: Blaster
Purchased item 1 name: Tear Catcher
Purchased item 1 price: 12.99
Purchased item 2 name: Laminated NB
Purchased item 2 price: 4.97
Purchased item 3 name: Smart Cookie
Purchased item 3 price: 1.03
Enter your favorite ending message: Thank you! Go Orediggers!
Example Output
RECEIPT GENERATOR
===================================
The Real Mines Market
Golden, Colorado
***********************************
Your cashier was: Blaster
Welcome Valued Customer
***********************************
Item Name Item Price
Tear Catcher $12.99
Laminated NB $4.97
Smart Cookie $1.03
***********************************
Total Cost of Order: 18.99
***********************************
Thank you! Go Orediggers!
===================================
Comments
All Python files should include a header with your name,
section, assignment info, references (i.e., who did you collaborate
with on this assignment?; what resource did you use?), and approximate
time taken to do the assignment. Be sure to cite
any allowed external references used to complete the
assignment. Any code without this header will lose 1
point. Here's an example:
# Tracy Camp
# CSCI 102 – Section A
# Week 0 - Lab B - Receipt Generator
# References: Friend Billie Joe Armstrong, who helped me with how to print two decimal points
# Time: 25 minutes
Submit Solutions
Follow these steps
to submit your files to Canvas.
- In Canvas, go to Assignments > Week0A and
upload Week0A-helloworld.py.
- In Canvas, go to Assignments > Week0B and
upload Week0B-receipt_generator.py.
To receive full credit, your code must execute in
Python 3, and you must submit a single file for each
portion of the assignment (your Python code file).
In addition, your code must follow the Lab I/O
Format.
Whenever you submit something to Canvas, we
strongly recommend you always double check what
you submitted actually got submitted correctly
(e.g., did the file upload correctly? did you
submit the correct file? etc.) If your submission
is incorrect, it's on you.