Nov 16, 2026 | 714 words | 7 min read
8.1.2. PCA: Data Types and Calculations#
Python is a powerful programming language for performing computations, scripting, and database management. As an engineering tool, it offers standard mathematical operations as part of its basic environment. Therefore, you can design standard computational models, process data, and generate reports. The language must work within the limits of the machine it is running on. As a result, there may be differences between what you compute by hand and what Python computes.
Before You Begin Python - Download the Software#
Use the Course Software page for detailed installation instructions and operating-system-specific guidance. Complete the following steps before you begin the following Python activities:
Install Python or verify that Python is already installed on your computer.
Install Visual Studio Code.
Install the official Python extension in Visual Studio Code.
Verify that Visual Studio Code is using the correct Python interpreter.
Required Files#
Download the Python Template. and save it as
8_1_2_username.py.
Reminder
Rename your files with your Purdue username by replacing “template” in the filename. Then fill out any required information in the template, such as your name, email, and course details.
Instructions#
Template Requirements#
Use the ENGR 131 Python template for this assignment.
Rename the Python file as specified above.
Update the template header:
Replace the
Descriptionplaceholder with a brief description of what the program does.Replace the
Assignmentplaceholder with the assignment information provided in the problem statement.Replace the
Authorplaceholder with your name and Purdue email.
Write all program code within the
main()function.
Reminder
Review and reference the Python Style Guide to create a professionally formatted code file. For example, remember to provide detailed comments throughout your code so anyone can read them and understand what your program does!
Program Requirements#
Ask the user to input a value between 1 and 10 and store the input in the variable
a.Ask the user to input a value between 3 and 8 and store the input in the variable
b.Convert both input values to
float.Import the
mathmodule in the import section of the template (above themain()function).Calculate and store each of the following in a separate variable:
Sum
Difference
Product
Quotient
Power, with the first number (
a) raised to the second (b)
Use the math module to calculate the square root of the absolute value of each input value.
Display the results as clearly labeled, multi-line output.
Format all numerical output to two decimal places.
Use the Sample Output section below to verify that your program produces the correct values.
Sample Output#
Use the values in Table 8.1 below to test your program.
Case |
Number 1 |
Number 2 |
|---|---|---|
1 |
2 |
6 |
2 |
8 |
7 |
Ensure your program’s output matches the provided samples exactly. This includes all characters, white space, and punctuation. In the samples, user input is highlighted like this for clarity, but your program should not highlight user input in this way.
Case 1 Sample Output
Case 2 Sample Output
Gradescope Submission#
Save Deliverables: Ensure all required assignment files are saved and named exactly as specified in the assignment instructions. If a template file name contains the word
template, replace only that word with your Purdue username. When a task lists more than one deliverable, such as a workbook and a report, submit each deliverable to its own matching Gradescope assignment instead of combining them into one upload.Navigate to Gradescope: Log in to Gradescope. From your Dashboard, open the assignment.
Upload your work: Select the Upload submission method. Drag and drop all required files (or a compressed
.zipfolder) into Gradescope, and select Upload.Confirm Submission: When your upload is successful, you will see a confirmation message on your screen and receive an automated email receipt.
Add Team Members (if applicable): If this is a team assignment, add all team members to the submission. Each teammate should confirm they can see the submission in their own Gradescope account. For help, visit Gradescope’s documentation on adding team members.
Review Autograder Results: Wait a few minutes for the autograder to evaluate the relevant files. Scroll down to view any failed test cases. If you need assistance interpreting the output or errors, ask your teaching team.
Resubmit if Necessary: You can edit your files and select Resubmit as many times as you need before the assignment deadline. Only your final, active submission is graded. (Note: If you need to resubmit, you must upload all required files for the assignment again).
For a detailed walkthrough, review the official Gradescope Submission Guide.