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 pockets 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.

Answers

Answer 1
Answer:

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")


Related Questions

A cybersecurity analyst is currently investigating a server outage. The analyst has discovered the following value was entered for the username: 0xbfff601a. Which of the following attacks may be occurring?(A) Buffer overflow attack(B) Man-in-the-middle attack(C) Smurf attack(D) Format string attack(E) Denial of service attack
1. Do our shared social experiences lead us to thinkcommunication is a cure-all?
A web page that allows interaction from the user​
The sql standard prescribes three different types of __________ operations: left, right, and full.
Which method can help you prevent RSI while using a keyboard?Keep the left-hand’s fingers on J, K, L, and ; keys. Rest the left-hand’s fingers on A,S, D, and F keys. Rest the right-hand’s fingers on A,S, D, and F keys. Rest the right-hand’s fingers on Q,W, E, and R keys.

Provide your own examples of the following using Python lists. Create your own examples. Do not copy them from another source. Nested lists The “*” operator List slices The “+=” operator A list filter A list operation that is legal but does the "wrong" thing, not what the programmer expects Provide the Python code and output for your program and all your examples.

Answers

Lists are used in Python to hold multiple values in one variable

(a) Nested list

A nested list is simply a list of list; i.e. a list that contains another list.

It is also called a 2 dimensional list.

An example is:

nested_list = [[ 1, 2, 3, 4]  , [ 5, 6, 7]]

(b) The “*” operator

The "*" operator is used to calculate the product of numerical values.

An example is:

num1 = num2 * num3

List slices

This is used to get some parts of a list; it is done using the ":" sign

Take for instance, you want to get the elements from the 3rd to the 5th index of a list

An example is:

firstList = [1, 2 ,3, 4, 5, 6, 7]

secondList = firstList[2:5]

The “+=” operator

This is used to add and assign values to variables

An example is:

num1 = 5

num2 = 3

num2 += num1

A list filter

This is used to return some elements of a list based on certain condition called filter.

An example that prints the even elements of a list is:

firstList = [1, 2 ,3, 4, 5, 6, 7]

print(list(filter(lambda x: x % 2 == 0, firstList)))

A valid but wrong list operation

The following operation is to return a single list, but instead it returns as many lists as possible

def oneList(x, myList=[]):

   myList.append(x)

   print(myList)

oneList(3)

oneList(4)

Read more about Python listsat:

brainly.com/question/16397886

What is a decryption key?​

Answers

Answer:

A decryption key is a digital information used to recover the plain text from the corresponding ciphertext by decryption.

How will you ensure that all of the network's applications and tcp/ip services also support ipv6?

Answers

Answer:

Configure the Extended BSD API socket.

Explanation:

There are two types of logical network address, they are IP version 4 and up version 6. They are used to route packets to various destinations from various sources.

A network application must configure this IP addresses protocol. The IP version4 is the default address applications use. To enable IP version 6 the extended BSD API is configured on the network.

Choose a topic related to a career that interests you and think about how you would research that topic on the Internet. Set a timer for fifteen minutes. Ready, set, go! At the end of fifteen minutes, review the sources you have recorded in your list and think about the information you have found. How w

Answers

Answer:

Following are the solution to the given question:

Explanation:

The subject I select is Social Inclusion Management because I am most interested in this as I would only enhance my wide adaptability and also people's ability to know and how I can manage and understand people.

Under 15 min to this location. The time I went online but for this issue, I began collecting data on the workability to tap, such as a connection to the monster, glass doors, etc.

For example. At example. I get to learn through indeed.com that the HR manager's Avg compensation is about $80,600 a year. I can gather from Linkedin data about market openings for HR at tech companies like Hcl, Genpact, etc. Lenskart has an HR director open vacancy.

This from I learns that for qualified practitioners I have at least 3 years experience in the management of human resources & that I need various talents like organizing, communications, technical skills, etc.

Suppose two computers (A & B) are directly connected through Ethernet cable. A is sending data to B, Sketch the waveform produced by A when “$” is sent. Also mention the OSI layer that is responsible for this.

Answers

Answer:

Physical / Data link layer

Explanation:

If two computers (A & B) are directly connected through Ethernet cable. A is sending data to B, the data would be transmitted if the network is clear but if the network is not clear, the transmission would wait until the network is clear.

The Open Systems Interconnection model (OSI model) has seven layers each with its own function.

The physical layer is the first layer responsible for data transmission over a physical link. The data packets are converted to signals over a transmission media like ethernet cable.

The data link layer is the second layer in the OSI layer responsible for transmission of data packets between nodes in a network. It also provides a way of detecting errors and correcting this errors produced as a result of data transmission.

____ produces a full-featured, working model of the information system. A. Loose coupling B. Fourth-generation modeling C. System prototyping D. Web servicing

Answers

Answer:

C.system prototyping

Explanation:

Prototyping produces a quickly constructed working version of the proposed information system.

Planning

Analysis

Design

System prototyping

Implementation

Answer:

c. system prototyping

Explanation:

system prototyping  produces a full-featured, working model of the information system.

Other Questions