APCSP semester 1

Ace your homework & exams now with Quizwiz!

Which of the following variable types is characterized by allowing only two possible values to be stored?

Boolean This is correct. A boolean can take a true or false value, so is useful for storing variables which can only take 2 possible values.

Rhys is creating a program which stores customer records. One variable used in the program stores the first initial of a customer's name. Which of the following data-types could be used to store this data? Select two answers.

Character This is correct. A character stores a single letter, number or symbol, and therefore is ideally suited to storing a single letter variable. String This is correct. A string variable stores a sequence of letters, numbers and symbols, and could therefore be used to store a single letter if required.

The following algorithm is presented for assembling a piece of furniture from 12 individually numbered parts. Parts 1, 5, and 11 Parts 2 and 10 Part 12 Parts 6 to 9 inclusive Parts 3 and 4 Which of the following correctly describe issues with the way these instructions are presented? I. There instructions lack the required descriptive qualifiers II. The instructions lack the required imperative statements III. The order in which the instructions should be performed is unclear

II only This is correct. The order of instructions is clear, as is which parts should be used for each instruction. Imperative statements (e.g. attach, place together, fasten to) however are required in order for someone following the algorithm to understand what actions they actually have to perform with the parts listed.

Jama is creating a program which calculates the square roots of whole numbers. The program will store the results of each square-root as a variable. Which of the following data-types would be best used for this variable?

float This is correct. The square root of an integer may be another integer or a non-integer number (e.g. the square root of 2 is 1.4142...). Since the floating point number (float) data type stores decimal numbers, this makes it an ideal data-type for this variable.

Marta is writing a program for a home-automation system. Three of the variables in her program are as follows: light - A variable which determines whether the lights in a room are switched on or off temp - A variable which records the temperature of the room to the nearest whole degree Fahrenheit name - A variable which records the name the user has set for the room (e.g. "kitchen") Which of the following correctly describes the types which would be best used for each of these variables?

light - boolean, temp - integer, name - string This is correct. A boolean should be used for light as it can only have two possible value (on/off or true/false). An integer should be used for temp, as it can take many different possible values which are whole numbers. A string should be used for name since it can contain a combination of letters (and/or numbers).

Which of the following is an example of code written in a high-level programming language?

num1 = 8 - 3 num2 = 2 * num1 + 1 print(num2) Choice B is correct. This code is written in a high-level programming language: it uses some Instructions in english (e.g. print) and mathematical operators, but uses a formal and logical structure which removes ambiguities present in natural language.

Rick is in charge of a team developing a program which will be used by businesses to control stock. The team has already consulted with potential clients and developed an idea of what inputs will be required and the likely outputs that will be produced from these inputs. Which of the following should Rick and his team do next?

Plan the structure of the program and determine how the major algorithms will work

Which of the following statements are NOT true about high level programming languages? Select two answers:

Code written using high level languages is guaranteed to be ambiguous Any particular algorithm will be written in the same way regardless of which high level programming language is used

Which of the following statements about variables in programming are true? I. Variables allow a value to be stored for future use II. Once the value of a variable is set it cannot be changed III. The name given to a variable is important for human comprehension, but not for the computer.

I and III only

Which of the following best describe examples of abstraction

A developer writing a program for calculating properties of shapes uses a variable pi to store a decimal approximation of the number π (~3.14159). They use this variable whenever they need to use the number π to calculate an area or volume. A sheet of music for guitar is written as a series of chords (e.g C, Am, G7). Each of these represents multiple notes which are played simultaneously on different strings of a guitar.

Which of the following statements comparing low-level programming languages (such as assembly language) and high-level programming languages (such as python or java) are correct? Select two answers.

A program written in a high-level language will usually be easier for a person reading the code to understand than one written in a low-level programming language. A program written in a low-level language is closer in syntax to the binary code understood by computers than a program written in a high-level language.

Which of the following describes algorithmic solutions to problems: I. A set of step by step instructions for assembling a piece of furniture. II. A flowchart used to make important decisions on which actions to take in an emergency situation III. A recipe for baking a cake with detailed numbered steps to follow

I, II and III This is correct. Each of the problems described (assembling a piece of furniture, dealing with an emergency situation and baking a cake) are solved through a set of logically ordered, precise instructions. These solutions can therefore be thought of as being algorithmic in nature.

Which of the following best describes why the development process by which computer programs are created is described as "iterative"?

The process is a cycle, with results from one run of the cycle feeding into the next. This is correct. To iterate means to repeat a process, although not necessarily with the same data or results. This describes the development process since results from the evaluation and testing in one cycle are then used to create ideas for improvement and extension and start a new cycle of development.

