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
Which do web servers host?<br> Websites<br> Networks<br> Firewalls<br> Zones
bixtya [17]

Answer:

Websites

Explanation:

A web server host websites, individuals or corporate websites, this helps us to show our websites in the World Wide Web, there are several companies offers this service, even we can get a free host, but a corporate website or a social media needs a lot of host recourses, these hosts are expensive than other, we could pay a web host monthly or per year.

6 0
3 years ago
The Fully Meets rating should be assigned when the spelling suggestion matches query intent
neonofarm [45]
Yes definitely absolutely
8 0
3 years ago
Americans overwhelmingly support organ and tissue donation.
Simora [160]

This statement would be TRUE


7 0
4 years ago
One of the earlier applications of crypto-graphic hash functions was the storage of passwords to authenticate usersin computer s
vagabundo [1.1K]

Answer: provided in the explanation part.

Explanation:

This is actually quite long but nevertheless i will make it as basic as possible.

Question (a)  

Attack A:

One way property of hash means that we can't find the input string if given the hash value. The calculation of hash from input string is possible but it is not possible to calculate the input string when given the hash. If the hash function is properly created to have one-way property then there is no way of finding the exact input string. So this attack won't work as the one-way property of hash function can't be broken if the hash function is properly created.

Attack B:

Suppose h() is the hash function. And h(x) = m where x is the string and m is the hash. Then trying to find another string y such that h(y) = m is called finding out the second pre-image of the hash.

Although we can't know the exact initial string for sure, we can by using brute force method find out a second preimage.

This attack will take a very long time. It has the time complexity of 2n. It requires the attacker to have an idea about the kind of passwords that might be used and then brute force all of them to find the string that has the same hash. Each try will have a chance of 1/2n to succeed.

Rainbow attack using rainbow table is often used for such brute-force attack. This comprises a rainbow table which contains passwords and their pre-hashed values.

Therefore, it is not possible to determine the second preimages of h so easily.

Attack C:

Collisions refer to finding out m and m' without knowing any of them. Finding out collisions is easier than finding preimages. This is because after finding out 2n pairs of input/output. The probability of two of them having the same output or hash becomes very high. The disadvantage is that we can't decide which user's hash to break. However, if I do not care about a particular user but want to get as many passwords as possible, then this method is the most feasible.

It has the time complexity of 2n/2.

Hence, this is the attack which has the most success rate in this scenario.

Question (b)

The brute force way of finding out the password usually involves using a rainbow attack. It comprises a rainbow table with millions of passwords and their hashes already computed. By matching that table against the database, the password can be recovered.

Therefore it is often preferred to salt the password. It means we add some random text to the password before calculating the hash.

The salts are usually long strings. Although users usually do not select long passwords, so a rainbow table with hashes of smaller passwords is feasible. But once salt is used, the rainbow table must accommodate for the salt also. This makes it difficult computationally. Although password might be found in the rainbow table. The salt can be anything and thus, make brute-force a LOT more difficult computationally.

Therefore salt is preferred to be added to passwords before computing their hash value.

Question (c)

A hash output length of 80 means there can be exactly 280 different hash values. This means there is at least one collision if 280+1 random strings are hashed because 280 values are used to accommodate all the possible strings. It is not hard with today's computation power to do match against more than this many strings. And doing so increases the probability of exposing a probable password of a user.

Hence, 80 is not a very secure value for the hash length.

cheers i hope this helps!!!!

6 0
4 years ago
Which option allows you to customize the order of your data ?
Vladimir [108]

✧・゚: *✧・゚:*    *:・゚✧*:・゚✧

                  Hello!

✧・゚: *✧・゚:*    *:・゚✧*:・゚✧

❖ The correct answer choice is B) sorting. When you sort, you can order your sheet however you'd like.

~ ʜᴏᴘᴇ ᴛʜɪꜱ ʜᴇʟᴘꜱ! :) ♡

~ ᴄʟᴏᴜᴛᴀɴꜱᴡᴇʀꜱ

8 0
3 years ago
Read 2 more answers
Other questions:
  • A pacing calendar is provided to students so they can:
    8·2 answers
  • What economic measure is at the highest level since the Great Depression?
    12·1 answer
  • Consider the following method:
    8·2 answers
  • If you interview a dentist to learn about her experiences on the job, she is considered a secondary source of information. Pleas
    7·2 answers
  • Which are considered regulatory agencies? Check all that apply. WHO PPO HMO CMS CDC NIOSH
    11·2 answers
  • Probability can be used to determine the likelihood of specific __________
    6·2 answers
  • 10.7 LAB: Fat-burning heart rate Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus th
    8·1 answer
  • How much time per day does the average U.S. youth spend watching television, playing video games, or using a computer?
    8·1 answer
  • In this unit, you developed your skills at coding in Python. In this lab, you will put those skills to work by creating a progra
    8·2 answers
  • Ayuda necesito 7 objetos que se utilizan en la vida diaria
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!