Requirements
You are required to start with your Lab 5 program – you should have a passing grade (>= 70%) on Lab 5 before starting this assignment other wise you may be building additional functionality on a faulty foundation.
- Make a copy of Lab5.py and name it Lab6.py. Do not edit Lab5.py – you may need to go back and start over, so always start with a copy! Watch the Getting Started with PyCharm tutorial on how to make a copy of your project.
- You must use this valid.py page for all validations in this (and future) labs. The module has functions to prompt for, validate and return:
- Integers
- Real (floats, numbers with decimal values)
- Strings
- Y or N
- Do not edit this page, the code is correct and does not require any changes
- All input function should use the functions in the valid.py module. Use a while loop to perform additional validation in your existing functions. For example, if you are asking the user for their age, get_integer() will return a valid integer, but you may need to loop and continue to call get_integer() until they enter a positive integer between 0 and 120.
- Any new inputs, calculations, or outputs must be written as functions.
- All variables must be declared inside of your functions, global variables are not allowed.
- Declare result variables in functions. Do not return an equation. Assign the result variable(s) the equation result, the return the result variable(s).
- You must use arguments and parameters to share variables between functions.
- Your constants may be declared outside of main().
- Use proper function comments, follow the guidelines in the Python Style Guide.
- You are required to complete a test plan for your program. Think of all the invalid input that could cause your program to crash or behave incorrectly. If you are asking for the user’s age, you will want to handle:
- Text input: cat, twenty-three
- Input with decimals: 3.45
- Unreasonable input: less than 0 or greater than 120
- Download the Test Plan Template, rename the file Lab 6 Test Plan.doc. Learn how to complete your test plan by watching this video and looking at this Sample Test Plan.
- Submit Lab 6 Test Plan.doc containing your Test plan. Do not submit a link to a Google doc.
Criteria for Success
Your lab submission should consist of a single file named Lab5.py file, (the Python source code file) uploaded to the Lab 5 assignment folder in D2L. Check off each item on the list below before you submit your program:
- Look at the CIS 122 Lab Rubric criteria 1 – 6, before submitting your code. You may see a score of 1 if you do not meet one or more criteria. A score of 1 does not reflect the time or effort spent on this lab, instead, it is an indicator that you have been given feedback and need to make changes before it can be graded. There is no penalty for resubmitting your labs – please refer to the syllabus for more information on late policies.
- A comment header including program name, your name, date, brief description, input (what are you asking the user to enter), output (what will the program display), and 80 character ** delimiter line. Please follow the Python Style Guide rules for formatting your program.
- Start your program with a sample run as comments. What will the user see when they run your program? You can use the same sample run if you are not changing the happy path (the output when the user enters only valid input). The output of invalid input will be documented in the test plan..
- This IS a sample run, user input is shown in blue:Enter your name: MarcusEnter your age: 22Hello Marcus! You were born in 2000!
- This is NOT a sample run, do not use placeholders for real input data:Enter your name: [user enters name]Enter your age: [user enters age]Hello [name entered]! You were born in [year]!
- Add a comment section inside each function. There are two blank lines between each function definition. Please follow the Python Style Guide rules for formatting a function comment.
- Are all variables declared at the top of your program and use camelCase or snake_case and start with a lowercase letter?
- Did you initialize every variable to a default value?
- Did you create constants instead of using “magic numbers” in your code?
- Are your constants all UPPER_CASE letters? For example:TAX_RATE = .0775cost = 0.0final_cost = 0.0cost = float(input(“Enter item cost $ “))final_cost = cost + cost * TAX_RATE
- If you are using money, did you format all money output to 2 decimal places?
- You have a main() function that calls your other functions and “reads like a story”.
- Each input has its own function which returns only validated input. An error message is printed for the user for invalid input and the user is prompted again. Input functions must return valid input.
- Your program asks for text input, you must validate for empty string input.
- Each calculation has its own function.
- Each output has its own function.
- Declare result variables in functions. Do not return an equation. Assign the result variable(s) the equation result, the return the result variable(s).
- You do not have duplicated functions.
- Did you create test cases for all valid and invalid input? Test your code with your test plan before you submit it.