Erin has written a program which presents a user with multiple-choice quiz questions to answer and calculates a percent score based on the number the user got right or wrong. Each question has 5 possible answers, and scores presented are from 0 to 100 percent inclusive. Which of the following could be represented by a boolean variable?

Whether a user got a specific question right or not This is correct. A boolean variable can have two possible values - true or false. This makes ideal for determining if a user got an individual question right (true) or not (false).

Which of the following is a simplified but equivalent Boolean expression to the following: (X > 0 AND X ≤ 20) OR (X > -5 AND X < 15)

(X > -5) AND (X ≤ 20) This is correct. The expression in the question is satisfied whenever (1) the value of x is between 0 and 20 (including 20), or (2) the value of X is between −5 and 15, or both conditions (1) and (2) are satisfied. For every value of X greater than −5 and not larger than 20, at least one of the conditions (1) or (2) is satisfied, and for every value of X not in this range, neither of the conditions (1) or (2) is satisfied. Therefore any value of x which satisfies (X &gt; -5) AND (X ≤ 20) also satisfies the expression in the question, and any value of x which does not satisfy (X &gt; -5) AND (X ≤ 20) does not satisfy the expression in the question. This must mean that the two expressions are equivalent.

Which of the following best describes how abstraction makes code written in higher-level programming languages easier for humans to parse?

Abstractions used in higher-level languages mean what a command does is easier to understand without needing to parse all the individual operations performed by the CPU. This is correct. Abstraction replaces a complex system with a simplified representation. In this case a complicated sequence of operations being performed by the CPU is replaced with a simplified representation which is more easily understandable to a human.

Consider constructing an algorithm for a robot that can only perform the following three predefined operations. MOVE_FORWARD ( ): The robot moves one square forward in the direction it is facing. ROTATE_LEFT ( ): The robot rotates in place 90 degrees counterclockwise (i.e., makes an in-place left turn). ROTATE_RIGHT ( ): The robot rotates in place 90 degrees clockwise (i.e., makes an in-place right turn).

Step 1: MOVE_FORWARD ( ) Step 2: MOVE_FORWARD ( ) Step 3: ROTATE_LEFT ( ) Step 4: ROTATE_LEFT ( ) Step 5: MOVE_FORWARD ( ) Step 6: ROTATE_RIGHT ( ) Step 7: MOVE_FORWARD ( ) Step 8: MOVE_FORWARD ( )

Microsoft Excel® is a spreadsheet program that can be used for computing the average of a list of values in cells A1 through A20 with a command such as =AVERAGE(A1:A20). After the user initiates this command, the command disappears and the average (or mean) of the list of numbers appears. Why is this an abstraction?

The average can be viewed without knowing the process of how the average was computed. This is correct. Abstraction is the process by which complicated procedures can be replaced by a simplified representation. In this case, excel is summing the values in cells A1 to A20 and dividing this by the number of cells (20). However this process is represented by a simple command, =AVERAGE(A1:A20), which describes what is actually calculated by this process. Therefore this is an example of abstraction.

The following algorithm is proposed for the task of baking a cake, and is presented along with a list of ingredients. Add some ingredients from the list to a bowl Stir Add other ingredients to a bowl Stir Put in a tin in the oven Take out tin from oven Which of the following correctly describes an issue with the way the instructions in this algorithm is presented?

The instructions lack descriptive qualifiers This is correct. Descriptive qualifiers are needed to determine for example which ingredients are added first, which ingredients are added later, and how long the tin should be in the oven for.

Roxanne is writing a program which will be used to display information to passengers on a flight. Some of the variables she will use for her program are as follows. speed - the current speed of the airplane relative to the ground in meters per second passengers - the number of passengers on-board the plane destination - the name of the destination airport of the flight Which of the following correctly describes the types which would be best used for each of these variables?

speed - float, passengers - int, destination - string This is correct. The variable speed takes decimal number values, therefore a float, which represents decimal numbers is the best choice. The variable passengers will always be a whole number (integer), therefore an int is the best choice. The variable destination is a word (or multiple words) formed of letters, therefore a string, which is made up of multiple characters (letters, numbers, symbols) is the best choice.


Related study sets

Jason Dions Practice Exams (2 of 5)

View Set

Chem 144 Experiment 5 Part 1 and 2: The Quantitative Determination of an Acid in Carbonated Beverages

View Set

CompTIA A+ Exam 220-1001 - Wireless Networking Quiz

View Set

SUPPLEMENTAL NOMENCLATURE WORKSHEET FOR TEST 2

View Set