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
How might your use of computers and knowledge of technology systems affect your personal and professional success?
RUDIKE [14]
It can help you more be aware of whats going on and what you need to do.
8 0
3 years ago
Why did the Apostles choose deacons to help them?
Lena [83]

Answer:

Idk

Explanation:

Ikd

7 0
2 years ago
Is it bad to leave external hard drive on for hours
alexandr402 [8]
Yes, because it can cause fires and electrical problems
8 0
3 years ago
Each cable type can transport data at a particular speed only so far before its signals begin to weaken past the point that a re
Nataliya [291]

Answer:

attenuation

Explanation:

Based on the information provided within the question it can be said that the phenomenon that is being described in this scenario is known as attenuation. In the context of physics, this refers to the gradual loss of intensity of something when traveling through a medium. Which in this case would be the data signals travelling through the cables.

7 0
3 years ago
Which example is the best demonstration of initiative?
alisha [4.7K]

Answer: In this context, the best answer for the given questions would be (B) you offer to take on some extra work when a coworker is out sick.

Explanation: Initiative is pretty much defined as an action that is taken independently by someone. It could be said that one person with an initiative does not need someone else to tell him/her to do something.

4 0
3 years ago
Other questions:
  • You need to put cabling for connecting two new computers in a room, which did not have any network infrastructure. Because of th
    9·2 answers
  • Nadia would like to find text in her current document that differentiates CompanyABC from companyabc. Which option should she us
    8·2 answers
  • ​some forms use a _____ that contains icons or buttons that represent shortcuts for executing common commands.
    14·1 answer
  • 15. The text of a desktop publishing document is often created using
    6·2 answers
  • How are a cell's content and format related?
    12·2 answers
  • What is the main characteristic of a Peer-to-Peer (P2P) network?
    8·1 answer
  • This form of analysis is an extension of what-if analysis and is the study of the impact on other variables when one variable is
    8·1 answer
  • Files with what two file extensions are commonly known as tarballs??
    8·1 answer
  • What dose a bios system do?
    5·2 answers
  • Write a program that grades arithmetic quizzes as follows: Ask the user how many questions are in the quiz. Ask the user to ente
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!