Code:
import random as r d = {'red':4, 'blue':15, 'white':10, 'black':20, 'brown':11} for i in d.keys(): print(i, ":", end=" ") for j in range(d[i]): print("*", end = " ") print() # b colours = list(d.keys()) print(colours) #c count = 0 for i in range(1000): if r.choice(colours) == 'black': count += 1 print('Black picked {} times.'.format(count))
Ouput:
red : * * * *
blue : * * * * * * * * * * * * * * *
white : * * * * * * * * * *
black : * * * * * * * * * * * * * * * * * * * *
brown : * * * * * * * * * * *
['red', 'blue', 'white', 'black', 'brown']
Black picked 182 times.
Python 3 The number of socks of different colors in a drawer full of colored socks...
Suppose your top drawer contains different colored socks: 4 are white, 16 are black, 6 are pink, and 12 are blue. All socks in the drawer are loose (unpaired). In the morning, you randomly select two socks, one at a time. Calculate the following probabilities, writing your answer either as a decimal or a fraction. (a) What is the probability that you get a blue pair of socks? (b) What is the probability that you do not get a blue...
Suppose your top drawer contains different colored socks: 12 are white, 16 are black, 4 are pink, and 8 are blue. All socks in the drawer are loose (unpaired). In the morning, you randomly select two socks, one at a time. Calculate the following probabilities, writing your answer either as a decimal or a fraction. (a) What is the probability that you get a blue pair of socks? O Preview (b) What is the probability that you do not get...
Suppose your upper drawer has 36 different socks: 12 are white, 10 are black, 6 are pink and 8 are blue. all the socks in the drawer are unpaired/lose. In the morning you pick 2 socks at random, one at a time. Draw a probability tree to calculate: a) The probability of picking a black sock and a white sock b) The probability of picking a pair of white socks c) The probability of picking a blue sock GIVEN you...
The photoreceptors in the human eye, called rods and cones, have different sensitivities to different wavelengths of electromagnetic waves. (Figure 1) (Notice that the y axis in the figure is a logarithmic scale.) The rods, which number over 100 million, can only be activated by a certain range of wavelengths, but they do not pass any color information to the brain. In other words, they note differences in shades of grey (from black to white) and are responsible for a...
A case-control (or retrospective) study was conducted to investigate a relationship between the colors of helmets worn by motorcycle drivers and whether they are injured or killed in a crash. Results are given in the accompanying table. Using a 0.01 significance level, test the claim that injuries are independent of helmet color. Questions: Compute the test statistic (Round to three decimal places as needed.) and find the critical value. Please list steps. Thank you! Do Homework - dalton jones -...
Python Object oriented programming Exercise 3 Dictionary Computers are playing an increasing role in education. Write a program that will help an elementary school student to learn English. To simplify the model, the program will first teach numbers from 1 to 10, colors and fruits. It will use a dictionary to store the pairs Spanish-English words. dataTable-uno':one,'dos':'two....' rojo':'red','blue':'Azul... manzana': apple, nara nja:orange. When running your program, it should get a random Spanish word from the dictionary dataTable and then show...
# In this file, fill in the ... parts with lines of code. Do not # create new functions. from random import seed, randrange P=[" ♟♜♝♞♛♚"]; L,R,BL,TL=["▌▐▄▀"] BonR=WonR=WonB=DonR=DonB=RonB=GonR=GonB=RonG='\033[1;m\033[' WonR+='7;31;47m' # For drawing a white piece on a red background WonB+='7;30;47m' # For drawing a white piece on a black background DonR+='2;37;41m' # For drawing a dark piece on a red background DonB+='2;37;40m' # For drawing a dark piece on a black background GonR+='2;33;41m' # For drawing gold on a red...
Please help me with this question! It is due by midnight! I'm doing this in Visual Studio 2019. But any others are fine as long as it can compile. I also wanted to see the results if it is compiled and QT comments as well. Please respond immediately! Description: For this homework we will use classes to model something in the real world. In this case a resistor. The colored bands on the top-most resistor shown in the photo below...
AssignmentBitmap files map three 8-bit (1-byte) color channels per pixel. A pixel is a light-emitting "dot" on your screen. Whenever you buy a new monitor, you will see the pixel configuration by its width and height, such as 1920 x 1080 (1080p) or 3840x2160 (4K). This tells us that we have 1080 rows (height), and each row has 1920 (width) pixels.The bitmap file format is fairly straight forward where we tell the file what our width and height are. When...
Q3) A day has 86,400 secs (24*60*60). Given a number in the range 1 to 86,400, output the current time as hours, minutes, and seconds with a 24-hour clock. For example:70,000 sec is 19 hours, 26 minutes, and 40 seconds. Q4) Consider a triangle with sides of length 3, 7, and 9. The law of cosines states that given three sides of a triangle (a, b, and c) and the angle C between sides a and b: c square = a...