This Individual lab should be done by every student. You can ask the TA, Dr. Keen, or other students in the class for help. If you get help from a student please cite that in your header comment.
Due date: by end of lab on Monday, January 22, 2018
Educational goals of this lab - verify that every student can
Submit your files with this link. Use the Lab 1 menu choice. The grocer.py file is submitted as Code; the text file is submitted as Other.
Preparations: Please do these BEFORE Lab session starts.
IF YOU NEED HELP see tutorials on Python using IDLE or using Wing IDE 101 here (IDLE) or here (WingIDE). (Also available as video Entering and running a Python program)
Saving Files: On your computer you can save a file where you wish, but it is a good idea to make at least one folder for your CS 115 work, to make it easy to find. Or you can save a file on a memory stick or a Cloud storage account (like Dropbox) or email it to yourself.
# Prolog # Author: YOUR NAME # Email: YOUR EMAIL @uky.edu # Section: YOUR SECTION # Date: 1/22/18 ''' Purpose: to find the total cost of some apples and some oranges, given the quantity of each and a sales tax rate of 6%. Assumptions: apples cost $2.50, oranges cost $2, and sales tax is 6% Preconditions: (input) User supplies the number of apples and the number of oranges Postconditions: (outputs) User greeted and prompted for number of apples and oranges The total bill for the fruit is displayed and a goodbye message displayed ''' def main(): # 1. Greet the user print("Welcome to Green Grocer!\n") # 2. Get number of apples (integer) apples = int(input("How many apples: ") # 3. Get number of oranges (integer) oranges = int(input("How many oranges: ")) # 4. Set up sales tax rate sales_tax = 0.5 # sales tax rate # 5. Calculate total bill assuming $2.50 per apple # and $2 per orange bill = (2.5 * apples + 2 * oranges) * (1 + sales_tax) print() # 6. Display total and say goodbye print("The total bill is", bill) print("Thank you for shopping with us!") main() # end of program file
Here are two test cases for the program (IF it were correct).
Your program MUST produce the output of both of these cases correctly.
When you have the program running correctly, make sure your
TA or the lecturer in the class sees that you can run them.
Test Case 1:
Welcome to Green Grocer! How many apples: 10 How many oranges: 20 The total bill is 68.9 Thank you for shopping with us!
Welcome to Green Grocer! How many apples: 2 How many oranges: 0 The total bill is 5.300000000000001 Thank you for shopping with us!
Create a text file (either IDE's editor will create one, or you can use Notepad). You should put into the file (named errors.txt) a description of the two errors you found. Note that we want a TEXT file, not a PY file (it will have a .txt extension, not a .py extension). (Also not a .pages file, not a .doc or .docx file!) (10 points for the right format!)
Notice the personal information in the comments (#) at the top of the program. This is called the program prolog or header comment. You are required to provide a prolog like this for program assignments. Providing a prolog will be part of the grade for the program. Change this prolog to match your information. Make sure you cite anyone who helped you do the problem (name and email).
Why do we ask you to do this? A good part of this class involves writing Python programs, running them, testing them, fixing them. You need to start learning how you use the tools of the trade to do this. You will definitely run into many different errors when you are writing programs; every programmer does. You need to start gaining experience in what the error messages mean and how you can fix them.
IF YOU NEED HELP see tutorials on Python using IDLE or using Wing IDE 101
here (IDLE) or
(Also available as video Entering and running a Python program)
HINT: a very common mistake people make with IDLE is to skip the step where you tell the IDE that you want a NEW WINDOW. Go to the File menu, click on New Window, then you can paste the program code into that window.
HINT: In an IDE, do NOT paste your code into the window that says "Shell" at the top. That is NOT right! Your file should NOT have ">>>"'s all over it.
If you use a lab machine, log off properly - you don't want your account misused by someone else!
Remember NOT to leave files on the local hard drives on University machines! Make sure you save your projects onto a portable storage device you take with you or mail it to yourself or use a Cloud drive like Dropbox!