Quiz: Unit 3 Review

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

A gaming software company gave their new customers a survey, asking them to rate various aspects of a new product on a scale of 1 to 5. The integer values of their answers were stored in a list feedback. Which code segments would assign the mean average value of the items on the list to the variable average? Select two.

First Option: sum ← 0 item ← 1 REPEAT LENGTH(feedback) times { sum ← sum + list[item] item ←item + 1 } average ← sum / LENGTH(feedback) Second Option: sum ← 0 FOR EACH item IN feedback { sum ← sum + item } average ← sum / LENGTH(feedback)

nspired by a tip-calculating mobile application that she made in the classroom, a student decides to create a program that uses percentages. She notices on a social media website that there is much debate over a proposed local sales tax increase. She decided to create a calculator into which users will be able to input the amounts they spend on various items, and which will output the current tax, and the proposed future tax on those items in dollars. The app will tell the user how much more the goods will cost with the new tax than the old tax. One of the procedures in her program, which finds the difference between the old and new tax, is listed below.

.06

The following scratch program is run: Assuming that the list favorite songs is initially empty, and the user responds to each request for input, how many items will the list favorite songs contain after the program is run?

10

Which of the following decimal (base-10) values is equivalent to the binary (base-2) value 101001?

41

What is the binary number 1001110001 expressed as a decimal number?

625

How many distinct values can be represented with 6 bits of data?

64

What is the value of z at the end of this procedure if x was 20 and y was 2 when the procedure was called?

84

Using the table given below convert the binary number 01000011 01010011 00100000 01010010 01101111 01100011 01101011 01110011 00100001 to ASCII characters.

CS Rocks!

Remember that "state space" refers to the space of all potential possibilities. Which dichotomous questions below will successfully narrow down the entire state space of "flipping a coin and rolling a normal six-sided die" to 1 or fewer possible outcomes regardless of the answers given?

Did the coin land on heads? Is the value on the die odd? Is the value on the die more than 3? Does the value on the die equal 1, 2, 5 or 6?

Consider the following procedure: PROCEDURE find (target, list) { i← 1 FOR EACH item IN list { IF (item = target) { DISPLAY (i) } i ← i + 1 } }

Displays the positions of all occurrences of target in list

Students were asked to order a list of the seven days of a week, without a specification as to the rules of the ordering. Which of the following ordered lists may be considered correctly ordered? I. Mon-Tue-Wed-Thu-Fri-Sat-Sun II. Thu-Fri-Sat-Sun-Mon-Tue-Wed III. Fri-Mon-Sat-Sun-Thu-Tue-Wed

I,II, and III

Consider the goal of finding the sum of all odd integers in a list, myInts, of integers. What should replace <block of statements> to successfully find the sum of all odd integers?

IF (NOT (num MOD 2 = 0)) { sum ← sum + num }

The table below shows an incomplete ASCII chart If the ASCII chart were continued, what letter would be represented by 84?

T

Consider the following algorithm. Subtract 1 from the current value of Y and store the answer as the new value of YSet the value of X to the current value of Y+1Set the value of X to the current value of YRepeat steps 1 to 3 until X = 10 Which of the following best describes the behavior of this algorithm based on the starting values of the variables X and Y?

There are many possible starting values for X and Y which will cause the algorithm to eventually terminate, and many possible starting values for X and Y which will cause the algorithm to run indefinitely

The program below was designed to find the smallest positive item in a list of integers but contains a crucial error. Which of the following lists will cause the program to give and incorrect output?

[-1,1,4,0]

Two students are trying to combine their decks of Pokémon cards so that they make one large deck of cards that contains exactly one of each unique type of Pokémon card that they own - in alphabetical order. In order to do this, the students start with two lists, deck1 and deck2, which are lists of all Pokémon cards each student owns (duplicates included) and the following available procedures. Which of the following code segments below would correctly create combinedDeck based on the above specifications?

combinedDeck ← Add(deck1, deck2)combinedDeck ← RemoveDups(combinedDeck)combinedDeck ← Alphabetize(combinedDeck)

The procedure prime returns a value of "PRIME" if number (a positive integer) is prime (divisible by only 1 and itself) and returns "NOT PRIME" otherwise.

count = 2

The procedure Max(list) is used to find the maximum number in list and display that number. See the procedure below: PROCEDURE Max(list) { maximum ← 0 FOR EACH number IN list { IF (number > maximum) { maximum ← number } } DISPLAY (maximum) }

list ← [] list ← [-5, -3, -10, -8, -1]

At the end of the code segment below, what will be said for 2 seconds?

mixxixxixxi

In order to program a robot to move around within a two-dimensional space, a programmer considers four different designs for defining the robot's behavior. Which of the following sets of procedures would be the best design in terms of the readability, efficiency, and flexibility of the resulting program?

move(dir, dist): Moves the robot dist spaces in the dir direction, where dist is a number and dir is NORTH, SOUTH, EAST or WEST


संबंधित स्टडी सेट्स

Strategic Management Chapters 1-5

View Set

REAL 17.2: Legislation Resulting from the Subprime Mortgage Crisis

View Set

Unit 9 Environmental Science MCQ

View Set

Psych/Mental Health HESI Study Plan A

View Set

ISSA Domain One Basic and applied science

View Set

P.M. Ch.8: Project Quality Management

View Set

GEO111 - Grundzüge und Sphären

View Set

Philosophy short answer questions

View Set