Stats 107; m3-Review

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

For Loop Syntax What is the output of the following segment of code? for i in range(10): print(i) The numbers 0 - 9, on one line. The numbers 0 - 10, on one line. The numbers 0 - 10, on separate lines. The numbers 0 - 9, on separate lines.

The numbers 0 - 9, on separate lines.

Random Number Generation Facts Which of the following are true? Select all that apply: The probability of outputting a 3 in random.randint(1, 4) is 25%. The probability of returning any color from random.choice(['red', 'red', 'yellow', 'blue']) is the same for all colors. random.choice() can only simulate unbiased distributions. Each number that appears from the code random.randint(1, 10) has an equal chance of being chosen. random.choice([1, 2, 3, 4, 5, 6]) simulates rolling a fair 6-sided die.

The probability of outputting a 3 in random.randint(1, 4) is 25%. Each number that appears from the code random.randint(1, 10) has an equal chance of being chosen. random.choice([1, 2, 3, 4, 5, 6]) simulates rolling a fair 6-sided die.

MCQs Select all the following statements that are true about the standard normal curve The standard normal curve is bell-shaped. The x-axis is measured in standard units (also called Z scores). The standard normal curve is centered at 0. The area under the curve is 50%. The area under the curve is 100%. The standard normal curve is centered at 1. The standard normal curve is U-shaped.

The standard normal curve is bell-shaped. The x-axis is measured in standard units (also called Z scores). The standard normal curve is centered at 0. The area under the curve is 100%.

MCQS Select all the following statements that are true about the standard normal curve. The standard normal curve is centered at 0. The standard normal curve is bell-shaped. The mean and the median are 1 and the standard deviation is 0. The standard normal curve is U-shaped. The standard normal curve is centered at 1. The mean and the median are 0 and the standard deviation is 1. The x-axis is measured in standard units (also called Z scores).

The x-axis is measured in standard units (also called Z scores). The mean and the median are 0 and the standard deviation is 1. The standard normal curve is bell-shaped. The standard normal curve is centered at 0.

MCQs Select all the following statements that are true about the standard normal curve. The x-axis is measured in standard units (also called Z scores). The area under the curve is 100%. The mean and the median are 1 and the standard deviation is 0. The mean and the median are 0 and the standard deviation is 1. The standard normal curve is bell-shaped. The standard normal curve is centered at 1. The area under the curve is 50%.

The x-axis is measured in standard units (also called Z scores). The area under the curve is 100%. The mean and the median are 0 and the standard deviation is 1. The standard normal curve is bell-shaped.

Conditional True/False For each of the following scenarios, select whether or not it is possible for "Hello!" to print. Suppose you write and run the following code: import random n = random.randint(0, 10) if n != 10: print("Hello!") Yes, it is possible for "Hello!" to print. No, it is not possible for "Hello!" to print.

Yes, it is possible for "Hello!" to print.

Conditional True/False For each of the following scenarios, select whether or not it is possible for "Hello!" to print. Suppose you write and run the following code: import random n = random.randint(0, 8) if n > 7: print("Hello!") Yes, it is possible for "Hello!" to print. No, it is not possible for "Hello!" to print.

Yes, it is possible for "Hello!" to print.

Conditional True/False For each of the following scenarios, select whether or not it is possible for "Hello!" to print. Suppose you write and run the following code: import random n = random.randint(7, 8) if n <= 7: print("Hello!") Yes, it is possible for "Hello!" to print. No, it is not possible for "Hello!" to print.

Yes, it is possible for "Hello!" to print.

Conditional True/False For each of the following scenarios, select whether or not it is possible for "Hello!" to print. Suppose you write and run the following code: import random n = random.randint(8, 9) if n < 9: print("Hello!") Yes, it is possible for "Hello!" to print. No, it is not possible for "Hello!" to print.

Yes, it is possible for "Hello!" to print.

CBTF Z-Scores A group of Illinois students were surveyed on how many times they visit the Computer Based Testing Facility (CBTF) for an exam every semester. Results roughly followed the normal curve, with students visiting the CBTF an average of 10 times with an SD of 2. Suppose a student visited the CBTF 7 times. What z-score represents this value?

Z-Score: -1.5

CBTF Z-Scores A group of Illinois students were surveyed on how many times they visit the Computer Based Testing Facility (CBTF) for an exam every semester. Results roughly followed the normal curve, with students visiting the CBTF an average of 10 times with an SD of 2. Suppose a student visited the CBTF 12 times. What z-score represents this value?

Z-Score: 1

i11, Taylor Swift and the Normal Curve You decided to conduct a survey to determine the correlation between Taylor Swift fans and GPA. You find that the average GPA of a Taylor Swift fan is 3.49 with a standard deviation of 0.251 and that this data follows a normal curve. You are a Swiftie and your GPA is 3.84. Determine the z-score of your GPA.

Z-Score: 1.394

