Table 6 Exercises

< CS101

Each of the following problems asks you to count two things. The last lines printed should look like:

count: 23
count: 42

For simplicity, we will just use the word "count" for both lines in the output. The starter code includes lines to set variables count1 and count2 to zero before the loop. As usual, you can print and count some cases by hand to check your code before submit time.

1.

Do more baby names start with "A" or "B"? Write code to count and print those two counts ("A" count, then "B" count).


table-6-ex1

 

2.

Now we'll look at the survey data. How many people identified "House Of Cards" vs. "The Office" as their favorite TV show? The appropriate field in the survey is "tv", and think about uppercase vs. lowercase letters in your query code. Write code to count and print those two values ("House Of Cards" count, then "The Office" count).


table-6-ex2

 

3.

Instead of looking at the whole survey, let's look only at the people who identified "blue" as their favorite color. Produce the same tv-show counts as the previous question, but looking only at people who identified "blue" as their favorite color.


table-6-ex3

 


Each click of a Run button saves that code on the computer running the browser. The button below retrieves the all code exercises listed to the right of the button.

count 3 : table-6-ex1 table-6-ex2 table-6-ex3

(code appears here)