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
In excel what does sidney need to consider when creating formulas
Musya8 [376]
The biggest thing she need to consider are her variables. and the output she will get.
5 0
3 years ago
Display all the natural numbers from 1 to 100 that are exactly divisible by 3 and 7 using FOR … NEXT. Without using Mod
Tcecarenko [31]

Answer:

FOR i% = 1 TO 100

 IF ((i%\3) = i%/3) AND ((i%\7) = i%/7)  THEN

   PRINT i%

 END IF

NEXT i%

Explanation:

Of course using MOD would be cleaner, but another way to check if a number is integer divisable is to compare the outcome of an integer division to the outcome of a floating-point division. If they are equal, the division is an integer division.

The program outputs:

21

42

63

84

6 0
3 years ago
What term identifies the physical interface between a computer and its peripherals?
antoniya [11.8K]
(B. Hardware), Hardware is physical components, Software are the programs in the computer.
3 0
3 years ago
What is the next line?
marissa [1.9K]

Explanation:

solução de ácido clorídrico (HCI 6 m e HCI 0,6 m)

7 0
3 years ago
What do TCP/IP MEAN​
melomori [17]

Answer:IP is internet protocol, every router has one some routers are dynamic which means they change everything the router reboots and some routers are static which means you would have to call your isp(Internet Service Provider) to get it changed.

Explanation: I do illegal things :)

8 0
3 years ago
Other questions:
  • What are three new things in Microsoft Word 2016?
    5·1 answer
  • The process of searching for a special pattern of symbols within a larger collection of information is called pattern ____.
    12·1 answer
  • Commercial applications are never free<br><br> -True<br><br> -False
    9·1 answer
  • To close the ____ view, click File on the Ribbon or click the preview of the document in the Info gallery to return to the docum
    9·1 answer
  • What development in operating systems happened between the years 1990 and 2000?
    15·1 answer
  • Public class Student {
    14·1 answer
  • Ashton assigned a string value to a variable. Which program statement should he use?
    5·1 answer
  • What's your fav show?
    12·2 answers
  • Which of the following best describes a hotspot as
    10·1 answer
  • a printer's accessory list includes a maintenance kit with a variety of replaceable parts you should install after 100,000 pages
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!