MCQ Comp Sci P
Assume that both lists and strings are indexed starting with index 1. The list wordList has the following contents. ["abc", "def", "ghi", "jkl"] Let myWord be the element at index 3 of wordList. Let myChar be the character at index 2 of myWord. What is the value of myChar ?
"h"
An employee wants to count the number of books that meet all of the following criteria. Is a mystery book Costs less than $10.00 Has at least one copy in stock For a given row in the spreadsheet, suppose genre contains the genre as a string, num contains the number of copies in stock as a number, and cost contains the cost as a number. Which of the following expressions will evaluate to true if the book should be counted and evaluates to false otherwise?
(genre = "mystery") AND ((1 ≤ num) AND (cost < 10.00))
A student wants to count the number of shows that meet both of the following criteria. Is a talk show Is on Saturday or Sunday For a given row in the spreadsheet, suppose genre contains the genre as a string and day contains the day as a string. Which of the following expressions will evaluate to true if the show should be counted and evaluates to false otherwise?
(genre = "talk") AND ((day = "Saturday") OR (day = "Sunday"))
What is the value of r as a result of executing the code segment?
20
The list wordList contains a list of 10 string values. Which of the following is a valid index for the list?
4
A teacher is writing a code segment that will use variables to represent a student's name and whether or not the student is currently absent. Which of the following variables are most appropriate for the code segment?
A string variable named studentName and a Boolean variable named isAbsent
The variable isOpen is to be used to indicate whether or not a store is currently open. Which of the following is the most appropriate data type for isOpen ?
Boolean
Which of the following explains how the two databases can be used to develop the interactive exhibit?
Both databases are needed. Each database can be searched by animal name to find all information to be displayed.
Assume that applying either of the filters will not change the relative order of the rows remaining in the spreadsheet. Which of the following sequences of steps can be used to identify the desired entry? Select two answers.
Filter by photographer, then filter by year, then sort by year Sort by year, then filter by year, then filter by photographer
A programmer has a need to round many numeric values to the nearest integer. Which of the following best explains the benefit of using a list as a data abstraction in this situation?
Keeping the numeric values in a list makes it easier to apply the same computation to every data element.
Which of the following is a benefit of using a list as a data abstraction in a program?
Lists often allow their size to be easily updated to hold as many data values as needed.
The owner of a clothing store records the following information for each transaction made at the store during a 7-day period. The date of the transaction The method of payment used in the transaction The number of items purchased in the transaction The total amount of the transaction, in dollars Customers can pay for purchases using cash, check, a debit card, or a credit card. Using only the data collected during the 7-day period, which of the following statements is true?
The total number of items purchased on a given date can be determined by searching the data for all transactions that occurred on the given date and then adding the number of items purchased for each matching transaction.
What are the values of first and second as a result of executing the code segment?
The value of first is true, and the value of second is true.
A new rechargeable battery pack is available for products that use AA batteries. Which of the following best explains how the data files in the table can be used to send a targeted e-mail to only those customers who have purchased products that use AA batteries to let them know about the new accessory?
Use the products file to generate a list of product IDs that use AA batteries, then use the list of product IDs to search the purchases file to generate a list of customer IDs, then use the list of customer IDs to search the customers file to generate a list of e-mail addresses
firstList ←← ["guitar", "drums", "bass"] secondList ←← ["flute", "violin"] thirdList ←← [] thirdList ←← firstList firstList ←← secondList secondList ←← thirdList What are the contents of secondList after the code segment is executed?
["guitar", "drums", "bass"]
What are the contents of yourList after the code segment is executed?
[10, 30, 50, 70]
The variable age is to be used to represent a person's age, in years. Which of the following is the most appropriate data type for age ?
number
Which of the variables have the value 50 after executing the code segment?
x and z only