Checkpoint B In this checkpoint, we simulate groups of individuals playing the lottery. The final goal will be simulating two groups (a high-income group and a low-income group) and the movement of wealth across these. For example, we might represent one group of 5 individuals and their wealth by the list [2,3,4,5,6]. If this population plays (and loses) the lottery 2 times: It could become [0,3,4,5,6], if the first individual played twice Or it could become [2,3,4,4,5], if the last two individuals each played once ● etc ● Continuing the example, scholarships might then award a total of $3 of awards to the population in the form of $1 scholarships. If the wealth had originally been [0,3,4,5,6], then: It could become[3,3,4,5,6], if the 1st individual got all three awards Or it could become [0,4,5,5,7], if it was distributed equally among the 2nd, 3rd, and 5th individuals ● etc . We assume the lottery system is backed by a relatively huge pool of capital, so that scholarships are awarded no matter how many lottery winners there are. We also assume who plays the lottery and who benefits from scholarships will be random, at the individual-level. Later, at the population-level, we will select behaviors for our simulation based on social science research. The function generate_disparity_msg() returns a string summarizing the distribution of wealth. Here are examples of that analysis: highIncomeList . [2,3,4,5,6] ● [5, 6, 10, 14] ● lowIncomeList [6,5,4,3,2] [1, 5, 7, 2] msg = f"Decade (decade}: High income group " +\ [4, 10, 2, 5, 8] [2, 7] Implementation Strategy Implement each function from the template following the description in their docstring: • sim_lottery() • award_scholarship() • generate_disparity_msg() For the messages returned by generate_disparity_msg(), adapt this fstring for your code: Wealth Distribution High income: 50% of wealth Low income: 50% of wealth High income: 70% of wealth Low income: 30% of wealth High income: 76% of wealth Low income: 24% of wealth Again, by default, this project does not generate any interesting printed output. So, you should use one of these strategies in your work: Use Python Tutor to do incremental development, focusing on one function at a time in isolation Invent some of your own intermediate output, to get feedback while in develop mode Submit your work to get feedback from unit tests f"has (highIncome Percent:.0f)% of the community's wealth. "+\ f"Low income group has {lowIncome Percent:.0f}* "+\ f"of the community's wealth."
Checkpoint B In this checkpoint, we simulate groups of individuals playing the lottery. The final goal will be simulating two groups (a high-income group and a low-income group) and the movement of wealth across these. For example, we might represent one group of 5 individuals and their wealth by the list [2,3,4,5,6]. If this population plays (and loses) the lottery 2 times: It could become [0,3,4,5,6], if the first individual played twice Or it could become [2,3,4,4,5], if the last two individuals each played once ● etc ● Continuing the example, scholarships might then award a total of $3 of awards to the population in the form of $1 scholarships. If the wealth had originally been [0,3,4,5,6], then: It could become[3,3,4,5,6], if the 1st individual got all three awards Or it could become [0,4,5,5,7], if it was distributed equally among the 2nd, 3rd, and 5th individuals ● etc . We assume the lottery system is backed by a relatively huge pool of capital, so that scholarships are awarded no matter how many lottery winners there are. We also assume who plays the lottery and who benefits from scholarships will be random, at the individual-level. Later, at the population-level, we will select behaviors for our simulation based on social science research. The function generate_disparity_msg() returns a string summarizing the distribution of wealth. Here are examples of that analysis: highIncomeList . [2,3,4,5,6] ● [5, 6, 10, 14] ● lowIncomeList [6,5,4,3,2] [1, 5, 7, 2] msg = f"Decade (decade}: High income group " +\ [4, 10, 2, 5, 8] [2, 7] Implementation Strategy Implement each function from the template following the description in their docstring: • sim_lottery() • award_scholarship() • generate_disparity_msg() For the messages returned by generate_disparity_msg(), adapt this fstring for your code: Wealth Distribution High income: 50% of wealth Low income: 50% of wealth High income: 70% of wealth Low income: 30% of wealth High income: 76% of wealth Low income: 24% of wealth Again, by default, this project does not generate any interesting printed output. So, you should use one of these strategies in your work: Use Python Tutor to do incremental development, focusing on one function at a time in isolation Invent some of your own intermediate output, to get feedback while in develop mode Submit your work to get feedback from unit tests f"has (highIncome Percent:.0f)% of the community's wealth. "+\ f"Low income group has {lowIncome Percent:.0f}* "+\ f"of the community's wealth."
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
100%
I need help answering this question in python
![Checkpoint B
In this checkpoint, we simulate groups of individuals playing the lottery. The final goal will be simulating two groups (a high-income group
and a low-income group) and the movement of wealth across these.
For example, we might represent one group of 5 individuals and their wealth by the list [2,3,4,5,6].
If this population plays (and loses) the lottery 2 times:
It could become [0,3,4,5,6], if the first individual played twice
Or it could become [2,3,4,4,5], if the last two individuals each played once
etc
Continuing the example, scholarships might then award a total of $3 of awards to the population in the form of $1 scholarships. If the
wealth had originally been [0,3,4,5,6], then:
It could become[3,3,4,5,6], if the 1st individual got all three awards
Or it could become [0,4,5,5,7], if it was distributed equally among the 2nd, 3rd, and 5th individuals
etc
We assume the lottery system is backed by a relatively huge pool of capital, so that scholarships are awarded no matter how many lottery
winners there are. We also assume who plays the lottery and who benefits from scholarships will be random, at the individual-level. Later, at
the population-level, we will select behaviors for our simulation based on social science research.
The function generate_disparity_msg() returns a string summarizing the distribution of wealth. Here are examples of that analysis:
highIncomeList
[2,3,4,5,6]
[5, 6, 10, 14]
msg=f"Decade
lowIncome List
[6,5,4,3,2]
[1, 5, 7, 2]
[4, 10, 2, 5, 8] [2, 7]
Wealth Distribution
High income: 50% of wealth
Low income: 50% of wealth
High income: 70% of wealth
Low income: 30% of wealth
High income: 76% of wealth
Low income: 24% of wealth
Implementation Strategy
Implement each function from the template following the description in their docstring:
sim_lottery()
• award_scholarship()
generate_disparity_msg()
For the messages returned by generate_disparity_msg(), adapt this fstring for your code:
High income group "+\
f"has {highIncome Percent:.0f) of the community's wealth. "+\
f"Low income group has {lowIncome Percent:.0f} "+\
f"of the community's wealth."
Again, by default, this project does not generate any interesting printed output. So, you should use one of these strategies in your work:
Use Python Tutor to do incremental development, focusing on one function at a time in isolation
Invent some of your own intermediate output, to get feedback while in develop mode
Submit your work to get feedback from unit tests](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe01cbe9c-c6ce-406b-a6a1-8d45f039166c%2F699d4e76-adaa-4f5d-b7dd-ce96988cf480%2Fsrt0s8n_processed.png&w=3840&q=75)
Transcribed Image Text:Checkpoint B
In this checkpoint, we simulate groups of individuals playing the lottery. The final goal will be simulating two groups (a high-income group
and a low-income group) and the movement of wealth across these.
For example, we might represent one group of 5 individuals and their wealth by the list [2,3,4,5,6].
If this population plays (and loses) the lottery 2 times:
It could become [0,3,4,5,6], if the first individual played twice
Or it could become [2,3,4,4,5], if the last two individuals each played once
etc
Continuing the example, scholarships might then award a total of $3 of awards to the population in the form of $1 scholarships. If the
wealth had originally been [0,3,4,5,6], then:
It could become[3,3,4,5,6], if the 1st individual got all three awards
Or it could become [0,4,5,5,7], if it was distributed equally among the 2nd, 3rd, and 5th individuals
etc
We assume the lottery system is backed by a relatively huge pool of capital, so that scholarships are awarded no matter how many lottery
winners there are. We also assume who plays the lottery and who benefits from scholarships will be random, at the individual-level. Later, at
the population-level, we will select behaviors for our simulation based on social science research.
The function generate_disparity_msg() returns a string summarizing the distribution of wealth. Here are examples of that analysis:
highIncomeList
[2,3,4,5,6]
[5, 6, 10, 14]
msg=f"Decade
lowIncome List
[6,5,4,3,2]
[1, 5, 7, 2]
[4, 10, 2, 5, 8] [2, 7]
Wealth Distribution
High income: 50% of wealth
Low income: 50% of wealth
High income: 70% of wealth
Low income: 30% of wealth
High income: 76% of wealth
Low income: 24% of wealth
Implementation Strategy
Implement each function from the template following the description in their docstring:
sim_lottery()
• award_scholarship()
generate_disparity_msg()
For the messages returned by generate_disparity_msg(), adapt this fstring for your code:
High income group "+\
f"has {highIncome Percent:.0f) of the community's wealth. "+\
f"Low income group has {lowIncome Percent:.0f} "+\
f"of the community's wealth."
Again, by default, this project does not generate any interesting printed output. So, you should use one of these strategies in your work:
Use Python Tutor to do incremental development, focusing on one function at a time in isolation
Invent some of your own intermediate output, to get feedback while in develop mode
Submit your work to get feedback from unit tests
![1 def sim_lottery (incomeList, numPlays):
2
3
SAWI
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""Uses play_lottery_once() to simulate the lottery for some list of
indivudals from an income group. Within that group, the total
number of lottery plays are numPlays (of course, some individuals
might play multiple times). For each lottery ticket, the simulation
picks a random individual from the incomeList and adds the game.
reward to that individual's wealth.
69
70
Parameters:
incomeList (list): wealth values for the given income group
numPlayers (int): the number of players who will play the lottery
Returns: None
for i in range(numPlays):
# YOUR CODE HERE
pass
def award_scholarship(incomeList, awardTotal):
"""Redistributes funds from the lottery in the form of a scholarship.
Select a random recipient from the income group list. Each recipient
receives $1 added to their indivual wealth.
Parameters:
incomeList (list): indivual wealth values for the income group
awardTotal (int): total amount of lottery funds to be rewarded
to members of this income group
Returns: None
www
for i in range (awardTotal):
# YOUR CODE HERE
pass
def generate_disparity_msg(high IncomeList, lowIncomeList, decade):
"""Generates a string that describes the percentages of wealth
possessed by the higher income half and lower income half for any
given year.
Parameters:
high IncomeList (list): list of weath of individuals
lowIncomeList (list): list of weath of individuals
decade (int): a number indicating the decade
Returns:
str: The string with a message about the wealth disparity
50
51 if _name == __main__":
52
www
pass
seed = int(input('Enter a seed for the simulation: '))
random.seed (seed)
# data about each population's wealth
low_income_group= [50,50,50,50,50]
high income_group = [100,100,100,100,100]
# each group plays the lottery, some amount of times
sim_lottery (low_income_group, 3)
sim_lottery (high_income_group, 1)
# each group is awarded scholarships, in some amount
award scholarship(high_income_group, 5)
award scholarship(low_income_group, 2)
m = generate_disparity_msg(high_income_group, low_income_group)
print(m)](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe01cbe9c-c6ce-406b-a6a1-8d45f039166c%2F699d4e76-adaa-4f5d-b7dd-ce96988cf480%2F56ndldk_processed.png&w=3840&q=75)
Transcribed Image Text:1 def sim_lottery (incomeList, numPlays):
2
3
SAWI
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""Uses play_lottery_once() to simulate the lottery for some list of
indivudals from an income group. Within that group, the total
number of lottery plays are numPlays (of course, some individuals
might play multiple times). For each lottery ticket, the simulation
picks a random individual from the incomeList and adds the game.
reward to that individual's wealth.
69
70
Parameters:
incomeList (list): wealth values for the given income group
numPlayers (int): the number of players who will play the lottery
Returns: None
for i in range(numPlays):
# YOUR CODE HERE
pass
def award_scholarship(incomeList, awardTotal):
"""Redistributes funds from the lottery in the form of a scholarship.
Select a random recipient from the income group list. Each recipient
receives $1 added to their indivual wealth.
Parameters:
incomeList (list): indivual wealth values for the income group
awardTotal (int): total amount of lottery funds to be rewarded
to members of this income group
Returns: None
www
for i in range (awardTotal):
# YOUR CODE HERE
pass
def generate_disparity_msg(high IncomeList, lowIncomeList, decade):
"""Generates a string that describes the percentages of wealth
possessed by the higher income half and lower income half for any
given year.
Parameters:
high IncomeList (list): list of weath of individuals
lowIncomeList (list): list of weath of individuals
decade (int): a number indicating the decade
Returns:
str: The string with a message about the wealth disparity
50
51 if _name == __main__":
52
www
pass
seed = int(input('Enter a seed for the simulation: '))
random.seed (seed)
# data about each population's wealth
low_income_group= [50,50,50,50,50]
high income_group = [100,100,100,100,100]
# each group plays the lottery, some amount of times
sim_lottery (low_income_group, 3)
sim_lottery (high_income_group, 1)
# each group is awarded scholarships, in some amount
award scholarship(high_income_group, 5)
award scholarship(low_income_group, 2)
m = generate_disparity_msg(high_income_group, low_income_group)
print(m)
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education