1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sauron [17]
3 years ago
7

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 poc

kets 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.
Computers and Technology
1 answer:
Rama09 [41]3 years ago
6 0

Answer:

pkt = int(input("Pocket Number: "))

if pkt == 0:

   print("Green")

elif pkt >= 1 and pkt <=10:

   if pkt%2 == 0:

       print("Black")

   else:

       print("Red")

elif pkt >= 11 and pkt <=18:

   if pkt%2 == 0:

       print("Red")

   else:

       print("Black")

elif pkt >= 19 and pkt <=28:

   if pkt%2 == 0:

       print("Black")

   else:

       print("Red")

elif pkt >= 29 and pkt <=36:

   if pkt%2 == 0:

       print("Red")

   else:

       print("Black")

else:

   print("Error")

Explanation:

The program was written in Python and the line by line explanation is as follows;

This prompts user for pocket number

pkt = int(input("Pocket Number: "))

This prints green if the pocket number is 0

<em>if pkt == 0:</em>

<em>    print("Green")</em>

If pocket number is between 1 and 10 (inclusive)

elif pkt >= 1 and pkt <=10:

This prints black if packet number is even

<em>    if pkt%2 == 0:</em>

<em>        print("Black")</em>

Prints red, if otherwise

<em>    else:</em>

<em>        print("Red")</em>

If pocket number is between 11 and 18 (inclusive)

elif pkt >= 11 and pkt <=18:

This prints red if packet number is even

<em>    if pkt%2 == 0:</em>

<em>        print("Red")</em>

Prints black, if otherwise

<em>    else:</em>

<em>        print("Black")</em>

If pocket number is between 19 and 28 (inclusive)

elif pkt >= 19 and pkt <=28:

This prints black if packet number is even

<em>    if pkt%2 == 0:</em>

<em>        print("Black")</em>

Prints red, if otherwise

<em>    else:</em>

<em>        print("Red")</em>

If pocket number is between 29 and 36 (inclusive)

elif pkt >= 29 and pkt <=36:

This prints red if packet number is even

<em>    if pkt%2 == 0:</em>

<em>        print("Red")</em>

Prints black, if otherwise

<em>    else:</em>

<em>        print("Black")</em>

Prints error if input is out of range

<em>else:</em>

<em>    print("Error")</em>

You might be interested in
What authentication protocol is ticket-based and is used by windows computers that are members of an active directory domain?
Temka [501]
Your IP address, also known as Internet Protocol
7 0
3 years ago
When was the Ethics Resource Center (ERC) established? In the 1970s In the 1980s In the 1990s In the 2000s
baherus [9]

Answer:

1922

Explanation:

i looked it up When was the Ethics Resource Center (ERC) established?

4 0
3 years ago
A Python function cannot under normal circumstances reference a module variable for its value.
marishachu [46]
This is false because
6 0
3 years ago
Read 2 more answers
To save a file so that it can be opened on most computers, select the _____ option.
romanna [79]
Save it on the cloud.
6 0
3 years ago
Read 2 more answers
What is output if the user types 13 click all that apply ABCD
Klio2033 [76]

Answer:

AD?

Explanation:

3 0
3 years ago
Other questions:
  • Is anyone really good at immerse 2 learn??
    9·1 answer
  • Each entry in a linked list is called a_______
    11·1 answer
  • Which stage of the waterfall model is most like the simple model's stage 5?
    12·1 answer
  • Code embedded into an HTML page and downloaded by a user; resides on the client and helps process Web form input. Common clients
    9·1 answer
  • Have all of my coins because i will delete acount there will be part 2, 3 , 4 ,5,6,7,8
    15·2 answers
  • Do you think Mortal Combat is cool?
    10·2 answers
  • imagine that you wanted to write a program that asks the user to enter in 5 grade values. the user may or may not enter valid gr
    12·1 answer
  • How would you use keywords and Boolean operators to help you with a web search?
    13·1 answer
  • Copy the formula in cell M7 to the range M8:M15, and edit the copied formulas to return the value from the column indicated by t
    15·1 answer
  • How has 5G become more energy efficient?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!