Computers and Technology

Complete all components in the activity below according to the given instructions. Refer to the provided rubric for information on how you will be graded. Submit your work as a file attachment using the dropbox. The activity is worth 15 points.

UNIT 1 ACTIVITY 1
How Many Sevens?
Required Materials
OnlineGDB (login required)
Word processing software
You’ve learned about lists and defining your own functions. Now, you will put those skills together by writing a program that will print how many times the number 7 appears in a list.

Step 1: Practice
But before we do that, let’s visualize a bit of code to be sure you understand how it works. We are going to run the code in a visualizer. A visualizer shows you not just the output of the code but also what is happening step by step.

Go to Python Tutor Visualizer.

Then, type in this code:

my_list = [1, 2, 3, 4, 5]
for x in range(len(my_list)):
print(my_list[x])
Now, click on the Visualize Execution button. You will see a screen that has your code on the left and a blank area on the right.

Press the Next > button to begin stepping through the program. On the right, you will see a visual representation of the fact that the code has created a list; you will also see the items in the list as well as their index numbers.

Press the Next > button until you have finished the program. Did you notice how the red and green arrows showed you which lines of the program had just executed and which ones were about to execute during each step of the way through the program?

Now, let’s review the program itself. The first line of this code creates a list called my_list . Then, the second line is the command to iterate over the list using a variable that we call x . We did this iteration by making the range equal to the length of the list. For each iteration, it printed the item from the list that had the same index as the iterating variable. Now, you should be comfortable with iterating over a list and accessing each item in the list as you iterate over the list by using the incrementing variable as the index number.

Step 2: Program
Now, we’re ready to program! Leave the visualizer and go to OnlineGDB to write your program. Here is the pseudocode for your program:

Define a function called “seven_checker” that will do the following things:

Iterate over a list.
Check to see whether the number 7 is in the list.
Print how many times the number 7 appears in the list.
Create a list with 10 numbers in it. Then call the function and pass your list to the function as a parameter.

When you have tested your program, click the save button. Then click Share and copy the program link. Paste the link in a word processing document and submit using this unit’s dropbox. If your program does not work properly, also include a paragraph explaining what you did to troubleshoot it.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:00, alyssacyamamoto8050
Budgets you to do all of the following expect a) send frivolously b) avoid over spending c) gain financial independence d) examine your priorities and goals
Answers: 2
image
Computers and Technology, 23.06.2019 01:50, jumoke26
Create a class named majors that includes an enumeration for the six majors offered by a college as follows: acc, chem, cis, eng, his, phys. display the enumeration values for the user, then prompt the user to enter a major. display the college division in which the major falls. acc and cis are in the business division, chem and phys are in the science division, and eng and his are in the humanities division. save the file as majors. java.
Answers: 2
image
Computers and Technology, 23.06.2019 10:00, lamanihill
Now, open this passage to read about fafsa requirements. describe the information you will need to provide in order to complete a fafsa. list at least three of the required documents you must include.
Answers: 3
image
Computers and Technology, 24.06.2019 01:00, summerjoiner
Verify each identity[tex] \frac{csc}{cot \: x \: + \: tan \: x} = cos \: x[/tex]
Answers: 1
Do you know the correct answer?
Complete all components in the activity below according to the given instructions. Refer to the prov...

Questions in other subjects:

Konu
Mathematics, 07.12.2020 23:50