Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

NOTE: Is learning \"Python programming\" (currently on chapter 3) with the follo

ID: 3884036 • Letter: N

Question

NOTE: Is learning "Python programming" (currently on chapter 3) with the following textbook:

Book "Starting Out With Python" 3rd Edition by Gaddis

1. On a roulette wheel, the pockets are numbered from 0 to 36. The colors of the pockets are as follows: » Pocket 0 is green. . For pockets 1 through 10, the odd-numbered pockets are red and the even- numbered pockets are black For pockets 11 through 18, the odd-numbered pockets are black and the even- numbered pockets are red. For pockets 19 through 28, the odd-numbered pockets are red and the even- numbered pockets are black. » For pockets 29 through 36, the odd-numbered pockets are black and the even- numbered pockets are red Write a program that asks the user to enter a pocket number and displays whether the pocket is green, red, or black. The program should display an error message if the user enters a number that is outside the range of 0 through 36. ~/workspace/HW/ $ python number01.py Enter a pocket number: 54 That is not a valid pocket number /workspace/HW/ python number01.py Enter a pocket number: 28 Pocket 28 is black /workspace/HW/ python number01.py Enter a pocket number: 31 Pocket 31 is black

Explanation / Answer

print("Enter a file name:");

pocket = int(input());

if pocket == 0:

    print("Pocket %d is green."%pocket);

elif pocket>0 and pocket <=10:

      if pocket%2==0:

          print("Pocket %d is black."%pocket);

      else :

          print("Pocket %d is red."%pocket);

elif pocket >10 and pocket <=18:

      if pocket%2==0:

          print("Pocket %d is red."%pocket);

      else :

        print("Pocket %d is black."%pocket);

elif pocket >18 and pocket <=28:

      if pocket%2==0:

        print("Pocket %d is black."%pocket);

      else :

        print("Pocket %d is red."%pocket);

elif pocket >28 and pocket <=36:

      if pocket%2==0:

        print("Pocket %d is red."%pocket);

      else :

        print("Pocket %d is black."%pocket);

else :

print("That is not a valid pocket number");