Python 2 Icw

.docx

School

San Jose State University *

*We aren’t endorsed by this school

Course

110A

Subject

Computer Science

Date

Feb 20, 2024

Type

docx

Pages

2

Uploaded by ChiefReindeerPerson763

Report
ICW: Programming Selection Complete the following exercises by: 1. Try each one by yourself, adding your answers directly to this document. For questions requiring code, you may provide pseudocode or executable code written in Google Colab. 2. Discussing the questions with your team and agreeing on the best answer and editing your answer as needed. 3. Submit your own completed assignment to its Canvas submission folder. 1. The following is the pseudocode for an if-statement. Identify the logical error . Assume that each tax bracket is needed. (Great test question, btw) if income <=10000: tax = .05 elif income <=20000: tax = .10 elif income >=50000: tax = .15 else: tax = .20 . 2. From the Python Crash Course Book. Complete the following by either typing in pseudocode or using Colab and then copying your code or screen shot it and paste it in below. Write the selection statement to choose a color for a video game alien: • If the alien’s color is green, print a statement that the player just earned 5 points for shooting the alien. • If the alien’s color isn’t green, print a statement that the player just earned 10 points. Answer: the logical error is in line 5, the income messes up the ranging. It should be smaller than 50000. colors = input ( "Color;" ) if colors == "green" :   print ( "The player just earned 5 points for shooting the alien" )
3. Complete the following by either typing in pseudocode or using Colab and then copying your code or screen shot it and pasting it in below. UserInput = 1 Then write the selection statement needed to accomplish the following: If UserInput equals 1 then print “You will now be directed to the product page” If UserInput equals 2 then print “You will now be directed to the customer page” If UserInput equals 3 then print “You will now be directed to the registration page” If any other value is entered, print “Please select 1, 2, or 3”. 4. Think of a decision you made recently that required you to evaluate multiple options and then write a selection statement reflecting your decision process. This selection statement must include at least one elif. Pseudocode or actual code are fine. When you’ve completed it ask at least one teammate to check it for you for logic mistakes. I decided to purchase a Stanley cup from Amazon. There are four options of size with four different prices. Here is the code so that I can see the sizes and prices. user_input = int ( input ()) if user_input == 1 :   print ( "You will now be directed to the product page" ) elif user_input == 2 :   print ( "You will now be directed to the customer page" ) elif user_input == 3 :   print ( "You will now be directed to the registration page" ) else :   print ( "Please select 1, 2, or 3" ) product_size = str ( input ( "There are four sizes: 18oz, 24oz, 32oz, 64oz? " )) if product_size == '18' :   print ( "Price: $20" ) elif product_size == '24' :   print ( "Price: $30" ) elif product_size == '32' :   print ( "Price: $40" ) elif product_size == '64' :   print ( "Price: $50" ) else :   print ( "Sorry! We do not carry this size. " )
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help