Simulation of Two Shapes in a Box You have a box with exactly two objects: square and hexagon. Create and return a DataFrame of 1000 simulations, where each simulation involves drawing two objects from the box without replacement. There are a few requirements: In your DataFrame, make sure your columns are called "shape1" and "shape2". The values for the shapes must be exactly "square" and "hexagon".

data = [] for i in range(1000): shape1 = random.choice(["hexagon", "square"]) if shape1 == "hexagon": shape2 = random.choice(["square"]) if shape1 == "square": shape2 = random.choice(["hexagon"]) d = {"shape1": shape1, "shape2": shape2} data.append(d) df=pd.DataFrame(data) df

i2, Weather in Champaign, IL Write a simulation in Python to simulate the weather in Champaign, IL during the summer. You found the following historical data about the summer weather: 60% of summer days are sunny, 20% of summer days are rain, 10% of summer days are clouds (without rain), and the final 10% of summer days are windy. Store and return a DataFrame of a simulation of 1000 days. Your DataFrame must contain the column weather, where each row stores the weather for one day (one of sunny, rain, clouds, or windy). Make sure the likelihood of the weather matches the chance of the event provided above.

data = [] for i in range(1000): weather = random.choice(["sunny", "sunny", "sunny", "sunny", "sunny", "sunny", "rain", "rain", "clouds", "windy"]) d = {"weather": weather} data.append(d) df=pd.DataFrame(data) df

Simulation of Three Dice Write a simulation in Python to simulate rolling three 6-sided dice. Run your simulation 2500 times . Store and return your results in a DataFrame with the columns die1, die2, and die3 that each contain a value between 1-6 representing the possible rolls of the 6-sided die.

