cs 12 midterm

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What type of volatile memory is usually used only for temporary storage while running a program?

RAM

According to the behavior of integer division, when an integer is divided by an integer, the result will be a float. true/false

false

All programs are normally stored in ROM and are loaded into RAM as needed for processing. true/false

false

If a file with the specified name already exists when the file is opened and the file is opened in 'w' mode, then an alert will appear on the screen. true/false

false

In Python, an infinite loop usually occurs when the computer accesses an incorrect memory address. true/false

false

In Python, math expressions are always evaluated from left to right, no matter what the operators are. true/false

false

In Python, read() and readline() allows the programmer to work with text and number files without any extra step. We can read from the file straight to a variable in the str, int and float formats. true/false

false

One of the drawbacks of a modularized program is that the only structure you can use in such a program is the sequence structure. true/false

false

Python allows you to compare strings, but it is not case sensitive. true/false

false

Python uses the same symbols for the assignment operator as for the equality operator. true/false

false

The Python language is not sensitive to block structuring of code. true/false

false

The Python language uses a compiler which is a program that both translates and executes the instructions in a high-level language. true/false

false

To get the total number of iterations in a nested loop, add the number of iterations in the inner loop to the number in the outer loop. true/false

false

Unlike other languages, in Python the number of values a function can return is limited to one. true/false

false

What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8?x < y and z > x

false

When a piece of data is read from a file, it is necessarily copied from the file into a variable. true/false

false

After the execution of the following statement, the variable sold will reference the numeric literal value as (n) ________ data type. sold = 256.752

float

A ________ constant is a name that references a value that cannot be changed while the program runs.

global

A ________ variable is accessible to all the functions in a program file.

global

It is recommended that programmers avoid using ________ variables in a program whenever possible.

global

The first line in a function definition is known as the function

header

Which of the following is the correct if clause to determine whether choice is anything other than 10?

if choice != 10:

Which of the following is the correct if clause to determine whether y is in the range 10 through 50, inclusive?

if y >= 10 and y <= 50:

Which of the following statements causes the interpreter to load the contents of the random module into memory?

import random

A good way to repeatedly perform an operation is to write the statements for the task once and then place the statements in a loop that will repeat as many times as necessary. true/false

true

A software developer is the person with the training to design, create, and test computer programs. true/false

true

A value-returning function is like a simple function except that when it finishes it returns a value back to the part of the program that called it. true/false

true

An action in a single alternative decision structure is performed only when the condition is true. true/false

true

Both of the following for clauses would generate the same number of loop iterations. for num in range(4): for num in range(1, 5): true/false

true

Computer programs typically perform three steps: input is received, some process is performed on the input, and output is produced. true/false

true

Different functions can have local variables with the same names. true/false

true

Expressions that are tested by the if statement are called Boolean expressions. true/false

true

Functions can be called from statements in the body of a loop and loops can be called from within the body of a function. true/false

true

IDLE is an alternative method to using a text editor to write, execute, and test a Python program. true/false

true

If the last line in a file is not terminated with \n, the readline method will return the line without \n. true/false

true

In Python, print statements written on separate lines do not necessarily output on separate lines. true/false

true

It is possible to create a while loop that determines when the end of a file has been reached. true/false

true

One reason not to use global variables is that it makes a program hard to debug. true/false

true

Python allows programmers to break a statement into multiple lines. true/false

true

Python allows you to pass multiple arguments to a function. true/false

true

Python function names follow the same rules as those for naming variables. true/false

true

RAM is a volatile memory used for temporary storage while a program is running. true/false

true

Reducing duplication of code is one of the advantages of using a loop structure. true/false

true

Strings can be written directly to a file with the write method, but numbers must be converted to strings before they can be written. true/false

true

The CPU understands instructions written in a binary machine language. true/false

true

The if statement causes one or more statements to execute only when a Boolean expression is true. true/false

true

The integrity of a program's output is only as good as the integrity of its input. For this reason, the program should discard input that is invalid and prompt the user to enter valid data. true/false

true

The main reason to use secondary storage is to hold data for long periods of time, even when the power supply to the computer is turned off. true/false

true

What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8?x < y or z > x

true

