25.1. Set #1¶
The following questions make up Set #1 of the Untimed Practice Questions. The questions resemble, both in format and substance, what you might see on the AP CS Principles exam. You may refer to the AP CS Reference Sheet, which can be found here.
You will not be able to change your answers after you hit the “Finish Exam” button.
- A variable.
- Incorrect. A variable is name that a computer can associate with a value. For example, if name ='Alexa' then name is the variable and 'Alexa' is the value.
- A Function.
- Incorrect. Functions perform some action, like a procedure, and return a value. For example, x.lower() would return a new string in all lowercase.
- Code.
- Incorrect. Code is what you are using to tell the computer how to function! You are learning how to code!
- A String.
- Correct. A string is characters typed between one, two, or three quotes.
Which term does the following statement describe?
Any sequence of characters we can type between a pair of single, double, or triple quotes
- A device that can be programmed to compute anything that can be mathematically computed.
- Incorrect. This one is true! All Turing Machines have the ability to compute mathematical functions.
- Any machine that passes the Turing Test.
- Incorrect. This one is true! Turing Machines pass the Turing Test if they reflect human-like tendencies during the Turing Test.
- A machine that can read instructions from a tape and write results to the tape.
- Incorrect. This one is true! A Turing Machine can read information that it is provided and write back results.
- A computer that cannot repeat steps.
- Correct. This answer is not true! All Turing Machines do have the ability to repeat steps.
Which of the following is NOT true of a Turing Machine?
- 'Fido'
- Correct. On line four, notice how animal_1 is reassigned to 'Fido'. On the following line animal_3 is reassigned to the value of animal_1, which is now 'Fido'.
- animal_3
- Incorrect. animal_3 is the name of the variable.
- 'fish'
- Incorrect. 'fish' is the new value of animal_2 assigned on the last line.
- Error
- Incorrect. This code will run and there will not be an error.
Use the following code for questions 3 and 4.
What will print out when the code is run?
animal_1 ← 'Garfield'
animal_2 ← 'Fido'
animal_3 ← 'Gary'
animal_1 ← animal_2
animal_3 ← animal_1
animal_2 ← 'fish'
- A name
- Incorrect. animal_1 is the name of the variable, but the type of animal_1 is a variable.
- A string
- Incorrect. The value of animal_1 is a string, however, animal_1 is a variable assigned to that value.
- A function
- Incorrect. A function performs an action on variables and returns some result.
- A variable
- Correct. animal_1 is a variable with a string as its value.
Which of the following is animal_1 an example of?
- strings
- Incorrect. Strings are immutable.
- lists
- Correct. Lists can be changed by indexing and reassigning the value of that index.
- integers
- Incorrect. Integers are immutable, but mathematical functions can be applied to change their values.
- booleans
- Incorrect. Booleans have the value of either True or False.
Which of the following are mutable?
- Classifying
- Incorrect. This process is not called Classifying.
- Cleaning
- Correct. Cleaning is in fact the process of searching data sets for incomplete data records.
- Clustering
- Incorrect. This is not the definition of Clustering.
- Filtering
- Incorrect. Filtering often refers to choosing data with specific characteristics.
What describes the process of searching data sets for incomplete data records to process?
- _a1SteakSauce
- Incorrect. Names of variables MUST start with a letter or an underscore (_).
- My_name
- Incorrect. This is a legal variable. It does not start with a number or contain any spaces.
- 1more-try
- Correct. Legal variable names must start with a letter or underscore, can contain but not start with a digit, and cannot be a Python keyword.
- LOL
- Incorrect. This is a legal variable name.
- alotOfexamStuff
- Incorrect. This is a legal variable.
Which of the following is not a legal variable name?
- .25
- Correct. In Python code, pseudo code as well, a decimal value will be returned from an integer calculation. Note that in older Python code, it would have printed 0. In other languages as well, the code will return the number just before the decimal.
- 0
- Incorrect. Because we are applying Python 3.0, the code will return a decimal.
- 1/4
- Incorrect. The code will calculate the value of a fraction.
- .2
- Incorrect. The value of 1/4 is .25, not .2 or .20.
What will the above code print?
result ← 1/4
DISPLAY (result)
- 122
- Incorrect. Based on the order of operations, be sure to start with the inmost parentheses.
- 220
- Correct. The expression will begin by adding Right + Left inside the parentheses then move to the outer parentheses to add Mid to the sum of Right + Left. The entire sum within the outer parentheses will then be multiplied by Right.
- 420
- Incorrect. Remember to follow the order of operations.
- 0
- Incorrect. The product is not 0. Remember to follow the order of operations.
What is the value of Product?
Mid ← 8
Right ← 10
Left ← 4
Product ← Right *((Right+Left)+ Mid)
- They are the same.
- Incorrect. The Web and the Internet are not the same. The Internet is a global computer network consisting of interconnected networks. The Web is an information system on the Internet that allows documents to be connected to one another.
- The Internet cannot search using user-specified queries, the Web can.
- Incorrect. The Internet can search user-specified queries.
- The Internet uses the Web to connect devices to share data.
- Incorrect. The Web is a system on the Internet that connects documents to one another.
- The Web uses HTTP to share computational artifacts using the Internet.
- Correct. This is true of the World Wide Web.
How do the World Wide Web and the Internet work together?
- Everyone with access can reach it at any time.
- Correct. Using cloud computing refers to storing and accessing information using the Internet rather than one's hard drive. It allows more than one computer to access it.
- The cloud keeps their information private from other companies.
- Incorrect. Cloud computing systems can keep information private, however, that is not a main advantage of using it.
- The cloud blocks all information from its employees.
- Incorrect. Advantages of cloud computing do the exact opposite.
- Half of the company’s data can be transferred to other locations to reduce demand on servers.
- Incorrect. This is not a main advantage of cloud computing systems for businesses.
Which of the following is a main advantage for a company placing their data in the cloud?
- 2
- Incorrect. 4 is divisible by 2, and 4/2 = 2, but MOD will produce the remainder value of 4/2.
- 4
- Incorrect. The remainder of 4/2 is not 4.
- 0
- Correct. Because 4 is divisible by 2, there is no remainder.
- None
- Incorrect. The answer is not None. MOD will return an integer.
What will the following code print out?
num ← 4 MOD 2
DISPLAY (num)
- 0.5
- Incorrect. 100 divided by 20 is 5.
- 5.0
- Correct. Because they are float types, the value of 100.0/20.0 is equal to 5.0.
- 15.0
- Incorrect. 100 divided by 20 is not 15.
- 20
- Incorrect. 100 divided by 20 is not 20. The value of a float divided by a float is also a float.
Use the following code for questions 13 and 14.
What is the value of gallons?
distance ← 100.0
mpg ← 20.0
gallons ← distance / mpg
costPerGallon ← 3.00
costTrip ← gallons * costPerGallon
- 15.0
- Correct. The value of gallons is 5.0, the value of costPerGallon is 3.00. Therefore, costTrip = 15.0.
- 5.0
- Incorrect. A float multiplied by a float is a float.
- 15.0
- Incorrect. The value of costTrip is the product of gallons multiplied by costPerGallon.
- 20
- Incorrect. The value of costTrip is the product of gallons multiplied by costPerGallon.
What is the value of costTrip?
- 'What a fast turtle!'
- Incorrect. The return value of a function will not be printed unless in a print statement.
- A square
- Correct. This function creates a square. Turtles start facing East.
- A turtle
- Incorrect. This function does not create a turtle shape.
- A triangle
- Incorrect. Write out the function. The turtle starts facing East, moves forward 100, turns right and does it again three more times.
What shape will the turtle function return?
def square(turtle):
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
return “What a fast turtle!”