data = [] for i in range(10000): die1 = random.choice([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) die2 = random.choice([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) die3 = random.choice([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) d = {"die1": die1, "die2": die2, "die3": die3} data.append(d) df = pd.DataFrame(data) df

CONFUSED, NEED HELP CLARIFYING Conditional Printing Suppose you write the following snippet of code and run it multiple times. import random n = random.randint(0, 107) if n < 10: print("Hello!") elif n == 107: print("DISCOVERY!") else: print("abc") print("Data Science") "Hello!" will print if n is less than 10 "Data Science" will print if n is 107 "Hello!" will print if n is 10 "abc" will print if n is 107

"Hello!" will print if n is less than 10 "Data Science" will print if n is 107

i18, NEEDS EXPLAINING Conditional Printing Suppose you write the following snippet of code and run it multiple times. import random n = random.randint(0, 107) if n < 10: print("Hello!") elif n == 107: print("DISCOVERY!") else: print("abc") print("Data Science") Which of the following statements are TRUE? "Hello!" will print if n is less than 10 "abc" will print if n is 100 "Data Science" will print if n is less than 10 "abc" will print if n is 107

"Hello!" will print if n is less than 10 "abc" will print if n is 100 "Data Science" will print if n is less than 10

Function Output The following rollDie function has been defined: def rollDie(sides = 6): roll = random.randint(1, sides) return roll What are all the possible values for the variable roll when we call rollDie(1)? 1 1, 2 1, 2, 3, 4, 5 1, 2, 3, 4, 5, 6 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13

1

Distribution Functions Given a z-score in a normal distribution, z, which of the following can be used to find the area to the right of that z-score? norm.cdf(z) norm.ppf(z) 1 - norm.cdf(z) 1 - norm.ppd(z)

1 - norm.cdf(z)

Function Output The following rollDie function has been defined: def rollDie(sides = 6): roll = random.randint(1, sides) return roll What are all the possible values for the variable roll when we call rollDie()? 1 1, 2 1, 2, 3, 4, 5 1, 2, 3, 4, 5, 6 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13

1, 2, 3, 4, 5, 6

Function Output The following rollDie function has been defined: def rollDie(sides = 6): roll = random.randint(1, sides) return roll What are all the possible values for the variable roll when we call rollDie(12)? 1 1, 2 1, 2, 3, 4, 5 1, 2, 3, 4, 5, 6 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12

Output of Default Python Functions Which of the following is the output of the code segment below? def Increment(n = 6): return n + 1 sum = Increment(21) sum 7 22 21 None of the above

22

Superbowl Calories The number of calories consumed by a large group of Super Bowl partiers was found to roughly follow the normal curve with an average of 2000 calories and an SD of 300 calories. What percentage of partiers consumed more than 2200 calories on Superbowl Sunday? Above 2200:

25.25%

Output of Default Python Functions Which of the following is the output of the code segment below? def Increment(n = 6): return n + 1 sum = Increment(32) sum 32 33 7 None of the above

33

Blood Pressure and the Normal Curve The blood pressure (in millimeters) was measured for a large sample of people. The average pressure is 140 mmHg, and the standard deviation of the measurements is 20 mmHg. The histogram looks reasonably like a normal curve. Use the normal curve to estimate the following percentages. What is the percentage of people with blood pressure between 140 and 165 mm? 78.8% 68.27% 10.6% 89.4% 39.4%

39.4%

Output of Default Python Functions Which of the following is the output of the code segment below? def Increment(n = 6): return n + 1 sum = Increment(47) sum 7 48 47 None of the above

48

Superbowl Calories The number of calories consumed by a large group of Super Bowl partiers was found to roughly follow the normal curve with an average of 2000 calories and an SD of 300 calories. What percentage of partiers consumed between 1800 and 2200 calories on Superbowl Sunday? Between 2200 and 1800:

49.5%

Blood Pressure and the Normal Curve The blood pressure (in millimeters) was measured for a large sample of people. The average pressure is 140 mmHg, and the standard deviation of the measurements is 20 mmHg. The histogram looks reasonably like a normal curve. Use the normal curve to estimate the following percentages. Choose the answer that is closest to being correct. What is the percentage of people with a blood pressure between 118 and 162 mm? 13.6% 36.4% 68.27% 86.4% 72.8%

72.8

Blood Pressure and the Normal Curve The blood pressure (in millimeters) was measured for a large sample of people. The average pressure is 140 mmHg, and the standard deviation of the measurements is 20 mmHg. The histogram looks reasonably like a normal curve. Use the normal curve to estimate the following percentages. What is the percentage of people with a blood pressure between 115 and 165 mm? 10.6% 39.4% 89.4% 78.8% 68.27%

78.8%

i4, ALS Ice Bucket Challenge In 2014, the ALS Ice Bucket challenge went viral. The challenge involved pouring a bucket of ice water over a person's head to raise awareness for Amyotrophic Lateral Sclerosis (ALS) and encourage donations to help the fight against it. Suppose your elementary school held an ALS Ice Bucket Challenge with proceeds going to the ALS Association. You find that donations followed the normal curve, with an average of $11 and an SD of $3. What percentage of people donated more than $14 to the ALS Association?

Above $14: 15.87

i4, ALS Ice Bucket Challenge In 2014, the ALS Ice Bucket challenge went viral. The challenge involved pouring a bucket of ice water over a person's head to raise awareness for Amyotrophic Lateral Sclerosis (ALS) and encourage donations to help the fight against it. Suppose your elementary school held an ALS Ice Bucket Challenge with proceeds going to the ALS Association. You find that donations followed the normal curve, with an average of $11 and an SD of $3. What percentage of people donated between $9 and $14 to the ALS association?

Between $9 and $14: 58.89

Real-World Linking of Random Number Generation You see the code random.randint(1, 52), where each output can be mapped to a unique outcome 1 through 52. What best describes a possible real-world example that is simulated using the code? Flipping a two-sided fair coin. Guessing an answer on an exam question where there are five answer choices. Choosing a card randomly from a standard deck of 52 cards. Rolling a six-sided fair die. Drawing from your dresser drawer that contains 4 red socks, 4 green socks, and 4 blue socks.

Choosing a card randomly from a standard deck of 52 cards.

For Loop Syntax What is the output of the following segment of code? for i in (3): print("STAT") Prints "STAT" "107" three times, each on a separate line. Prints "STAT107" three times, on one line. Does not print anything and gives an error. Prints "STAT" three times, each on a separate line.

Does not print anything and gives an error.

Real-World Linking of Random # Gen. You see the code random.randint(1, 3), where each output can be mapped to a unique outcome 1 through 3. What best describes a possible real-world example that is simulated using the code? Guessing an answer on an exam question where there are five answer choices. Rolling a six-sided fair die. Drawing from your dresser drawer that contains 4 red socks, 4 green socks, and 4 blue socks. Choosing a card randomly from a standard deck of 52 cards. Flipping a two-sided fair coin.

Drawing from your dresser drawer that contains 4 red socks, 4 green socks, and 4 blue socks.

Real-World Linking of Random Number Generation You see the code random.choice([1, 2, 3, 4, 5]), where each output can be mapped to a unique outcome 1 through 5. What best describes a possible real-world example that is simulated using the code? Choosing a card randomly from a standard deck of 52 cards. Rolling a six-sided fair die. Flipping a two-sided fair coin. Guessing an answer on an exam question where there are five answer choices. Drawing from your dresser drawer that contains 4 red socks, 4 green socks, and 4 blue socks.

Guessing an answer on an exam question where there are five answer choices.

i13, The Normal Distribution and Sleep The number of hours of sleep DISCOVERY students reported getting each night roughly follows the normal curve with an average of 7.4 hours and a SD of 1.2 hours. Using the approximation that the middle area between Z = -1.00 and Z = 1.00 is almost exactly 68%, what is the approximate lower value of the range of hours that 68% of DISCOVERY students sleep?

Lower Value of Range: 6.2 hours

Conditional True/False For each of the following scenarios, select whether or not it is possible for "Hello!" to print. Suppose you write and run the following code: import random n = random.randint(0, 9) if n > 9: print("Hello!") Yes, it is possible for "Hello!" to print. No, it is not possible for "Hello!" to print.

No, it is not possible for "Hello!" to print.

Possible Uniform Distributions The following Python code is used to generate a random number: random.choice([51, 52, 53, 54, 55, 55, 56]) When this code is run many times, will this code generate a uniform distribution of values? Yes, the distribution of numbers is expected to be uniform. No, the distribution of numbers is NOT expected to be uniform. Unable to determine.

No, the distribution of numbers is NOT expected to be uniform.

i11, Taylor Swift and the Normal Curve You decided to conduct a survey to determine the correlation between Taylor Swift fans and GPA. You find that the average GPA of a Taylor Swift fan is 3.49 with a standard deviation of 0.251 and that this data follows a normal curve. You are a Swiftie and your GPA is 3.84. What percent of Taylor Swift fans have a GPA below yours?

Percent Below: 91.84 %

Height Distribution The heights of the 228 men who graduated from UIUC a few years ago follow the normal curve fairly closely with an average of about 68" and a SD of about 2". What percent of the students are over 70.4"? Enter your answer as a percentage between 0-100.

Percent over 70.4:

Height Distribution The heights of the 228 men who graduated from UIUC a few years ago follow the normal curve fairly closely with an average of about 68" and a SD of about 2". What percentile is 70.4 inches? (This is the same as finding the percent of men who are under 70.4 inches.) Enter your answer as a percentage between 0-100.

Percentile of 70.4:

For Loop Syntax What is the output of the following segment of code? for i in range(3): print("STAT") print("107") Prints "STAT107" on one line three times. Prints "STAT107" on separate lines three times. Does not print anything and gives an error. Prints "STAT" and "107" on separate lines three times.

Prints "STAT" and "107" on separate lines three times.

For Loop Syntax What is the output of the following segment of code? for i in (["red", "yellow", "blue"]): print(i) Prints "red", "yellow", "blue", on one line. Prints "red", "yellow", "blue", on separate lines. Prints "i" 3 times. Prints "red yellow blue", on one line.

Prints "red", "yellow", "blue", on separate lines.

i5, Lucky Number 13 Say you have a box of tickets marked with numbers and you want to play a game with your friends who are huge Swifties! The game is simple: you draw a ticket out of the box and if it is a 13 (Taylor's favorite number), you win! Otherwise, you lose. There are 28 tickets marked 1 through 28. Assume you are drawing with replacement. Write a simulation to play this game 1989 times. Your end result should be a DataFrame that contains 0s and 1s. If you win, the game should record a 1, if you lose, the game should record a 0. Store the results in a DataFrame named df. This DataFrame should have one column named win.

data = [] for i in range(1989): draw = random.randint(1,28) if draw == 13: d = {"win": 1} else: d = {"win": 0} data.append(d) df = pd.DataFrame(data) df

Simulation of Three Dice Write a simulation in Python to simulate rolling three 12-sided dice. Run your simulation 2500 times . Store and return your results in a DataFrame with the columns die1, die2, and die3 that each contain a value between 1-12 representing the possible rolls of the 12-sided die.

data = [] for i in range(2500): die1 = random.randint(1,12) die2 = random.randint(1,12) die3 = random.randint(1,12) d = {"die1": die1, "die2": die2, "die3": die3} data.append(d) df = pd.DataFrame(data) df

i1, simulation of three shapes in a box You have a box with exactly three objects: triangle, star, and pentagon. Create and return a DataFrame to store the results of 2500 simulations, where each simulation involves drawing two objects from the box without replacement. There are a few requirements: In your DataFrame, make sure your columns are called "shape1" and "shape2". The values for the shapes must be exactly "triangle", "star", and "pentagon".

data = [] for i in range(2500): shape1 = random.choice(["triangle", "star", "pentagon"]) if shape1 == "triangle": shape2 = random.choice(["star", "pentagon"]) if shape1 == "star": shape2 = random.choice(["pentagon", "triangle"]) if shape1 == "pentagon": shape2 = random.choice(["star", "triangle"]) d = {"shape1": shape1, "shape2": shape2} data.append(d) df=pd.DataFrame(data) df

Cooking Simulation You're hungry and you only find beans, eggs, chicken and tofu in your fridge. You want to cook something with two of these ingredients. Indecisive and looking to simulate, create and return a DataFrame to store the result of 2500 simulations, where each simulation involves randomly selecting two ingredients for your dish without replacement (food is finite, after all). There are a few requirements: In your DataFrame, make sure your columns are called "ingredient1" and "ingredient2". The values for the ingredients must be exactly "beans", "eggs", "chicken", or "tofu".

import pandas as pd import random # Write your code here: data = [] for i in range(2500): ingredient1 = random.choice(["beans", "chicken", "eggs", "tofu"]) if ingredient1 == "beans": ingredient2 = random.choice(["chicken", "eggs", "tofu"]) if ingredient1 == "chicken": ingredient2 = random.choice(["beans", "eggs", "tofu"]) if ingredient1 == "eggs": ingredient2 = random.choice(["chicken", "tofu", "beans"]) if ingredient1 == "tofu": ingredient2 = random.choice(["chicken", "eggs", "beans"]) d = {"ingredient1": ingredient1, "ingredient2": ingredient2} data.append(d) df=pd.DataFrame(data) df

Drawing Marbles From A Bag In Data Science, it is sometimes necessary to associate numbers with a real-world meaning. Write a Python simulation that simulates randomly drawing 187 marbles from a bag of 5 red marbles, 5 blue marbles, and 5 yellow marbles with replacement. Each time you draw a marble, record its color by associating it with an integer value 1, 2, or 3 where 1 represents a red marble, 2 represents a blue marble, and 3 represents a yellow marble. Store and return your results in a DataFrame with a single column called marble that shows the integer associated with each marble drawn.

import pandas as pd import random # Write your simulation here: data = [ ] for i in range(187): marble = random.randint(1,3) d = {"marble": marble} data.append(d) df=pd.DataFrame(data) df

Multiple choice Exam Create a simulation of a student taking a multiple choice exam containing 5 questions and run this simulation a total of 2500 times. All questions have five possible answer choices: A, B, C, D, and E. In your simulation: The first question must be called q1, the second question must be called q2, and so on. Each answer for each question should be randomly picked among the five answer choices (A, B, C, D, and E).

import pandas as pd import random data=[] for i in range (2500): q1 = random.choice(["A", "B", "C", "D", "E"]) q2 = random.choice(["A", "B", "C", "D", "E"]) q3 = random.choice(["A", "B", "C", "D", "E"]) q4 = random.choice(["A", "B", "C", "D", "E"]) q5 = random.choice(["A", "B", "C", "D", "E"]) d = {"q1":q1,"q2":q2, "q3":q3, "q4":q4, "q5":q5} data.append(d) df = pd.DataFrame(data) df

Flipping a Coin The code cell below simulates flipping a fair coin 5 times. Modify the code below so that it simulates flipping a coin 78 times. import random coin_flips = [ ] for i in range(5): coin = random.choice(['head', 'tail']) coin_flips.append(coin) coin_flips

import random coin_flips = [ ] for i in range(78): coin = random.choice(['head', 'tail']) coin_flips.append(coin) coin_flips

Random Number Range You've already imported the random module into a Python notebook and type the following code into a cell: random.randint(25, 54) What is the smallest possible value (a.k.a, the "lower bound") of the number generated by the code above?

lower bound: 25

i2, Probability of Spinning Wheels in Python A complete simulation of an event has already been written and run for you. The data from the simulation is stored in the file wheel-spinner.csv. The simulation involves spinning two wheels each with numbers 1 through 16. Each spin in stored as a row (observation) in the DataFrame df under the columns wheel1 and wheel2. Using the simulation results in df, find an estimate of the probability that you get at least one value less than 5 OR the value of wheel2 is greater than 12. Store your probability in a variable called prob.

prob = len(df[(df["wheel1"] < 5) | (df["wheel2"] < 5) | (df["wheel2"] > 12)]) / len(df) prob

Exclusive Random Selection You want to use the random module in Python to select a random integer strictly exclusively between 36 and 53 — meaning NOT including 36 or 53 themselves. random.randint(36, 51) random.randint(36, 53) random.randint(37, 52) random.randint(37, 53) random.randint(37, 51)

random.randint(37, 52)

Exclusive Random Selection You want to use the random module in Python to select a random integer strictly exclusively between 38 and 65 — meaning NOT including 38 or 65 themselves. Which of the following function calls can accomplish this? random.randint(39, 64) random.randint(39, 63) random.randint(40, 63) random.randint(38, 65) random.randint(38, 63)

random.randint(39, 64)

Inclusive Random Selection You want to use the random module in Python to select a random integer inclusively between 42 and 65, including 42 and 65. Which of the following function calls can accomplish this? random.randint(42, 65) random.randint(41, 64) random.randint(43, 64) random.randint(42, 64) random.randint(43, 66)

random.randint(42, 65)

Taylor's Choice You are a Taylor Swift Mega Fan and you know that she is coming to tour your city in a few months. You decide to try and predict one of the songs Taylor is likely to sing in concert. After a little research, you conclude that she will sing twice as many songs from her album, Midnights (as it was released in 2022), than any other album. The list of options are as follows: Bejeweled (Midnights), Look What You Made Me Do (Reputation), or Carolina (Single). s=r.c(['Bejeweled', 'Look What You Made Me Do', 'Carolina', 'Carolina']) s=r.c(['Bejeweled', 'Look What You Made Me Do', 'Bejeweled']) s=r.c(['Bejeweled', 'Look What You Made Me Do', 'Carolina']) s=r.c(['Bejeweled', 'Look What You Made Me Do', 'Carolina', 'Bejeweled']) s=r.c(['Bejeweled', 'Look What You Made Me Do', 'Bejeweled', 'Carolina']) s=r.c(['Bejeweled', 'Bejeweled', 'Look What You Made Me Do', 'Carolina'])

song=random.choice(['Bejeweled', 'Look What You Made Me Do', 'Carolina', 'Bejeweled']) song=random.choice(['Bejeweled', 'Look What You Made Me Do', 'Bejeweled', 'Carolina']) song=random.choice(['Bejeweled', 'Bejeweled', 'Look What You Made Me Do', 'Carolina'])

norm.ppf

to be used when Percentile given

norm.cdf

to be used when z-score given

Random Number Range You've already imported the random module into a Python notebook and type the following code into a cell: random.randint(25, 54) What is the largest possible value (a.k.a, the "upper bound") of the number generated by the code above?

upper bound: 54

z =

x-avg/SD

Random Royal Cards You and your friends have planned a weekend trip to the Wynn in Las Vegas to play Texas hold'em poker. In preparation for the trip, you are developing an advanced poker odds calculator. Suppose that a part of your calculator requires you to simulate selecting a card, with it being four times as likely to select a royal card than any other card. For context, a royal card is any 10, Jack (J), Queen (Q), King (K), or Ace (A) - because they can be part of a royal flush. card = random.choice(['10', '10', '5', 'J', 'Q']) card = random.choice(['2', '5', 'A', 'A', 'Q']) card = random.choice(['10', '2', '4', '6', 'A']) card = random.choice(['10', '10', '10', '7', 'A'])

card = random.choice(['10', '10', '5', 'J', 'Q']) card = random.choice(['10', '10', '10', '7', 'A'])

Random Royal Cards You and your friends have planned a weekend trip to the Wynn in Las Vegas to play Texas hold'em poker. In preparation for the trip, you are developing an advanced poker odds calculator. Suppose that a part of your calculator requires you to simulate selecting a card, with it being three times as likely to select a royal card than any other card. For context, a royal card is any 10, Jack (J), Queen (Q), King (K), or Ace (A) - because they can be part of a royal flush. Which of the following are possible random generators that correctly simulate this? card = random.choice(['3', 'A', 'K', 'K'] card = random.choice(['10', '2', 'K', 'K']) card = random.choice(['10', '10', '10', '2', '2', '7', '7', 'K']) card = random.choice(['4', '9', 'A', 'A', 'J', 'K', 'Q', 'Q'])

card = random.choice(['3', 'A', 'K', 'K']) card = random.choice(['10', '2', 'K', 'K']) card = random.choice(['4', '9', 'A', 'A', 'J', 'K', 'Q', 'Q'])

Random Royal Cards You and your friends have planned a weekend trip to the Wynn in Las Vegas to play Texas hold'em poker. In preparation for the trip, you are developing an advanced poker odds calculator. Suppose that a part of your calculator requires you to simulate selecting a card, with it being three times as likely to select a royal card than any other card. For context, a royal card is any 10, Jack (J), Queen (Q), King (K), or Ace (A) - because they can be part of a royal flush. card = random.choice(['10', '8', 'A', 'K']) card = random.choice(['2', '8', 'A', 'Q']) card = random.choice(['10', '10', '10', '3', '7', 'A', 'J', 'J']) card = random.choice(['10', '4', 'A', 'K'])

card=random.choice(['10', '8', 'A', 'K']) card=random.choice(['10', '10', '10', '3', '7', 'A', 'J', 'J']) card=random.choice(['10', '4', 'A', 'K'])

Random Class Your roommate is having trouble deciding what course to take next semester. Suggesting an alternative to indecision, you mention the Python random library's ability to choose. Given your roommate's preferences, you'd want it to be three times as likely to select a CS course than any other course. course = random.choice(['CS 124', 'CS 128', 'CS 225', 'CS 374', 'KIN 104', 'KIN 104', 'MUS 132', 'MUS 132']) course = random.choice(['ANSC 210', 'CS 124', 'CS 128', 'CS 225', 'CS 374', 'CS 374', 'CS 374', 'MUS 132']) course = random.choice(['CS 124', 'CS 225', 'KIN 104', 'MUS 132', 'MUS 132', 'REL 110', 'RST 242', 'RST 242']) course = random.choice(['ANSC 210', 'CS 124', 'CS 124', 'CS 128', 'CS 173', 'CS 225', 'CS 374', 'MUS 132'])

course = random.choice(['ANSC 210', 'CS 124', 'CS 128', 'CS 225', 'CS 374', 'CS 374', 'CS 374', 'MUS 132']) course = random.choice(['ANSC 210', 'CS 124', 'CS 124', 'CS 128', 'CS 173', 'CS 225', 'CS 374', 'MUS 132'])

Random Class Your roommate is having trouble deciding what course to take next semester. Suggesting an alternative to indecision, you mention the Python random library's ability to choose. Given your roommate's preferences, you'd want it to be just as likely to select a CS course than any other course. Which of the following are possible random generators that correctly simulate this? course = random.choice(['CS 128', 'CS 225', 'CS 374', 'CS 374', 'CS 374', 'MUS 132']) course = random.choice(['ANSC 210', 'CS 124', 'CS 128', 'REL 110']) course = random.choice(['CS 124', 'CS 374', 'KIN 104', 'KIN 104', 'REL 110', 'RST 242']) course = random.choice(['CS 124', 'CS 124', 'CS 128', 'MUS 132'])

course = random.choice(['ANSC 210', 'CS 124', 'CS 128', 'REL 110'])

Random Class Your roommate is having trouble deciding what course to take next semester. Suggesting an alternative to indecision, you mention the Python random library's ability to choose. Given your roommate's preferences, you'd want it to be just as likely to select a CS course than any other course. Which of the following are possible random generators that correctly simulate this? course = random.choice(['ANSC 210', 'CS 128', 'CS 173', 'CS 225', 'KIN 104', 'MUS 132']) course = random.choice(['ANSC 210', 'ANSC 210', 'CS 124', 'CS 128', 'KIN 104', 'RST 242']) course = random.choice(['CS 124', 'CS 225', 'CS 225', 'CS 225', 'CS 374', 'RST 242']) course = random.choice(['ANSC 210', 'CS 173', 'CS 173', 'KIN 104'])

course = random.choice(['ANSC 210', 'CS 128', 'CS 173', 'CS 225', 'KIN 104', 'MUS 132']) course = random.choice(['ANSC 210', 'CS 173', 'CS 173', 'KIN 104'])

Random Class Your roommate is having trouble deciding what course to take next semester. Suggesting an alternative to indecision, you mention the Python random library's ability to choose. Given your roommate's preferences, you'd want it to be just as likely to select a CS course than any other course. Which of the following are possible random generators that correctly simulate this? c=r.c.(['CS 124', 'CS 124', 'CS 128', 'CS 374', 'CS 374', 'MUS 132']) c=r.c(['CS 124', 'CS 173', 'CS 225', 'RST 242']) c.=r.c.(['CS 124', 'CS 173', 'CS 225', 'KIN 104', 'REL 110', 'RST 242']) c.=r.c.(['CS 173', 'CS 225', 'REL 110', 'RST 242'])

course = random.choice(['CS 124', 'CS 173', 'CS 225', 'KIN 104', 'REL 110', 'RST 242']) course = random.choice(['CS 173', 'CS 225', 'REL 110', 'RST 242'])

Random Class Your roommate is having trouble deciding what course to take next semester. Suggesting an alternative to indecision, you mention the Python random library's ability to choose. Given your roommate's preferences, you'd want it to be just as likely to select a CS course than any other course. Which of the following are possible random generators that correctly simulate this? course = random.choice(['CS 124', 'CS 173', 'CS 374', 'KIN 104']) course = random.choice(['CS 173', 'CS 225', 'MUS 132', 'REL 110']) course = random.choice(['CS 124', 'CS 173', 'CS 374', 'KIN 104', 'REL 110', 'RST 242']) course = random.choice(['CS 124', 'CS 173', 'CS 225', 'CS 374', 'CS 374', 'KIN 104'])

course = random.choice(['CS 173', 'CS 225', 'MUS 132', 'REL 110']) course = random.choice(['CS 124', 'CS 173', 'CS 374', 'KIN 104', 'REL 110', 'RST 242'])

i1, Simulation of your two favorite songs You and two friends choose your favorite songs from Taylor Swift's album: evermore (deluxe version) To learn more about simulation, you write the names of the songs on slips of paper and put them in a hat to draw from. Your song options are: "marjorie" and "gold rush". Create a DataFrame that stores the results of 2500 simulations of drawing two songs from the hat without replacement. There's a few requirements: In your DataFrame, make sure your columns are called "song1" and "song2". The values for the songs must be exactly "marjorie" and "gold rush". Make sure you are drawing without replacement. In other words, for each draw, the songs cannot be the same.

data = [] for i in range(2500): song1 = random.choice(["marjorie", "gold rush"]) if song1 == "marjorie": song2 = random.choice(["gold rush"]) if song1 == "gold rush": song2 = random.choice(["marjorie"]) d = {"song1": song1, "song2": song2} data.append(d) df=pd.DataFrame(data) df

simulation of spinning wheels Write a simulation in Python to simulate spinning two wheels each numbered 1 through 12. Run your simulation 5000 times. Store and return your results in a DataFrame with the columns wheel1 and wheel2.

data = [] for i in range(5000): wheel1 = random.randint(1,12) wheel2 = random.randint(1,12) d = {"wheel1": wheel1, "wheel2": wheel2} data.append(d) df = pd.DataFrame(data) df

i4, simulation of your three favorite songs You and two friends choose your favorite songs from Taylor Swift's album: 1989 To learn more about simulation, you write the names of the songs on slips of paper and put them in a hat to draw from. Your song options are: "Clean", "Style", and "This Love". Create and return a DataFrame that stores the results of 5000 simulations of drawing two songs from the hat without replacement. There's a few requirements: In your DataFrame, make sure your columns are called "song1" and "song2". The values for the songs must be exactly "Clean", "Style", and "This Love". You may copy and paste these values. Make sure you are drawing without replacement. In other words, for each draw, the songs cannot be the same.

data=[] for i in range (5000): song1 = random.choice(["Clean", "Style", "This Love"]) if song1 == "Clean": song2 = random.choice(["Style", "This Love"]) if song1 == "Style": song2 = random.choice(["Clean", "This Love"]) if song1 == "This Love": song2 = random.choice(["Style", "Clean"]) d = {"song1":song1,"song2":song2} data.append(d) df = pd.DataFrame(data) df

Python Functions Syntax Which of the following correctly declares a function Day with parameter date in Python? def Day(): def Day(date): Both are correct None of the above

def Day(date):

Python Functions Syntax Which of the following correctly declares a function DiceRoll with parameter sides in Python? def DiceRoll(sides): def DiceRoll(): Both are correct None of the above

def DiceRoll(sides):

i3, Addition Function Write a function called add that takes two arguments and returns their sum. Only your function will be graded.

def add(a,b): return a * b add(10,10)

Area Function Write a function called area that takes two arguments, the base and height of a triangle, and returns the area of the triangle. Remember: the formula to calculate the area of a triangle is (0.5 * base * height). Only your function will be graded.

def area(base, height): return 0.5 * base * height

i1, Draw Queens Function Write a function called drawQueens that takes a parameter times and returns the number of queens drawn when drawing cards from a standard 52-card deck times times. A standard 52-card deck includes 52 total cards with 4 suits each with 13 possible values: ace, two, king, etc. When drawing, assume we draw with replacement. Only your function will be graded.

def drawQueens(times): count = 0 for i in range(times): draw = random.randint(1, 52) if draw <= 4: count += 1 return count

Draw Queens Function Write a function called drawQueens that takes a parameter times and returns the number of queens drawn when drawing cards from a standard 52-card deck times times. When drawing, assume we draw with replacement. Only your function will be graded.

def drawQueens(times): queens_count = 0 for i in range(times): draw = random.randint(1, 52) # Adjusted to generate numbers between 1 and 52 if draw <= 4: queens_count += 1 return queens_count

i18, Multiply Function Write a function called multiply that takes two arguments and returns their product. Only your function will be graded.

def multiply(a,b): return a * b multiply(10,10)

Default Arguments in Python You are given the task of creating a function called quiz that simulates randomly guessing on a quiz. The quiz has a default number of 12 true or false (T/F) questions. You know that the argument specified for this function is the number of questions (q). Which of the following correctly declares this function? def quiz(): def quiz(q): def quiz(q = 12): None of the above

def quiz(q = 12):

i1, rolling a six-sided die Write a function called rollDie that rolls a fair six-sided die and returns the result of the roll. Only your function will be graded.

def rollDie(): roll = random.randint(1,6) return roll

i6, A Function that Returns a Simulation Write a function called simulateDice that returns a simulation of rolling a sides sided die 10,000 times, with a default value of sides=6. Your simulation must store and return results in a DataFrame with a single column die, that contains a value between 1 and sides representing the possible rolls of the sides-sided die.

def simulateDice(sides = 6): data = [] for i in range(10000): roll = random.randint(1,sides) d = {"die": roll} data.append(d) df = pd.DataFrame(data) return df

Eligible Voters Write a function called voting_eligibility that takes one argument, an individual's age, and returns whether or not they are eligible to vote in the United States (18 or older). Specifically, voting_eligibility must return Eligible if the age is 18 or larger and must return Not Eligible if the age is 17 or younger.

def voting_eligibility(age): if age >= 18: return "Eligible" else: return "Not Eligible"


संबंधित स्टडी सेट्स

Pages 12-20 in study guide questions for Night

View Set

Securities Industry Essentials Exam

View Set

money and banking final ch 11-15

View Set

Leddy Professionalism Practice Questions

View Set

research STRAGITIES AND VALIDITY

View Set

Chapter 16, Outcome identification and planning

View Set

Songs of Innocence and Experience

View Set

Chapter 12 med coding and billing

View Set

Income Tax Planning 2022 Midterm

View Set

Evolve - Chapter 29 (Fluid and Electrolytes)

View Set