Question: PYTHON 2. Write the pseudo-code for a nested if-then statement (elif or else, depending on the language you are used to) that determines the appropriate

PYTHON

2. Write the pseudo-code for a nested if-then statement (elif or else, depending on the language you are used to) that determines the appropriate weekly commission payment based on the sales and commission rates below. Assume that the employee gets the earned commission rate on all of his or her sales (i.e. the employee would earn 20% commission on all $2000 of sales)

Sales under $200 = 2% commission rate

$200 - $499 = 5% commission rate

$500-799 = 10% commission rate

$800 - 1999 = 15% commission rate

Sales greater than $2000 = 20% commission rate

3. Redo question 2 using separate if statements (i.e. not using elif or else)

4. What is unnecessary in the following code? (Great test question, btw)

if income < 20K:

tax = .05

elif income >=20K and <50K:

tax = .10

elif income >=50K:

tax = .15

5. What is wrong with the following code? (Great test question, btw)

if income < 20K:

tax = .05

elif income >=20K:

tax = .10

elif income >=50K:

tax = .15

End if

6. From Python Crash Course exercise 5-3.

Alien Colors #1: Imagine an alien was just shot down in a game. Create a variable called alien_color and assign it a value of 'green', 'yellow', or 'red'.

Write an if statement to test whether the aliens color is green. If it is, print a message that the player just earned 5 points.

Write one version of this program that passes the if test and another that fails. (The version that fails will have no output.)

7. From Python Crash Course exercise 5-4.

Alien Colors #2: Choose a color for an alien as you did in Exercise 5-3, and write an if-else chain.

If the aliens color is green, print a statement that the player just earned 5 points for shooting the alien.

If the aliens color isnt green, print a statement that the player just earned 10 points.

Write one version of this program that runs the if block and another that runs the else block.

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!