Python Chapters 1-8

Ace your homework & exams now with Quizwiz!

Input validation means prompting a user when input is required. (True/False)

False

It's a bad idea to define new functions if it makes a program longer. (True/False)

False

Keywords make good variable names. (True/False)

False

Multi-way decisions must be handled by nesting multiple if-else statements. (True/False)

False

Operations like addition and subtraction are defined in the math library. (True/False)

False

Programmers rarely define their own functions. (True/False)

False

Programs no longer require modification after they are written and debugged. (True/False)

False

Python does not allow the input of multiple variable with a single statement. (True/False)

False

Python functions can never modify a parameter. (True/False)

False

Secondary memory is also called RAM. (True/False)

False

Since floating-point numbers are extremely accurate, they should generally be used instead of ints. (True/False)

False

The add method can be used to add an item to the end of a list. (True/False)

False

The best way to write a program is to immediately type in some code and then debug it until it works. (True/False)

False

The copy method is provided to make a copy of a graphics object. (True/False)

False

The easiest way to iterate through the lines of a file in Python is to use a while loop. (True/False)

False

The math.sqrt function cannot compute the square root of a negative number. (True/False)

False

The method in the graphics library used to get a mouse click is readMouse. (True/False)

False

The process of associating a file with an object in a program is called "reading" the file. (True/False)

False

The sqrt function computes the squirt of a number. (True/False)

False

The statement myShape.move(10,20) moves myShape to the point (10,20). (True/False)

False

The syntax of a language is its meaning, and semantics is its form. (True/False)

False

There is usually only one correct solution to a problem involving decision structures. (True/False)

False

Type conversion functions such as float are a safe alternative to eval for getting a numbers as a user input. (True/False)

False

Using graphics.py allows graphics to be drawn in a Python shell window. (True/False)

False

not(a or b) == (not a) or not(b) (True/False)

False

A user interface organized around visual elements and user actions is called a(n)

GUI

What expression would create a line from (2,3) to (4,5)?

Line(Point(2,3), Point(4,5))

A function with no return statement returns

None

Variables defined in a function are local to that function. (True/False)

True

a and (b or c) == (a and b) or (a and c) (True/False)

True

The literals for type bool are

True, False

A successor to ASCII that includes characters from (nearly) all written languages is

Unicode

Taking the square root of a negative value with math.sqrt produces a(n)

ValueError

What is the fundamental question of computer science?

What can be computed?

When a program is being run directly (not imported), the value of __name__ is

__main__

One difference between a compiler and an interpreter is

a compiler is no longer needed after a program is translated

A statement is

a complete computer command

The template for <variable> in range(<expr>) describes

a definite loop

Which of the following is not a Python type-conversion function?

abs

Which of the following computes the horizontal distance between points p1 and p2?

abs(p1.getX() - p2.getX())

A method that returns the value of an object's instance variable is called a(n)

accessor

The pattern used to compute factorial is

accumulator

If a function returns a value, it should generally be called from

an expression

In order to use functions in the math library, a program must include

an import statement

Fragments of code that produce or calculate new data values are called

assignment statements

The term for a program that does its I/O with files is

batch

What statement can be executed in the body of a loop to cause it to terminate?

break

In Python, actual parameters are passed to functions

by value

The part of a program that uses a function is called the

caller

In modern Python, an int value that grows larger than the underlying hardware int

causes an overflow

A statement that controls the execution of other statements is called a

control structure

