Week 1 Deliverables Solution

$30.00 $24.00

Overview: In this week, you have set-up your Python Environment. The Lab for this week demonstrates your first use of this environment with a fairly simple Python application. You should also begin to use the PEP Python Style guide mentioned in the book and found here: https://www.python.org/dev/peps/pep-0008/ Some examples of Python Coding Style best practices…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

Overview: In this week, you have set-up your Python Environment. The Lab for this week demonstrates your first use of this environment with a fairly simple Python application.

You should also begin to use the PEP Python Style guide mentioned in the book and found here:

https://www.python.org/dev/peps/pep-0008/

Some examples of Python Coding Style best practices include:

Limit all lines to a maximum of 79 characters.

Imports are always put at the top of the file, just after any module comments and before module

globals and constants.

Use 4 spaces for indentation.

Submission requirements include 3 files. (Zipping them into one file is acceptable):

Python MinMax Application Code Python Calculator Application Code

Word of PDF file containing your test results

Python Applications for Lab1: (total 100 points):

This lab consists of two parts. The first exercise calculates the minimum and maximum of 5 numbers input by a user. The second exercise produces a simple Python calculator where a user selects the math operator and then enters two values as input for the operator selected.

  1. Using Python environment write a program that takes 5 input values from a user and prints the minimum and maximum value. Be sure to prompt the user for each of the 5 input values. The following is a possible application interface. Other application interfaces are possible as well. (40 points)

************************************************************************************

Welcome to the Python MinMax Application!

This application calculates the minimum and maximum of 5 integer values entered by a user.

Enter your first integer:

4

Enter your second integer:

7

Enter your third integer:

2

Enter your fourth integer:

1

12

Enter your fifth integer:

1

The minimum integer entered was 1.

The maximum integer entered was 12.

Thanks for trying the Python MinMax application.

*************************************************************************************

Hints:

  1. Use int() to cast the string entered by the user to an integer

  1. Use min() and max() to calculate the minimum and maximum values

  1. Test with many combinations. For example, what happens if you enter a non-number?

  1. Use comments to document your code

Note: without any exception handling, you should see issues/errors when testing your program.

  1. Using your programming environment write a Python calculator application that prompts a user to calculate the sum, difference, modulus, product or quotient of two input integers. Since we can’t loop yet, the application should run once and then exit. The application should prompt the user to select the mathematical operator, display what was selected and then prompt the user to enter the two integers.

If the user enters a 0 for the second number when the division operator is selected, the application should warn that divide by zero is not allowed and exit.

The following is a possible application interface. Other application interfaces are possible as well. (40 points)

Welcome to the Python Calculator Application.

What calculation do you want to perform?

  1. Addition (+)

  1. Subtraction (-)

  1. Division (/)

  1. Multiplication (*)

  1. Modulus (%)

Enter 1,2,3,4 or 5 indicating your selection.

2

Subtraction was selected.

2

Enter your first integer:

12

Enter your second integer

3

The difference of 12 and 3 is 9.

Thanks for trying the Python calculator

***************************************************************************

Hints:

    1. Use int() to cast the string entered by the user to an integer

    1. Use the mathematical operators, if statements and comparison operators as needed

    1. Test with many combinations. For example, what happens if you enter a non-number?

    1. Use comments to document your code

  1. Document your test results for each application within your programming environment. The test document should include a test table that includes the input values, the expected results and the actual results. A screen capture should be included that shows the actual test results of running the test case. Be sure to include multiple test cases to provide full coverage for all code. For example, if you have you should demonstrate each mathematical operator selected works as expected and every statement in the code is reached through the test cases. (20 points)

A possible test table may look like this:

Test

Input

Expected Output

Actual Output

Pass?

Case

1a

1,2,3,4,5

Minimum = 1,

Minimum = 1,

Yes

Maximum =5

Maximum =5

1b

2,10,1,11,11

Minimum = 1,

Minimum = 1,

Yes

Maximum =11

Maximum =11

1c

3,g,e,s,7

Error

Error

Yes but note in

future this needs to

be addressed.

Screen capture of test cases:

3

Figure 1. Test Case 1a Execution results

Figure 2. Test Case 1b Execution results

Figure 3. Test Case 1c Execution results

Any submissions that do not represent work originating from the student will be submitted to the Dean’s office and evaluated for possible academic integrity violations and sanctions.

4

Week 1 Deliverables Solution
$30.00 $24.00