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>