Data 8R Summer 2017

Data Types and Arrays Discussion 4: July 6, 2017

The squirrels of UC Berkeley have decided to have a faceoff with the squirrels at Stanford. Its up to you to make sure that our squirrels are prepared with the most important knowledge before they head out!

1

A Test of Skill

Before they allow you to help them, the squirrels want to make sure that you’re up for the task. Answer their questions to pass their inspection! 1.1

Ints, Floats, and Strings Impress the squirrels with your knowledge of data types! Print the outputs (or errors) of the following lines of Python code! >>> 6 / 3

>>> round(2 / 3, 2)

>>> "42".replace("4", "ans").replace("2", "wer").upper()

>>> "Doggo" + "Squirrel"

>>> 1337 + "Squirrel"

2

1.2

Data Types and Arrays

Diagram review The squirrels want you to diagram the following expression. Show them what you got! >>> add(15, sub(mul(round(5), 3), 2))

1.3

To be, or None to be As a final question, the squirrels want you to prove you know the difference between prints and outputs. Show them your skills! >>> x = "Wassup?" >>> print(x) >>> x

2 2.1

Organize the data!

Make some arrays! The squirrels have a bunch of data about some neutral squirrels in the Bay Area. Firstly, they want you to put all the data about distance to UC Berkeley in an array assigned to dst to berk. Then, they want to you to put all the data about cleverness score in an array assigned to cleverness.

Write down the code to conduct this request!

Data Types and Arrays

2.2

3

Arraying the Forces Now the Squirrels want you to put data about the various populations into a collective array. Put the population of Berkeley squirrels, Stanford squirrels, and neutral squirrels into an array, in that order. Assign the array to the variable forces.

Write down the code to make such an array!

2.3

Indexing into the Array Now the squirrels want to know the smallest absolute difference in population between the three groups. Index into the forces array that you just made to find the smallest difference between the squirrel populations of Berkeley, Stanford, and the neutrals. Remember, we can index into an array by using the method .item: >>> forces.item(0) ... 20

Fill in the missing code:

>>> min(_________________________, _________________________, _________________________)

4

3 3.1

Data Types and Arrays

Visualizing the Forces

Population Bar Chart! The Squirrels have a difficult task for you: create a bar chart from the population data. Luckily, they’ve supplied a function named bar(labelArray, dataArray) to do the graphing. The bar function takes in two inputs: a labelArray, which contains the names of the bars in the chart, and a dataArray, which contains the value of each label to be charted. You will have to create the label array (which should consist of the values Berkeley, Stanford, and Neutral). Use the forces array that you’ve already created to supply the data. Remember that the values should match up - we want the values in the data array to correspond with the correct locations. The final graph is displayed below. Write your code here!

Data Types and Arrays

3.2

5

Scatter the Cleverness Data Now the squirrels want you to create a scatter plot of the cleverness data. Luckily, they’ve created a function called scatter(xArray, yArray), that will create the scatter plot for you. Use the arrays that you’ve created from before to create the scatter plot, using the distance to berkeley data as the x, and the cleverness score data as the y. The final graph is displayed below. Write your code here!

6

4 4.1

Data Types and Arrays

Data Manipulation

Calculations: Calculations Calculations The squirrels now want you to calculate a couple of values for them. Fill in the code you would use beneath each value. Remember to use array methods! The product of all the values in the dst to berk array >>> dstProd = __________

The product of all cleverness score values: >>> cleverProd = __________

The length of both arrays: >>> dstLen = __________ >>> cleverLen = __________

Now the squirrels want you to invert the lengths (Hint: To invert a number, use 1 number >>> dstLenInverted = __________ >>> cleverLenInverted = __________

The squirrels want you to calculate the value of the products to the power of the lengths inverted: >>> finalValueDist = __________ >>> finalValueClever = __________

Note: Those tricky squirrels got you to calculate the geometric mean, which is another measure of ”the center” of some data.

Data 8R Data Types and Arrays Summer 2017 1 A Test of Skill - GitHub

1 A Test of Skill ... errors) of the following lines of Python code! >>> 6 / 3 ... Luckily, they've supplied a function named bar(labelArray, dataArray) to do.

Recommend Documents

Data 8R Data Types and Arrays Summer 2017 1 A Test of Skill - GitHub
Data 8R. Data Types and Arrays. Summer 2017. Discussion 4: July 6, 2017 ... Impress the squirrels with your knowledge of data types! .... 4 Data Manipulation.

Data 8R Table Methods and Functions Summer 2017 1 ... - GitHub
Jul 18, 2017 - Data 8R. Table Methods and Functions. Summer 2017. Discussion 7: ... its range - the difference between the highest value in the array and.

Data 8R Tables and more Visualizations Summer 2017 1 ... - GitHub
number of colds each volunteer gets. Is this an observational ... questions about it. A business has graphed the proportion of outputs in each year as a bar chart.

Data 8R Tables and more Visualizations Summer 2017 1 ... - GitHub
Jul 11, 2017 - At the same time, the researcher also records the number of ... A business has graphed the proportion of outputs in each year as a bar chart.

Data 8R Table Methods and Functions Summer 2017 1 ... - GitHub
Jul 18, 2017 - We have the dataset trips, which contains data on trips taken as part ofa ... def num_long_trips(cutoff): ... We want to see what the distribution of.

Data 8R Plotting Functions Summer 2017 1 Midterm Review ... - GitHub
Data 8R. Plotting Functions. Summer 2017. Discussion 7: July 20, 2017. 1 Midterm Review. Question 4 ... function onto the table: Hint: Velocity = distance / time.

Data 8R Hypothesis Testing Summer 2017 1 Terminology 2 ... - GitHub
Jul 27, 2017 - simulated on a computer. ... From the histogram, it looks like the higher mean from gambling was not at all that unusual - it certainly could have.

Data 8R Intro to Visualizations Summer 2017 1 Similarity and ... - GitHub
Jun 27, 2017 - The chips that are present in your computer contain electrical components called transistors. ... Here's another attempt to improve the plot:.

Data 8R Intro to Python Summer 2017 1 Express Yourself! 2 ... - GitHub
Mike had a tremendous growth spurt over the past year. Find his growth rate over this 1 year. (Hint: The Growth Rate is the absolute difference between the final.

Different types of data, data quality, available open ...
processing tools ... data: Europeana, Digital Public Library of America & The European ... Influential national libraries moving to co-operative open (linked) data.

Performance Considerations of Data Types - SQL Fool
May 13, 2009 - Selecting inappropriate data types, especially on large tables with millions or billions of ... Fortune 500 company I've worked with learned this the hard way. .... This also resulted in smaller indexes, saving over 100GB of disk.

HW 2: Chapter 1. Data Exploration - GitHub
OI 1.8: Smoking habits of UK Residents: A survey was conducted to study the smoking habits ... create the scatterplot here. You can use ... Go to the Spurious Correlations website: http://tylervigen.com/discover and use the drop down menu to.

Tabloid data set - GitHub
The Predictive Analytics team builds a model for the probability the customer responds given ... 3 Summary statistics .... Predictions are stored for later analysis.