comp sci princples quiz 1
A program that Thomas has written is complete. It has been tested thoroughly, and some outputs were not as expected. Thomas is now going through the code carefully attempting to establish the cause of these errors and change the code to remove them. What is this procedure called?
Debugging
Which of the following should be true of any algorithm? I. The order in which the steps making up the algorithm are followed is logically determined II. Following the instructions in the algorithm will always result in the same outputs, regardless of any inputs III. The instructions in the algorithm contain all necessary information to be implemented
I and III only
Consider the following two implementations of the same algorithm, each written in a different language. Language A: Calculate the average daily rainfall for the week (averageRainfall) by adding together the rainfall totals for each of the 7 days of the week (sun, mon, tue, wed, thu, fri, and sat) and dividing the sum by 7. Language B: Take the total amount of rain from each day of the week (sunday, monday, tuesday, wednesday, thursday, friday and saturday) and then average them together to get the average daily rainfall for the week (averageRainfall). Which of the following statements about these two implementations is true?
Language B is ambiguous because the process of "average" is not explained well
iteration
repeatedly applying a process with the goal of coming closer and closer to a solution
Which of the following best describes how a compiled program is run by a computer?
The binary instructions from the program are loaded into RAM. The CPU reads and executes instructions, storing and accessing data from RAM as needed.
Which of the following is the MOST important reason computers use artificial languages over natural language?
The syntax of artificial languages is explicit and unambiguous
Which of the following best describes "compilation" in reference to computer science?
Code in a high-level language is converted to low-level instructions which can be interpreted and run by the CPU.
Jeremiah is part of a group planning a summer fair at which local businesses can run stalls and events. He wants to use his programming skills to develop an app for the fair which businesses will be able to use to communicate information about their activities at the fair with visitors. Which of the following would be the best first step for Jeremiah to take?
Find out from the businesses and potential visitors what information and format they think should be used for the app
Understanding of the life cycle of a program is an essential component to becoming an effective programmer. Which of the following is the best example of how the life cycle of a program should work?
Idea→algorithm→write code→execute code→debug→maintain
The algorithm below simulates rolling a regular 6-sided die twice. Consider the goal of determining if the sum of the values of the two rolls is odd or even. Step 1: Using a random number generator, get a value between 1 - 6 inclusively Step 2: Remember that number Step 3: Repeat steps 1 and 2 Step 4: Add the two remembered numbers together Step 5: Multiply that sum by 10 Step 6: Divide the result of that multiplication by 2 What conclusions can be made with regard to what we are trying to determine? Select two answers:
If the value found in step 6 is 10, 20, 30, 40, 50 or 60 then the sum is even If the last digit of the value found in step 6 is 5, then the sum is odd
Which of the following describes the part of a computer which stores instructions and information which has been input to the computer?
RAM
A statistics teacher wishes to create a program on her calculator that generates a random even integer. The command built in the calculator to generate a random positive integer is RANDOM(a,b). This command generates a random integer between integers a and b (and including a and b). Which of the following lines of code will ensure that the random integer generated will be even?
RANDOM(a,b) * 2
Which of the following best describes high-level computing languages?
They are not very ambiguous
natural language
a complex, but structured language, both written and spoken, that has evolved naturally in humans through use, repetition, and adaptation.
artificial language:
a limited size language, usually developed by a small group for specific purposes. Usually much simpler and structured.
algorithm
a process or set of instructions to be followed in calculations or other problem solving operations.
low-level language
a programming language that has little or no abstraction and communicates closely to the hardware using machine language. Less natural for humans.
high-level language
a programming language that is easier for humans to read, write, and parse. Guaranteed to be unambiguous.
source code
programs written in high-level languages.
abstraction
the process of removing or suppressing details to create a manageable level of complexity.
compilation
the process of source code being translated into machine code.
debug
to identify and remove errors from a computer program
selection
uses "if...then" to tell a computer how to select a step or to tell the sequence that it should be executed.