In Python the ________ symbol is used as the not-equal-to operator.

!=

What is the decimal value of the following binary number? 10011101

157

What are the values that the variable num contains through the iterations of the following for loop? for num in range(2, 9, 2):

2, 4, 6, 8

What is the largest value that can be stored in one byte?

255

In a print statement, you can set the ________ argument to a space or empty string to stop the output from advancing to a new line.

end

When a function is called by its name during the execution of a program, then it is

executed

Which mode specifier will open a file but not let you change the file or write to it?

'r'

A bit that is turned off is represented by the value -1. true/false`

false

Which mathematical operator is used to raise 5 to the second power in Python?

**

What will be displayed after the following code is executed? def pass_it(x, y): z = x*y result = get_result(z) return(result) def get_result(number): z = number + 2 return(z) num1 = 3 num2 = 4 answer = pass_it(num1, num2) print(answer)

14

What will be displayed after the following code is executed?for num in range(0, 20, 5):num += numprint(num)

30

What will be displayed after the following code is executed? total = 0 for count in range(1,4): total += count print(total)

6

After the execution of the following statement, the variable price will reference the value ________.price = int(68.549)

68

In Python the ________ symbol is used as the equality operator.

==

The ________ coding scheme contains a set of 128 numeric codes that are used to represent characters in the computer's memory.

ASCII

What is the output of the following print statement? print('The path is D:\\sample\\test.')

The path is D:\sample\test.

A local variable can be accessed from anywhere in the program. true/false

false

A value-returning function is

a function that will return a value back to the part of the program that called it

When using the ________ logical operator, both subexpressions must be true for the compound expression to be true.

and

A(n) ________ is any piece of data that is passed into a function when the function is called.

argument

A while loop is called a pretest loop because the condition is tested after the loop has had one iteration. true/false

false

The smallest storage location in a computer's memory is known as a

bit

Multiple Boolean expressions can be combined by using a logical operator to create ________ expressions.

compound

What type of loop structure repeats the code a specific number of times?

count-controlled loop

Given that the customer file references a file object, and the file was opened using the 'w' mode specifier, how would you write the string 'Mary Smith' to the file?

customer.write('Mary Smith')

Which of the following is the correct way to open a file named users.txt in 'r' mode? infile = open('r', users.txt) infile = read('users.txt', 'r') infile = open('users.txt', 'r') infile = readlines('users.txt', r)

infile = open('users.txt', 'r')

________ is the process of inspecting data that has been input into a program in order to ensure that the data is valid before it is used in a computation.

input validation

The ________ function reads a piece of data that has been entered at the keyboard and returns that piece of data, as a string, back to the program.

input()

In Python, a comma-separated sequence of data items that are enclosed in a set of brackets is called a

list

The following is an example of an instruction written in which computer language? 10110000

machine language

Which of the following is the correct way to open a file named users.txt to write to it?

outfile = open('users.txt', 'w')

When a file has been opened using the 'r' mode specifier, which method will return the file's contents as a string?

read

What is the process of retrieving data from a file called?

reading data

Which method will return an empty string when it has attempted to read beyond the end of a file?

readline

A(n) ________ structure is a structure that causes a statement or a set of statements to execute repeatedly.

repetition

In a value-returning function, the value of the expression that follows the keyword ________ will be sent back to the part of the program that called the function.

return

Which method could be used to strip specific characters from the end of a string?

rstrip

A ________ has no moving parts and operates faster than a traditional disk drive.

solid state drive

Which method could be used to convert a numeric value to a string?

str

Which type of error prevents the program from running?

syntax

Which of the following is not a major component of a typical computer system?

the operating system


Kaugnay na mga set ng pag-aaral

unit 6 genetic expression & regulation

View Set

Economics Chapter 1 and 2 Test Review

View Set

APUSH Vol. 1 to 1877 Ch. 18 Renewing the Sectional Struggle, 1848-1854

View Set

433 test 3 musculoskeletal review questions

View Set

Chap 3 3.3 a membrane seperates each cell from its surrounding

View Set

Anatomical Features (Markings) of Bones

View Set

Chapter 4: Folk and Popular Culture Test Review

View Set

Foundation and practice of mental health nursing

View Set