What color is `color_rgb(0,255,255)?

cyan

A Python function definition begins with

def

What of the following is not a step in the software development process?

fee setting

The most appropriate data type for storing the value of pi is

float

Computer languages designed to be used and understood by humans are

high-level computer languages

The best structure for implementing a multi-way decision in Python is

if-elif-else

In Python, the body of a decision is indicated by

indentation

Accessing a single character out of a string is called:

indexing

A loop that never terminates is called

infinite

In Python getting user input is done with a special expression called

input

A loop pattern that asks the user whether to continue on each iteration is called a(n)

interactive loop

In a mixed-type expression involving ints and floats, Python will convert

ints to floats

A problem is intractable when

it is not practical to solve

By convention, the statements of a program are often placed in a function called

main

A multiple choice question is most similar to

multi-way decisions

A function can modify the value of an actual parameter only if it's

mutable

A method that changes the state of an object is called a(n)

mutator

Placing a decision inside of another decision is an example of

nesting

Which of the following is not a valid rule of Boolean algebra?

not(a and b) == not(a) or not(b)

Before reading or writing to a file, a file object must be created via

open

What function gives the Unicode value of a character?

ord

The items listed in the parentheses of a function definition are called

parameters

Formal and actual parameters are matched up by

position

A loop structure that tests the loop condition after executing the loop body is called a

post-test loop

Which of the following is not part of the IPO pattern?

program

The process of describing exactly what a computer program will do to solve a problem is called

programming

What of the following is not a Python data type?

rational

Which of the following is not a file-reading method in Python?

readall

An algorithm is like a

recipe

A function can send output back to the program with a(n)

return

Which of the following is the same as s[0:-1]?

s[:len(s)-1]

A loop pattern that continues until a special value is input is called a(n)

sentinel loop

A priming read is part of the pattern for a(n)

sentinel loop

What comand would be used to draw the graphics object shape into the graphics window win?

shape.draw(win)

The term for an operator that may not evaluate one of its subexpressions is

short-circuit

Which of the following is not a built-in operation?

sqrt()

Which of the following are not used in expressions?

statements

Which of the following is the most accurate model of assignment in Python?

sticky note

Which of the following can not be used to convert a string of digits into a number?

str

Which of the following is not a reason to use functions?

to demonstrate intellectual superiority

A structure in which one decision leads to another set of decisions, which leads to another set of decisions, etc., is called a decision

tree

Which string method converts all the characters of a string to upper case?

upper

What command would set the coordinates of win to go from (0,0) in the lower-left corner to (10,10) in the upper-right?

win.setcoords(0, 0, 10, 10)

The string "slots" that are filled in by the format method are marked by:

{}

Computer science is the study of computers. (True/False)

False

In Python conditions, ≠ is written as /=. (True/False)

False

In Python, 4+5 produces the same result type as 4.0+5.0. (True/False)

False

In Python, a function can return only one value. (True/False)

False

In Python, some parameters are passed by reference. (True/False)

False

Computers represent numbers using base-2 (binary) representations. (True/False)

True

Every Python function returns some value. (True/False)

True

Expressions are built from literals, variables, and operators. (True/False)

True

In Python "4" + "5" is "45". (True/False)

True

In Python, x = x + 1 is a legal statement. (True/False)

True

Information can be passed into a function through parameters. (True/False)

True

Information that is stored and manipulated by computers is called data. (True/False)

True

Instance variables are used to store data inside an object. (True/False)

True

One reason to use functions is to reduce code duplication. (True/False)

True

Python identifiers must start with a letter or underscore. (True/False)

True

Python lists are mutable, but strings are not. (True/False)

True

Strings are compared by lexicographic ordering. (True/False)

True

The Boolean operator or return True when both of its operands are true. (True/False)

True

The CPU is the "brain" of the computer. (True/False)

True

The condition x <= y <= z is allowed in Python. (True/False)

True

The counted loop pattern uses a definite loop. (True/False)

True

The float data type is identical to the mathematical concept of a real number. (True/False)

True

The last character of a string s is at position len(s) - 1. (True/False)

True

The number of possible arrangements of n items is equal to n!. (True/False)

True

The split method breaks a string into a list of substrings, and join does the opposite. (True/False)

True

Traditionally, the upper-left corner of a graphics window has coordinates (0,0). (True/False)

True

True or False (True/False)

True

The value of 4! is

24

Which of the following is not a legal identifier?

2spam

The number of distinct values that can be represented using 5 bits is

32

In a flowchart, diamonds are used to show statements, and rectangles are used for decision points. (True/False)

False

A two-way decision is implemented using an if-elif statement. (True/False)

False

An expression that evaluates to either true or false is called

Boolean

Which of the following is not a step in the function-calling process?

Control returns to the point just before the function was called.

A while loop is a post-test loop. (True/False)

False

What kind of object can be used to get text input in a graphics window?

Entry

What is the correct forumla for converting Celsius to Fahrenheit?

F = 9/5(C) + 32

Which line would not be found in a truth table for or?

F T F

A Python string literal is always enclosed in double quotes. (True/False)

False

A Python while implements a definite loop. (True/False)

False

A chaotic function can't be computed by a computer. (True/False)

False

A function may only be called at one place in a program. (True/False)

False

A function that creates a new instance of a class is called an accessor. (True/False)

False

A graphics window always has the title "Graphics Window." (True/False)

False

A loop is used to skip over a section of a program. (True/False)

False

A programming environment refers to a place where programmers work. (True/False)

False

A sentinel loop asks the user whether to continue on each iteration. (True/False)

False

A string always contains a single line of text. (True/False)

False

A substitution cipher is a good way to keep sensitive information secure. (True/False)

False

Which of the following is not an example of secondary memory?

RAM

What graphics class would be best for drawing a square?

Rectangle

Which line would not be found in a truth table for and?

T F T

Which of the following is not true of comments?

They make a program more efficient

A counted loop is designed to iterate a specific number of times. (True/False)

True

A function definition is a sequence of statements that defines a new command. (True/False)

True

A hardware float can represent a larger range of values than a hardware int. (True/False)

True

A sentinel loop should not actually process the sentinel value. (True/False)

True

A simple decision can be implemented with an if statement. (True/False)

True

A single point on a graphics screen is called a pixel. (True/False)

True

A single try statement can catch multiple kinds of errors. (True/False)

True

A variable is used to give a name to a value so it can be referred to in other places. (True/False)

True

ASCII is a standard for representing characters using numeric codes. (True/False)

True

Aliasing occurs when two variables refer to the same object. (True/False)

True

All information that a computer is currently working on is stored in main memory. (True/False)

True

An algorithm can be written without using a programming language. (True/False)

True


Related study sets

Weaknesses of the Articles of Confederation

View Set

Course B1: working with laboratory mice at USC

View Set

03_LA Detective_At the bus station_Pattern 1:Present Simple Tense: have / has

View Set

CONDITIONAL OR IMPLICATION STATEMENTS

View Set

SAT Question of the Day Vocabularies

View Set