At Westonci.ca, we provide clear, reliable answers to all your questions. Join our vibrant community and get the solutions you need. Experience the convenience of finding accurate answers to your questions from knowledgeable professionals on our platform. Our platform provides a seamless experience for finding reliable answers from a network of experienced professionals.
Sagot :
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
if pkt == 0:
print("Green")
If pocket number is between 1 and 10 (inclusive)
elif pkt >= 1 and pkt <=10:
This prints black if packet number is even
if pkt%2 == 0:
print("Black")
Prints red, if otherwise
else:
print("Red")
If pocket number is between 11 and 18 (inclusive)
elif pkt >= 11 and pkt <=18:
This prints red if packet number is even
if pkt%2 == 0:
print("Red")
Prints black, if otherwise
else:
print("Black")
If pocket number is between 19 and 28 (inclusive)
elif pkt >= 19 and pkt <=28:
This prints black if packet number is even
if pkt%2 == 0:
print("Black")
Prints red, if otherwise
else:
print("Red")
If pocket number is between 29 and 36 (inclusive)
elif pkt >= 29 and pkt <=36:
This prints red if packet number is even
if pkt%2 == 0:
print("Red")
Prints black, if otherwise
else:
print("Black")
Prints error if input is out of range
else:
print("Error")
We appreciate your time on our site. Don't hesitate to return whenever you have more questions or need further clarification. Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. We're dedicated to helping you find the answers you need at Westonci.ca. Don't hesitate to return for more.