computer science tests + quizzes

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

You are writing a loop to print a word entered from the keyboard 15 times. Which of the following is true? A. this will be a loop stopped by counting b. the loop runs until the sum is greater than 100 c. this will be a loop stopped by user input d. none of the above

a

which command tells the for loop what to count by

range

which of the following applies to functions and describes a reason we use functions? a. to enable code to be reused b. to stop the program from repeating c. to ask the user for input d. to test a condition for true and false

a

which of the following is used to mark the end of the line in a text file? a. \n b. \f c. \e d. \t

a

why do we use WHILE loops? a. because of efficiency b. because computers can do calculations humans can't c. because programs need to make decisions d. because programming is an important skill

a

why do we use the close command when outputting to a data file a. to save the data to secondary memory b. to clear the data from secondary memory c. to clear the data from the CPU d. to save the data to the CPU

a

the _____________ method adds a new element onto the end of the array

append

_______ allows an entire array to be created with stored values at the same time a. an element b. an index c. an initializer list d. assigning

c

text files contain

characters

the ______________ command changes an ASCII value to its character

chr()

num < 19 is an example of

condition

c = c + 1 is called

count variable

sorting algorithms are used to __________ arrays, while search algorithms __________ in arrays A. index, find b. find, order c. index, find d. order, find

d

the ___________ keyword is used to create a function

def

the _______ method adds a list on the end of the array

extend

a ______ loop has a built in count variable

for

while loops should always be a. calculated b. indented c. output d. input

indented

we ____________ variables to prevent junk values from being stored in them

initialize

the _______ command changes a character to its ASCII value

ord()

the _______method removes elements from an array by the value not the location

remove

the _________ data type holds values not used for calculations

string

in a ____________ loop you do not know ahead of time how many times the loop will repeat

user input

which of the following can a character NOT contain a. a letter b. a symbol c. a string d. a number

c

which of the following is NOT a rule for algorithms? a. they produce a result b. they have an order c. they repeat indefinitely d. they have clear instructions

c

why do we use functions? a to stop the program from repeating b to test for true and false c to simplify code d to ask the user for input

c

why do we use while loops when processing data files? a. we know exactly how many lines are in the file b because we are inputting values from the keyboard c. we do not know ahead of time how many lines are in the file d. because files contain special characters to mark the end of the file

c

the _________ keyword is used to return a value from a function

return

the _______ method returns the length of an array

len

the ________ command returns the length of a string

len()

which statement will be best to draw a square

draw_line

the CPU carries out the commands from programs running in

main memory

a _________ is information sent to a function

parameter

what is one issue with digitally representing information a. it cannot be stored in secondary memory b. it cannot be input from external files c. the CPU cannot process it d. it can take up large amounts of memory

d

which of the following is not a reason we use subprograms? a to simplify code b to help us organize longer program c for code that will be reused d to add comments to lines of code

d

why do we use for loops with arrays a. for loops let python to handle the values as strings not numbers b for loops let us access one specific element of an array c. to store one piece of data at a time d. lets us quickly process contents of the array

d

functions are used to ________________ a represent numeric data b write output to the screen c organize longer programs d input data into a program

c

main memory is _____________ and ______________ a. permanent, slow b. temporary, slow c. temporary, fast d. permanent, fast

c

the __________ go above the __________ in the source code file a main program, return b main program, functions c subprograms, main program d def, functions

c

we use loops A. to do calculations on user input b. to test if more than one condition is true c. to repeat a section of code d. as a gate to block off sections of code

c

what color is created by RGB (255, 0, 0) a blue b green c red d yellow

c

where does append add the new elements? A. in alphabetical\numerical order b. to the beginning of an array c. to the end of an array d. to the middle of an array

c

______________ holds running programs and the information they are using

main memory

a _____________ is a piece of data stored in an array

element

a _________ is a collection of commands given a name

function

which command sends information to a data file

write()

loops are used to _____________ code

repeat

which of the following is NOT true about while loops a. used to find remainders b. use conditions like if statements c. a way of repeating a code d. give us more control over how the program runs

a`

the two ways to end a loop are a. count variables b. initialization c. condition d. user input

A, D

which of the following is NOT true about for loops A. a loop with the count variable built in B. advantage: less likely to get an invite loop C. these are used to replace user input while loops D. these are used to replace counting while loops

A,B,D

we use for loops instead of while loops. A. you do not know how many times you want the loop to run B. when you need to ask the user for input C. you know how many times you want the loop to run d. when there is a definite starting and ending point

C, D

for a loop to stop the loop control variable must a. the loop control variable must change b. the loop control variable must be input from the keyboard c. the loop control variable must be true d. the loop control variable must change inside the loop

D

which of the following is true about ASCII? a. the ASCII chart is different on PC and apple computers b. the ASCII chart is not used by mobile devices c. the ASCII chart was invented in the 1990's for use on the internet d. the ASCII chart matches characters to numbers so they can be stored in memory

D

a variable used to send information to a function is called a a. constant b. parameter c. call d. main

b

what is one advantage of using external data files a. repeating commands in programs b. inputting large amounts of data from a file instead of the keyboard c. inputting data from the internet instead of a keyboard d. repeating data input from multiple sources

b

___________________ help us look at new situations and try to measure how change impacts things A. computer models b. count variables c. random numbers d. simulations

a

which of the following is not a reason to use arrays? a. to do number calculations b. to store data in programs c. to quickly process large amounts of data d. organize information

a

which of the following correctly checks if the digit 8 is in the string represented by the variable word A. word.find("8") b. word.find(8) c. word.find('8') d. word.find(str(8))

a,c,d

an array is: a. a collection of commands that are given a name b. individual letters, digits, or symbols c. a data type that stores letters, numbers, and words not used for calculations d. variable that holds many pieces of data at the same time

d

in an array, what is the difference between an element and an index? a there is no difference b an element is a type of index c an index refers to actual data within the array while an elements refers to a memory location d. an element refers to actual data within the array while an index refers to a memory location

d

the ________ algorithm requires two for loops

sort

setting a starting value for a variable is called

initializing

a ___________ is a command used to repeat code

loop

what statement will be best to draw a box

draw_polygon

a __________ is a variable that holds many pieces of data at the same time

array

____________ is storing a specific value in the array

assigning

_____________ means to set a variable equal to a know value? a. sum b. initialize c. input d. count

b

_______________ : a way to spot errors in code and predict output A. function B. tracing code c. variable D. for loop

b

which of the following is not one of the three steps needed to import data from a text file a. open the file b. add comments to each line of data in the file c input and process the data d close the file

b

color in graphics are a ____________ data type

string


Ensembles d'études connexes

Prefix in- Im- Ir- all mean not ( all the words are adj)

View Set

Ch 5 z-scores: Location of Scores and Standardized Distributions

View Set

Property and Casualty Insurance Guide

View Set

The first emperor of China, CH. 22

View Set

APES Human Impacts on Ecosystems (Unit 8)

View Set