Question: { cells: [ { cell _ type: markdown, id : 7 2 a 5 ddfa, metadata: { id :

{
"cells": [
{
"cell_type": "markdown",
"id": "72a5ddfa",
"metadata": {
"id": "72a5ddfa"
},
"source": [
"# Guided Practice Conditional Statements"
]
},
{
"cell_type": "markdown",
"source": [
"### Try each of the Codes by pressing the Play button. You can modify the code and run again to see the outputs. Activities that need to be completed by the student are numbered.
",
"### Answer the questions and download your completed activity with full outputs as a .ipynb and a .pdf file. Use the Print option in the web browser to download the .pdf file. In your Chrome browser, press CTRL+P and select Set the Destination to \"Save as PDF\" or \"Print to PDF\" or the apropriate selection based on your computer. Save the file and submit your .pdf file and .ipynb in Canvas. A video on this process can be viewed using this [link](https://ecpi.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=2c60ba53-b182-4dd2-ba40-b12901260d39) or by running the code block below this. Thanks!"
],
"metadata": {
"id": "3AieqSoCPSvn"
},
"id": "3AieqSoCPSvn"
},
{
"cell_type": "code",
"source": [
"# Download Colab Notebook as .pdf and .ipynb Instructions
",
"
",
"from IPython.display import HTML
",
"
",
"HTML(\"\"\"
",
"
",
"\"\"\")"
],
"metadata": {
"id": "dTJXQoArH6Cp"
},
"execution_count": null,
"outputs": [],
"id": "dTJXQoArH6Cp"
},
{
"cell_type": "markdown",
"id": "0e20c8db",
"metadata": {
"id": "0e20c8db"
},
"source": [
"# Activity 2.1
",
"## Modify the program below to demonstrate the following:
",
"1. Calculate the total tax amount using a tax percentage of 40% if the gross pay is greater than 7500 and 20% if it is less than or equal to 7500.
",
"2. Use the calculated tax amount in dollars to subtract from gross pay and display the net pay"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "51f91cda",
"metadata": {
"id": "51f91cda"
},
"outputs": [],
"source": [
"# Activity 2.1
",
"#Variables to represent the base hours and
",
"# the overtime multiplier.
",
"base_hours =40 # Base hours per week
",
"ot_multiplier =1.5 # Overtime multiplier
",
"
",
"# Get the hours worked and the hourly pay rate.
",
"hours = float(input('Enter the number of hours worked: '))
",
"pay_rate = float(input('Enter the hourly pay rate: '))
",
"
",
"# Calculate and display the gross pay.
",
"if hours > base_hours:
",
" # Calculate the gross pay with overtime.
",
" # First, get the number of overtime hours worked.
",
" overtime_hours = hours - base_hours
",
"
",
" # Calculate the amount of overtime pay.
",
" overtime_pay = overtime_hours * pay_rate * ot_multiplier
",
"
",
" # Calculate the gross pay.
",
" gross_pay = base_hours * pay_rate + overtime_pay
",
"else:
",
" # Calculate the gross pay without overtime.
",
" gross_pay = hours * pay_rate
",
"
",
"# Display the gross pay.
",
"print('The gross pay is $', format(gross_pay, ',.2f'), sep='')
",
"
",
"#Calculate tax
",
"
",
"
"
]
},
{
"cell_type": "markdown",
"id": "c3b7a58e",
"metadata": {
"id": "c3b7a58e"
},
"source": [
"# Activity 2.2
",
"##Modify the program below to demonstrate the following:
",
"1. Ask the user for their credit_score.
",
">For the user to be qualified for the loan they must have:
",
">1. Minimum credit score of 600
",
">2. A minimum salary greater than min_salary (line 5)
",
">3. A minimum credit age of min_years (line 6)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7f8590cd",
"metadata": {
"id": "7f8590cd"
},
"outputs": [],
"source": [
"# Activity 2.2
",
"#This program determines whether a bank customer
",
"# qualifies for a loan.
",
"
",
"MIN_SALARY =3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!