Nayini01467237_HW4
.pdf
keyboard_arrow_up
School
George Mason University *
*We aren’t endorsed by this school
Course
409
Subject
Computer Science
Date
Dec 6, 2023
Type
Pages
1
Uploaded by CountWombatPerson996
HW #4 (
total: 50 pts
)
This homework primarily focuses on Descriptive Statistics and Data Visualization in Python.
Note:
(1) This is an individual assignment. It accounts for 12% of your grade.
(2)
Due Date: November 20th, 2023 Monday 7
:
20
:
59pm.
(3)
Make sure to run your code for each cell so that the output/result is visible underneath each code cell.
Do not create any new cells on this notebook file.
(4)
Submissions: you need to submit your completed Jupyter Notebook file (.ipynb) AND a PDF version of your completed Jupyter Notebook to Blackboard. **Both files must be uploaded using one
Blackboard submission (these are not to be submitted separately using two submissions)**.
Please make sure that the PDF file shows the output of each code cell prior to submitting your files to the
system. Submissions without the PDF file as instructed will result in a grade penality of 25%.
Part 0: Get Ready
(1 pts)
T0-1:
First, rename this Jupter Notebook file exactly as your last name followed by your G number without “G” and then followed by suffix “_HW4”. There should not be extra spaces or
underlines in between. For example, the Jupyter Notebook file you submit should be like Ye12345678_HW4.ipynb. Same applies to the PDF version of the file. You will complete the tasks below on this
Jyputer Notebook file, and then submit the completed the Jupyter Notebook file as well as the PDF version of the Juputer Notebook file.
(1 pts)
T0-2:
Run the cell below.
/Users/wadeyy03/Downloads
Part 1: Descriptive Statistics & Data Visualization - 1
In this part, you will continue to work with the dataset downloaded from the Virginia Department of Education (
https://www.doe.virginia.gov/data-policy-funding/data-reports
), you will import it into
DataFrame, and play with it to generate descriptive statistics and appropriate visualizations. The dataset shows the performance of public high schools in 2022 in three dimensions: Math, Science, and
Graduation Rate (some schools with missing data are excluded). An explanation of the variables (or columns) in the dataset is listed below:
Variable
Explanation
ZIP
zipcode of the school
School_Name
school name
Division
the division the school belongs to
Math_Pass_Rate
proportion of students who pass the math exam, a value of 50 means 50% students pass Math.
Science_Pass_Rate
proportion of students who pass the science exam, a value of 50 means 50% students pass Science.
Graduation_Rate
proportion of students who graduates, a value of 50 means 50% students graduate.
You need to download the csv file "
high_school_2022.csv
" provided on Blackboard and import it into a DataFrame first.
There are two ways to ensure the csv file is imported correctly.
1. Use the absolute file path. For example, if the full path of your file is *"C:/ipynb/HW/high_school_2022.csv"*, you are going to pass on this entire path with quotations as an argument in the
*read_csv()* function:
read_csv("C:/ipynb/HW/high_school_2022.csv")
2. copy the csv file to your current working directory (this is the output from T0-2), then you can do relative file path and just use the filename. For example, if T0-2 produces output
*"C:\Users\SY\Documents\ipynb"*, you are going to copy the csv file to the folder *"C:\Users\SY\Documents\ipynb"*, then you can just do:
read_csv("high_school_2022.csv")
(2 pts)
T1-1:
(To help you get you started and make sure the data is loaded correctly) Download the csv file "
high_school_2022.csv
", import the csv file into a DataFrame, print the first 7 rows, then
print the last 7 rows.
ZIP
School_Name
Division
Math_Pass_Rate
\
0
24263
Lee High
Lee County
74.43
1
24502
Brookville High
Campbell County
91.27
2
20124
Centreville High
Fairfax County
79.49
3
22712
Liberty High
Fauquier County
70.49
4
22655
Sherando High
Frederick County
78.28
5
22302
Alexandria City High
Alexandria City
46.35
6
24614
Grundy High
Buchanan County
86.87
Science_Pass_Rate
Graduation_Rate
0
65.27
79.67
1
73.82
91.46
2
77.36
89.61
3
65.71
90.00
4
76.96
92.70
5
49.47
80.26
6
62.30
85.57
==================================
ZIP
School_Name
Division
Math_Pass_Rate
\
319
23692
York River Academy
York County
90.00
320
23875
Prince George High
Prince George County
78.69
321
24641
Richlands High
Tazewell County
90.15
322
22847
Mountain View High
Shenandoah County
68.28
323
20148
Independence High
Loudoun County
83.33
324
20105
Lightridge High
Loudoun County
78.31
325
20164
W.O. Robey High
Loudoun County
78.31
Science_Pass_Rate
Graduation_Rate
319
95.24
89.47
320
76.93
89.68
321
82.52
87.15
322
63.97
90.16
323
81.90
98.22
324
82.77
100.00
325
82.77
100.00
(3 pts)
T1-2:
Which high school has the highest pass rate of Science
?
Use the appropriate DataFrame method(s) to display the result.
98.95
ZIP
22312
School_Name
Thomas Jefferson High for Science and Technology
Division
Fairfax County
Math_Pass_Rate
100.0
Science_Pass_Rate
98.95
Graduation_Rate
100.0
Name: 77, dtype: object
(4 pts)
T1-3:
Which high school in the Loudoun County division has the highest pass rate of Math
?
Use the appropriate DataFrame method(s) to display the result.
91.62
ZIP
20152
School_Name
Freedom High
Division
Loudoun County
Math_Pass_Rate
91.62
Science_Pass_Rate
90.23
Graduation_Rate
97.3
Name: 113, dtype: object
(4 pts)
T1-4:
For each division, what is the average pass rate of Math
?
and what is the average path rate of Science
?
Use appropriate DataFrame method(s) to print
one output
that answers both
questions.
Math_Pass_Rate
Science_Pass_Rate
Division
Accomack County
83.453333
72.373333
Albemarle County
70.880000
70.472500
Alexandria City
46.350000
49.470000
Alleghany County
78.880000
52.820000
Amelia County
75.320000
60.810000
...
...
...
Williamsburg-James City County
75.543333
74.640000
Winchester City
65.060000
62.360000
Wise County
93.183333
80.050000
Wythe County
93.016667
82.413333
York County
86.494000
83.760000
[130 rows x 2 columns]
(5 pts)
T1-5:
Overall, is there a positive or negative or no obvious relationship between pass rate of Math and pass rate of Science
?
Use an appropriate visualization to present a graph/plot to the
screen to help answer this question.
Make sure the graph/plot has at least a meaningful title, and meaningful descriptions of the horizontal axis and the vertial axis. Then based on the graph,
use
print()
to print a statement that explains your answer to the question.
In Majority of the Schools the Passing Rates of Maths and Science are Proportional in Nature.
(7 pts)
T1-6:
Focuses on these 4 divisions in Northern Virginia only: Fairfax County, Loudoun County, Arlington County, and Prince William County. How does the graduation rate of a division compare
to other divisions
?
Use an appropriate visualization to present a graph/plot to the screen to help answer this question.
Make sure the graph/plot has at least a meaningful title, and meaningful
descriptions of the horizontal axis and the vertial axis.
Division
Arlington County
80.400000
Fairfax County
85.161071
Loudoun County
95.626111
Prince William County
88.124167
Name: Graduation_Rate, dtype: float64
Part 2: Descriptive Statistics & Data Visualization - 2
In this part, you will import a dataset downloaded from Redfin (
https://www.redfin.com/news/data-center/
) into DataFrame, and play with it to generate descriptive statistics and appropriate
visualizations. The dataset shows the number of homes sold in each month from year 2018 to year 2022 for seven cities in the Fairfax county. An explanation of the variables (or columns) in the dataset
is listed below (most are self-explanatory):
Variable
Explanation
Year
year of each reported sales record
Month
numerical month of each reported sales record
Month_Name
(string) month name of each reported sales record
Quarter
(string) quarter of each reported sales record
City
city name
Active_Listings
number of houses listed for sale in the month
Homes_Sold
number of houses (in units) sold in the month
Median_Sale_Price
median sales price (
$
) of sold houses in the month
(2 pts)
T2-1:
(To help you get you started and make sure the data is loaded correctly) Download the csv file "
home_sales.csv
", import the csv file into a DataFrame, print the first 7 rows, then print the
last 7 rows.
Year
Month Month_Name Quarter
City
Active_Listings
Homes_Sold
\
0
2018
1
January
Q1
Arlington
599
165
1
2018
1
January
Q1
Centreville
121
68
2
2018
1
January
Q1
Fairfax
182
59
3
2018
1
January
Q1
Herndon
78
20
4
2018
1
January
Q1
McLean
220
54
5
2018
1
January
Q1
Oakton
92
36
6
2018
1
January
Q1
Vienna
68
6
Median_Sale_Price
0
514000
1
374000
2
509000
3
460000
4
1127000
5
460000
6
619000
======================
Year
Month Month_Name Quarter
City
Active_Listings
Homes_Sold
\
413
2022
12
December
Q4
Arlington
473
142
414
2022
12
December
Q4
Centreville
99
41
415
2022
12
December
Q4
Fairfax
95
47
416
2022
12
December
Q4
Herndon
53
18
417
2022
12
December
Q4
McLean
152
41
418
2022
12
December
Q4
Oakton
69
40
419
2022
12
December
Q4
Vienna
54
18
Median_Sale_Price
413
536000
414
470000
415
603000
416
605000
417
1499000
418
618000
419
1398000
(3 pts)
T2-2:
For each city, what is the average number of sold homes per month (i.e., for each city, the mean of all monthly records)
?
Use appropriate DataFrame method(s) to print the output that
answers this question. (Optional) you can also use the
.astype()
method to round up the values in a DataFrame or Series to integers: DataFrame_name.astype('int') or Series_name.astype('int').
City
Arlington
251
Centreville
91
Fairfax
81
Herndon
43
McLean
67
Oakton
50
Vienna
20
Name: Homes_Sold, dtype: int64
(4 pts)
T2-3:
For each month of each year, what is the average number of sold houses across all cities (i.e., for each month of each year, the mean of all monthly records including all cities)
?
Use
appropriate DataFrame method(s) to print the output that answers this question. (Optional) you can also use the
.astype()
method to round up the values in a DataFrame or Series to integers:
DataFrame_name.astype('int') or Series_name.astype('int').
Year
Month
Month_Name
2018
1
January
58
2
February
55
3
March
84
4
April
98
5
May
123
6
June
123
7
July
106
8
August
96
9
September
70
10
October
78
11
November
76
12
December
83
2019
1
January
58
2
February
56
3
March
72
4
April
101
5
May
113
6
June
109
7
July
102
8
August
92
9
September
76
10
October
73
11
November
63
12
December
75
2020
1
January
49
2
February
55
3
March
82
4
April
76
5
May
69
6
June
87
7
July
110
8
August
107
9
September
99
10
October
100
11
November
90
12
December
89
2021
1
January
63
2
February
77
3
March
103
4
April
123
5
May
125
6
June
134
7
July
123
8
August
107
9
September
95
10
October
98
11
November
94
12
December
91
2022
1
January
58
2
February
65
3
March
90
4
April
95
5
May
107
6
June
99
7
July
81
8
August
81
9
September
67
10
October
57
11
November
47
12
December
49
Name: Homes_Sold, dtype: int64
(7 pts)
T2-4:
What is the monthly trend of sold homes in the data, i.e., how does the average value of homes sold (across all cities and all years, i.e., there is one average for January, one average for
February, etc.) change from month to month
?
Use an appropriate visualization to present a graph/plot to the screen to help answer this question.
Make sure: (1) the graph/plot has a meaningful title,
and meaningful descriptions of the horizontal axis and the vertial axis; (2) the value for each year is clearly represented and marked in the graph/plot; (3) the ticks in the x-axis corresponds
exactly to the month.
Month
1
57
2
62
3
86
4
99
5
107
6
110
7
104
8
96
9
81
10
81
11
74
12
77
Name: Homes_Sold, dtype: int64
(7 pts)
T2-5:
In the class, we have learned using
.mean()
method to calcualte the average/mean of values. Similarly, you can use the
.sum()
method of DataFrame to do a sum of values to calculate
how many homes in total are sold for each city from 2018-2022 (the observation window of the data). What are the top 5 cities that have sold the most number of homes
?
Present the results both
numerically and visually
. Use appropriate DataFrame method(s) and an appropriate visualization to answer this question.
Make sure the graph/plot has at least a meaningful title, and meaningful
descriptions of the horizontal axis and the vertial axis.
For this task, you are also going to learn and use the
.nlargest()
method of DataFrame. First, read the code & comments below, and run the code to learn and understand the
.nlargest()
method.
Student
Score
3
Sarah
97
1
Mike
95
0
90
1
95
2
86
3
97
4
78
Name: Score, dtype: int64
<class 'pandas.core.series.Series'>
3
97
1
95
Name: Score, dtype: int64
Now write your Python code to complete the task T2-5. Again,
make sure the graph/plot has at least a meaningful title, and meaningful descriptions of the horizontal axis and the vertial axis.
City
Arlington
15101
Centreville
5516
Fairfax
4918
McLean
4055
Oakton
3029
Name: Homes_Sold, dtype: int64
End of Homework.
Once you have completed it and run all the cells, please remember to print the Jupyter Notebook file as a PDF file and submit it along with your Jupyter Notebook file, as both are required.
In [1]:
# Before you begin, run this cell with with the code provided below.
# This will print the current working directory
# This will also help you loate your Jupyter Notebook file on your computer
import
os
print
(
os
.
getcwd
())
In [8]:
import
pandas
as
pd
# T1-1 python solution code below
df
=
pd
.
read_csv
(
"high_school_2022.csv"
)
print
(
df
.
head
(
7
),
"\n"
)
print
(
'=================================='
)
print
(
df
.
tail
(
7
))
In [10]:
# T1-2 python solution code below
# What is the highest pass rate of Science among all schools? Print it.
print
(
df
[
'Science_Pass_Rate'
]
.
max
())
# Find the high school
df
.
loc
[
df
[
'Science_Pass_Rate'
]
.
idxmax
()]
Out[10]:
In [14]:
# T1-3 python solution code below
# What is the highest pass rate of Math among all schools in the Loudoun County division? Print it.
print
(
df
[
df
[
'Division'
]
==
'Loudoun County'
][
'Math_Pass_Rate'
]
.
max
())
# Find the school
df
.
loc
[
df
[
df
[
'Division'
]
==
'Loudoun County'
][
'Math_Pass_Rate'
]
.
idxmax
()]
Out[14]:
In [22]:
# T1-4 python solution code below
by_division
=
df
.
groupby
(
'Division'
)
Science_and_Maths_mean_by_division
=
by_division
[[
"Math_Pass_Rate"
,
"Science_Pass_Rate"
]]
.
mean
()
print
(
Science_and_Maths_mean_by_division
)
In [250…
import
matplotlib.pyplot
as
plt
# need it to present the graphs to the screen
# T1-5 python solution code below
# code for visualization below
df
.
plot
.
scatter
(
x
=
"Math_Pass_Rate"
,
y
=
"Science_Pass_Rate"
,
xlabel
=
"Maths Passing Rate"
,
ylabel
=
"Science Passing Rate"
,
title
=
"Scatter plot Science Pass Rate vs Maths Pass Ra
plt
.
show
()
# Once you have run the visualization code to see the graph,
# now add your code to print your answer/conclusion below, and run the entire cell again.
statement
=
"In Majority of the Schools the Passing Rates of Maths and Science are Proportional in Nature."
print
(
statement
)
In [251…
# T1-6 python solution code below
#County = ["Fairfax County","Loudoun County","Arlington County","Prince William County"]
#divisions_4 = df[df['Division'].isin(County)
divisions_4
=
df
[
df
[
'Division'
]
.
isin
([
"Fairfax County"
,
"Loudoun County"
,
"Arlington County"
,
"Prince William County"
])]
by_divisions
=
divisions_4
.
groupby
(
"Division"
)
mean_graduation_rate_by_division
=
by_divisions
[
"Graduation_Rate"
]
.
mean
()
print
(
mean_graduation_rate_by_division
)
mean_graduation_rate_by_division
.
plot
.
bar
(
x
=
"Divison"
,
y
=
"Graduation_Rate"
,
xlabel
=
"County Name"
,
ylabel
=
"Average Graduation Rate"
,
rot
=
10
,
title
=
"Average Graduation Rate by
plt
.
show
()
In [237…
import
pandas
as
pd
# T2-1 python solution code below
df1
=
pd
.
read_csv
(
"home_sales.csv"
)
print
(
df1
.
head
(
7
))
print
(
"\n ====================== \n"
)
print
(
df1
.
tail
(
7
))
In [252…
# T2-2 python solution code below
by_month_city
=
df1
.
groupby
([
'City'
])
#used "Month" in grouping as "Month_Name" is saved as a 'string' not a 'datetime' variable so grouping by "Month" gives order to the
avg_house_sold_by_month_city
=
by_month_city
[
"Homes_Sold"
]
.
mean
()
print
(
avg_house_sold_by_month_city
.
astype
(
'int'
))
In [253…
# T2-3 python solution code below
by_year_month
=
df1
.
groupby
([
"Year"
,
"Month"
,
"Month_Name"
])
#used "Month" in grouping as "Month_Name" is saved as a 'string' not a 'datetime' variable so grouping by "Mont
avg_houses_sold
=
by_year_month
[
"Homes_Sold"
]
.
mean
()
print
(
avg_houses_sold
.
astype
(
'int'
))
In [254…
import
matplotlib.pyplot
as
plt
# need it to present the graphs to the screen
# T2-4 python solution code below
months
=
[
"January"
,
"February"
,
"March"
,
"April"
,
"May"
,
"June"
,
"July"
,
"August"
,
"September"
,
"October"
,
"November"
,
"December"
]
homes
=
df1
.
groupby
([
"Month"
])[
"Homes_Sold"
]
.
mean
()
.
astype
(
'int'
)
print
(
homes
)
homes
.
plot
.
line
(
x
=
"Month"
,
y
=
"Homes_Sold"
,
figsize
=
(
10
,
10
),
marker
=
'x'
,
color
=
'Red'
,
rot
=
45
)
plt
.
xticks
(
range
(
1
,
13
),
months
)
plt
.
show
()
In [255…
# An example of .nlargest() method
# Read the code, and run the code in this cell to learn the method.
import
pandas
as
pd
# df_a is a dataframe containing students and their scores.
df_a
=
pd
.
DataFrame
(
{
"Student"
: [
"Taylor"
,
"Mike"
,
"John"
,
"Sarah"
,
"Julie"
],
'Score'
: [
90
,
95
,
86
,
97
,
78
]
}
)
# .nlargest() on a DataFrame
# print the rows with the two largest values in the Score column in desending order
print
(
df_a
.
nlargest
(
2
,
'Score'
))
# the above should print the row for Sarah with a score 97, and then the row for Mike with a score of 95
print
()
# .nlargest() can also be used on a Series, which has only one column of data
score
=
df_a
[
'Score'
]
# select a single column from the DataFrame, it returns a Series
print
(
score
)
print
(
type
(
score
))
# .nlargest() on a Series
print
(
score
.
nlargest
(
2
))
# because there is only one column in a Series, you do not need to specify column name
# the above should print row 3 with score 97 and row 1 with score 95
In [256…
# T2-5 python solution code below
by_city
=
df1
.
groupby
(
"City"
)
homes_sold_by_city
=
by_city
[
"Homes_Sold"
]
.
sum
()
print
(
homes_sold_by_city
.
nlargest
(
5
))
bar
=
homes_sold_by_city
.
nlargest
(
5
)
.
plot
.
bar
(
x
=
'City'
,
y
=
'Homes_Sold'
,
title
=
'Top 5 Cities with Most Homes Sold (2018-2022)'
,
ylabel
=
'Homes Sold'
,
xlabel
=
'City'
,
legend
=
False
,
rot
=
45
)
bar
.
bar_label
(
bar
.
containers
[
0
])
plt
.
show
()
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Programming in c language
arrow_forward
Create a simple program for a quiz
Software Requirements:
Latest version of NetBeans IDE
Java Development Kit (JDK) 8
Procedure:
Create a folder named LastName_FirstName (ex. Dahan yoon) in your local
Create a new project named LabExer5B. Set the project location to your own
The program shall:
contain an array of 10 multiple choice questions with three (3) choices each and
require the user to choose among A, B, or C;
Note: Cases are ignored. Lowercase letters are acceptable (a, b, c).
Create a try-catch structure to handle three (3) exceptions. These are when the user inputs the following:
an invalid letter (not A, B, or C)
a number or any special character
blank (no answer)
Prompt the user that he can answer again if any of the three (3) exceptions is
Display the score.
arrow_forward
VBA PROBLEM:
Create a code where every time that only cell B1 is changed, create a new tab and that this tab is renamed with the value that is entered in B1 and the other cells, that is, B2: B11 have the same values that are entered in the Sheet1. The values of A1: A11 must always remain the same. Like in the examples below (image 1 and 2).
arrow_forward
The last element of the array is 7.6 and is at position 7 There is no middle of the array since the array's length is even The largest element of the array is 54.3 and is at position 6 The smallest element of the array is 2.5 and is at position 1 Tip: Divide up the tasks among a few methods.
arrow_forward
use windows form app
arrow_forward
Write a code segment that searches a Grid object for a negative integer. The loop should terminate at the first instance of a negative integer in the grid, and the variables row and column should be set to the position of that integer. Otherwise, the variables row and column should equal the number of rows and columns in the grid.
*Python
arrow_forward
Overview: Create a coin flip game that allows the user to guess whether the coin will be heads or tails. Save the data associated with the flip. Repeat for a total of 10 guesses/flips. Display result summary and details at end.
Technical Requirements:
Participant will guess whether a coin flip will result in Heads or Tails
Computer will "flip" a coin to determine the side it lands using random generator
import random at top of program
result = random.randint(x,x)
The program will display the results: Guess, Flip, Outcome (Match or No Match)
The program will track the results and, when the game is over, display:
Summary
Detailed result of each turn
Use parallel arrays to collect details from each turn that can be displayed as a table when the game is over
Use running totals of each result detail to display at end
arrow_forward
Need help with coding this in python using tkinter
Write a GUI program to let the user enter a file name from an entry field and then count the number of occurrences of each letter in that file.
Clicking theShow Result button displays the result in a text widget. You need to displaya message in a message box if the file does not exist.
https://www.bartleby.com/questions-and-answers/need-help-with-coding-this-in-python-using-tkinter-write-a-gui-program-to-let-the-user-enter-a-file-/153862b8-6d38-47a4-bd38-9c66882021d1
arrow_forward
PLEASE COMMENT CODE
In a python program, create a new file and call it “ tracking”. Write to it four lines each contains information about an order like this:
1-00654-021 Dell charger Toronto-WEST 99-49-ZAD011-76540-022 ASUS battery Milton-EAST 34-56-CBH561-09239-026 HP HD Scarborough-NORTH 12-98-AZC451-12349-029 Mac FD North York-LAWRENCE 34-49-ZWL01Add the file two more lines: 1-34567-055 Lenovo SSD Milton-ON 34-09-MT04 1-90432-091 Lenovo battery Oakville-ON 78-KL98
Define a function that searches for a brand (e.g. Dell, ASUS, etc.). Test the function in your program.
arrow_forward
Programming Fundamentals
Spring 2020 - 2021
Practical Exam 1
Weight 7 marks
Date 19/05/2021
Write a java program that reads one number, and display your full name many
times as the number is read.
Exam submission instructions:
1- You must submit the file with ".java" extension.
2- You must submit a video that record your computer screen when you are writing the
program. The video must be uploaded to google drive then add video link with
assignment submission. The assignment will not be marked without screen recording
video.
of
arrow_forward
.Rprofile - the first chunk of code executed
arrow_forward
2- Assume that you are developer for photogrammetry and image processing in a
company. You are given a task to develop a method that deals with the objects in a
scene. Assume that a camera captured binary images, as shown below. The objects
do not overlap or not in contact, but may be close to each other. They can be in any
size or shape.
Binary image
Write the pseudo-code algorithm that automatically counts only the number of objects
with hole(s) and the shape of the object is not circle. Also present a block diagram of
your algorithm to make easy to understand your answer. If there any, please also
define any assumptions you perform in your algorithm (about the
size/shape/tone/hole etc. of the object).
code!)
(No need to implement a python
arrow_forward
Python
arrow_forward
5.PYTHON Programming language
Turtle Graphics: Hypnotic Pattern Use a loop with the turtle graphics library to draw the design
shown. Use named constants and inputs from the user. Perform input validation of the user inputs. • Set
the screen to 600 x 600 pixels (constant) • Draw the square in a 400 x 400 pixel area (constant) Put a red
dot counter at the the start and top right corner every three squares (constant) • Ask user to input a number
of squares 5 to 15 and validate • Ask user to input a pen color "black", "blue", "green", and validate • Bonus:
arrow_forward
PYTHON:
In this assignment, you will use all of the graphics commands you have learned to create an animated scene. Your program should have a clear theme and tell a story. You may pick any school-appropriate theme that you like.
The program must include a minimum of:
5 circles
5 polygons
5 line commands
2 for loops
1 global variable
You may wish to use the standard code for simplegui graphics below:
import simplegui def draw_handler(canvas): frame = simplegui.create_frame('Testing', 600, 600)
frame.set_canvas_background("Black")
frame.set_draw_handler(draw_handler)
frame.start()
arrow_forward
Create C# (Sharp) code using visual studio:
Use Delegate methodology to do the following project:
Have a Add method, Subtract method, Multiply method, Divide method. Each method will loop 100 times. With each iteration, generate two random numbers (between 1 - 50), then perform the math operation (add for the Add method, subtract for the Subtract method, etc.). Make sure to display the numbers and the answer!
One validation check - for subtraction and division, make sure the higher number generated comes first in the calculation. For example, if 12 and 40 are the numbers generated, the math should be 40 -12 for the subtraction (not 12 - 40) and 40/12 for the division (not 12/40).
Again, make sure to use Delegates!
arrow_forward
File names: color_square.py, chessboard.py, test_squares.py
Positions on a chess board are identified by a letter and a number. The letter identifies the column; the number identifies the row. See the image below.
You will provide the functions that allow us to determine:
if a chessboard square is either black or white, given its coordinates.
If the row/column is valid or not for the standard chessboard
For example, if we pass in “d” for the column and 4 for the row, your function that determines color should return the string: “BLACK”. If we pass in "k" for the column to your function that validates columns, that function should return the boolean False.
Requirements:
Your function for validating the column should be able to accept upper or lowercase strings as parameters.
Your functions for validating the row should be able to accept integers or strings as parameters.
Your function that determines black-or-white may assume that the input has been validated prior to us calling…
arrow_forward
Debugging - Run the code and find the problems
Run the code and see what is happening.
Complete the template in the file, explaining: the problems (just bugs) you find AND your process for debugging.
Then, fix the code in place. In addition to correcting the problems, improve this code (names, formatting, principles, etc.)
Code is :
"""CP1401 - Practical 10 - Debugging.
Explain the problems (not the solution, not the style issues):
fill answer here
Describe your debugging process:
fill answer here
Fix the code in-place below
fill answer here
Code :
import random
VALID_CHOICES = 'AC'
CONSERVATIVE_CHANCE = 40
CONSERVATIVE_REWARD = 50
AGGRESSIVE_CHANCE = 10
AGGRESSIVE_REWARD = 80
def main():
money = 100
print("Welcome to the futility of gambling!")
print("You start with a balance of $100.")
while money > 0:
result = play(money)
money = money + result
print(f"Your new balance is ${money}")
print("You lost :)")
def…
arrow_forward
Calculate average test score:
Write a program that reads 10 test scores in an array named testScores. Then pass this array to a function to calculate the average test scores, return the average to main function and display it.
Input Validation: The test scores should be between 0 and 100 (inclusive).
Add comments and version control.
arrow_forward
VB Small Project 19 – Numbers From a File
Using the program from Small Project 18, create a file that contain the numbers 5, 10, 15, 20, and 25.
Write a Visual Basic program that reads those numbers from the file. Calculate the average of the numbers and print it.
Name the text file this way: NameTextFile --- CooleyTextFile
arrow_forward
***Please write code suitable for Myprogramminglab below:
If you have downloaded the source code from this book's companion web site, youwill find the following files in the Chapter 07 folder:• GirlNames.txt--This file contains a list of the 200 most popular names given togirls born in the United States from the year 2000 through 2009.• BoyNames.txt--This file contains a list of the 200 most popular names given toboys born in the United States from the year 2000 through 2009.Write a program that reads the contents of the two files into two separatelists, allows a user to input either a girl's name, a boy's name, orboth, then tells the user whether the name(s) was/were popular between 2000 and2009.First, the program should prompt the user to choose a girl's name, a boy's name,or both by entering either 'girl', 'boy', or 'both.'Once they have chosen, they should be able to input a name. If the name wasa popular name, like Jacob or Sophia, the program should print "Jacob was apopular…
arrow_forward
python
The intent of this program is to manage a set of contacts. Each contact will have data associated with it:
Id – number/integer
First Name – string
Last Name – string
Age – number/integer
Phone Number – string
Email – string
Anything else you’d like to add to make yours unique (can result in extra credit)
Gender – character or string (m/f/o)
Twitter ID, Facebook Id, etc
You must allow the customer to do the following actions on the contact list:
List all contacts
Add contact
Delete contact
Edit contact
Exit program
You should leverage a database (PostgreSQL) to save everything to the DB and read from it.
You should use classes for this assignment. This means you should have two classes:
Contact – all the attributes/properties described above with appropriate constructor. Methods:
Add (constructor - __init__(p_id, p_fname, p_lname, p_age, p_phone, p_email, p_gender)
Edit
Contact List (contact_list) – built on Python list (or creating one within the constructor), you…
arrow_forward
pic for input and output
fname = "https://runestone.academy/runestone/books/published/StudentCSP/_static/beach.jpg"
arrow_forward
Using python language, make a program (refer to the image).
arrow_forward
Python
arrow_forward
Finish this program from the code posted below! Note: There should be two files Main.py and Contact.py
You will implement the edit_contact function. In the function, do the following:
Ask the user to enter the name of the contact they want to edit.
If the contact exists, in a loop, give them the following choices
Remove one of the phone numbers from that Contact.
Add a phone number to that Contact.
Change that Contact's email address.
Change that Contact's name (if they do this, you will have to remove the key/value pair from the dictionary and re-add it, since the key is the contact’s name. Use the dictionary's pop method for this!)
Stop editing the Contact
Once the user is finished making changes to the Contact, the function should return.
Code:from Contact import Contactimport pickledef load_contacts():""" Unpickle the data on mydata.dat and save it to a dictionaryReturn an empty dictionary if the file doesn't exist """try:with open("mydata.dat", 'rb') as file:return…
arrow_forward
Rest of code in image
/ This is a bad programming style since it is using goto. // This is an spagetti code and not working.// Use function to display menu, and display game rules,// Use different color for text display.// fix it so it works any way you like./*HANDLE screen = GetStdHandle(STD_OUTPUT_HANDLE); // Write 16 lines in 16 different colors. for (int color = 0; color < 16; color++) { SetConsoleTextAttribute (screen, color); cout << " Hello World!" << endl; Sleep(400); // Pause between lines to watch them appear } // Restore the normal text color) SetConsoleTextAttribute(screen, 7);*/#include <iostream>#include <windows.h>using namespace std;int main(){ //textbackground(WHITE); //textcolor(RED); system("cls"); char ch, a[20], ch2; int num = 100, rnum, guess, count, ch1, c = 0; cout << "**********************************************************"<<endl; cout << "*…
arrow_forward
In PYTHON
Print values from the Goal column only
Print values only for columns: Team, Yellow Cards and Red Cards
Find and print rows for teams that scored more than 6 goals
Select the teams whose name start with a G
Print values only for columns Team and Shooting Accuracy , and only for rows in which the team is either of the following: England, Italy and Spain
Find and print rows for teams that scored more than 6 goals and at least 4000 passes
arrow_forward
Chapter 7 - Programming Challenge 15
15. World Series Champions If you have downloaded this book’s source code (the companion Web site is available at www.pearsonhighered.com/gaddis), you will find a file named WorldSeriesWinners.txt. This file contains a chronological list of the winning teams in the World Series from 1903 through 2009. (The first line in the file is the name of the team that won in 1903, and the last line is the name of the team that won in 2009. Note that the World Series was not played in 1904 or 1994, so those years are skipped in the file.) Write a program that lets the user enter the name of a team, and then displays the number of times that team has won the World Series in the time period from 1903 through 2009.
Tip: Read the contents of the WorldSeriesWinners.txt file into an ArrayList. When the user enters the name of a team, the program should step through the ArrayList, counting the number of times the selected team appears
You only need to submit the…
arrow_forward
Python question please include all steps and screenshot of code. Also please provide a docstring, and comments throughout the code, and test the given examples below. Thanks.(Use Table Below)
The following table lists various Python container types in the first column, andproperties that they may or may not have in the following columns. (Note: I havecompleted the table.) But if a question like this appears on the exam you will have tocomplete this table by writing YES in each cell if that data structure has that property, orNO if it does not
Ordered
Mutable
Iterable
Allows duplicate values
tuple
yes
no
yes
no
dictionary
no
yes
yes
no
set
no
no
yes
no
list
yes
yes
yes
yes
arrow_forward
Searching - a user should be able to search by ID or by item name
create only one menu item for searching
a user should be able to enter the name of the item using any case, (for example, sTRolleR)
you may wish to store items in all lower/upper case to expedite the search
write one search function that can search by ID and name and goes through the array of structs/objects only once
show the entire record if found or an appropriate message if not
Sorting - sort by any field
write one function to sort by any field using a parallel array of pointers
use Bubble Sort is not the most effective but the easiest to modify.
do not copy and paste sort code five times into the same function.
sorting using pointers is faster because you have to swap pointers only, which are normally stored in 4 bytes each; it also allows you to preserve the original order of the items
If you choose to have a submenu, a submenu must have an option to go back to the previous menu or main menu
if a user got…
arrow_forward
me
words
Insert
Chapter 8 example.docx-Word
View
Review
Design
Tell me what you want to do...
Layout
Mailings
References
Class A:
Int data1, data2
A(int d1,int d2)// initialize data1, data2
Int Add() // adds two numbers: data1, data2
0
Class B:
Data3
Int AddFromB(int d1,int d2, int d3)// adds three numbers {
Super(d1, d2)
Int s=Add()
Int sb=s+d3}
Suppose you have a class called A which have two integer
data(data1, data2) and a method Add() which returns
sammation of data1and data2.
Another class B has an integer data3 and a method AddFromB()
which adds data3 with the returned result of Add().
Now implement the above scenario and show the summation of
three integer numbers.
Ix
Sign in
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
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)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- Programming in c languagearrow_forwardCreate a simple program for a quiz Software Requirements: Latest version of NetBeans IDE Java Development Kit (JDK) 8 Procedure: Create a folder named LastName_FirstName (ex. Dahan yoon) in your local Create a new project named LabExer5B. Set the project location to your own The program shall: contain an array of 10 multiple choice questions with three (3) choices each and require the user to choose among A, B, or C; Note: Cases are ignored. Lowercase letters are acceptable (a, b, c). Create a try-catch structure to handle three (3) exceptions. These are when the user inputs the following: an invalid letter (not A, B, or C) a number or any special character blank (no answer) Prompt the user that he can answer again if any of the three (3) exceptions is Display the score.arrow_forwardVBA PROBLEM: Create a code where every time that only cell B1 is changed, create a new tab and that this tab is renamed with the value that is entered in B1 and the other cells, that is, B2: B11 have the same values that are entered in the Sheet1. The values of A1: A11 must always remain the same. Like in the examples below (image 1 and 2).arrow_forward
- The last element of the array is 7.6 and is at position 7 There is no middle of the array since the array's length is even The largest element of the array is 54.3 and is at position 6 The smallest element of the array is 2.5 and is at position 1 Tip: Divide up the tasks among a few methods.arrow_forwarduse windows form apparrow_forwardWrite a code segment that searches a Grid object for a negative integer. The loop should terminate at the first instance of a negative integer in the grid, and the variables row and column should be set to the position of that integer. Otherwise, the variables row and column should equal the number of rows and columns in the grid. *Pythonarrow_forward
- Overview: Create a coin flip game that allows the user to guess whether the coin will be heads or tails. Save the data associated with the flip. Repeat for a total of 10 guesses/flips. Display result summary and details at end. Technical Requirements: Participant will guess whether a coin flip will result in Heads or Tails Computer will "flip" a coin to determine the side it lands using random generator import random at top of program result = random.randint(x,x) The program will display the results: Guess, Flip, Outcome (Match or No Match) The program will track the results and, when the game is over, display: Summary Detailed result of each turn Use parallel arrays to collect details from each turn that can be displayed as a table when the game is over Use running totals of each result detail to display at endarrow_forwardNeed help with coding this in python using tkinter Write a GUI program to let the user enter a file name from an entry field and then count the number of occurrences of each letter in that file. Clicking theShow Result button displays the result in a text widget. You need to displaya message in a message box if the file does not exist. https://www.bartleby.com/questions-and-answers/need-help-with-coding-this-in-python-using-tkinter-write-a-gui-program-to-let-the-user-enter-a-file-/153862b8-6d38-47a4-bd38-9c66882021d1arrow_forwardPLEASE COMMENT CODE In a python program, create a new file and call it “ tracking”. Write to it four lines each contains information about an order like this: 1-00654-021 Dell charger Toronto-WEST 99-49-ZAD011-76540-022 ASUS battery Milton-EAST 34-56-CBH561-09239-026 HP HD Scarborough-NORTH 12-98-AZC451-12349-029 Mac FD North York-LAWRENCE 34-49-ZWL01Add the file two more lines: 1-34567-055 Lenovo SSD Milton-ON 34-09-MT04 1-90432-091 Lenovo battery Oakville-ON 78-KL98 Define a function that searches for a brand (e.g. Dell, ASUS, etc.). Test the function in your program.arrow_forward
- Programming Fundamentals Spring 2020 - 2021 Practical Exam 1 Weight 7 marks Date 19/05/2021 Write a java program that reads one number, and display your full name many times as the number is read. Exam submission instructions: 1- You must submit the file with ".java" extension. 2- You must submit a video that record your computer screen when you are writing the program. The video must be uploaded to google drive then add video link with assignment submission. The assignment will not be marked without screen recording video. ofarrow_forward.Rprofile - the first chunk of code executedarrow_forward2- Assume that you are developer for photogrammetry and image processing in a company. You are given a task to develop a method that deals with the objects in a scene. Assume that a camera captured binary images, as shown below. The objects do not overlap or not in contact, but may be close to each other. They can be in any size or shape. Binary image Write the pseudo-code algorithm that automatically counts only the number of objects with hole(s) and the shape of the object is not circle. Also present a block diagram of your algorithm to make easy to understand your answer. If there any, please also define any assumptions you perform in your algorithm (about the size/shape/tone/hole etc. of the object). code!) (No need to implement a pythonarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
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)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education