Starting Out with Python, ch. 1-3

¡Supera tus tareas y exámenes ahora con Quizwiz!

Suppose the following statement is in a program: price = 99. 0. After this statement executes, the price variable will reference a value of this data type. a. int b. float c. currency d. str

float

If a math expression adds a float to an int, what will the data type of the result be?

float data type

This built-in function can be used to convert an int value to a float. a. int_to_float() b. float() c. convert ( ) d. int()

float()

A _______ is a diagram that graphically depicts the steps that take place in a program. a. flowchart b. step chart c. code graph d. program graph

flowchart

The physical devices that a computer is made of are referred to as __________. a. hardware b. software c. the operating system d. tools

hardware

Of the following variable names, which is the best one for keeping track of whether a patient has a fever or not? a. temperature b. feverTest c. hasFever d. fever

hasFever

This built-in function can be used to read input that has been typed on the keyboard. a. input() b. get_input() c. read_ input ( ) d. keyboard ( )

input()

A _______ is a sequence of characters. a. char sequence b. character collection c. string d. text block

string

The rules that govern the correct order and usage of the elements of a language are called the _______ of the language

syntax

The rules that must be followed when writing a program are called __________ a. syntax b. punctuation c. key words d. operators

syntax

The part of a computer that runs programs is called a. RAM b. secondary storage c. mam memory d. the CPU

the CPU

The following shows a combination of the values true and false connected by a logical operator. Indicate whether the result of such a combination is true or false. False or True

True

The following shows a combination of the values true and false connected by a logical operator. Indicate whether the result of such a combination is true or false. True or True

True

The following shows a combination of the values true and false connected by a logical operator. Indicate whether the result of such a combination is true or false. not False

True

An extensive encoding scheme that can represent characters for many languages in the world is __________ a. binary numbering b. ASCII c. Unicode d. ENIAC

Unicode

A set of 128 numeric codes that represent the English letters, various punctuation marks, and other characters is __________ a. binary numbering b. ASCII c. Unicode d. ENIAC

ASCII

If you were to look at a machine language program, you would see __________ a. Python code b. a stream of binary numbers c. English words d. circuits

a stream of binary

Explain how short-circuit evaluation works with the "and" and "or" operators.

and operator short circuit - If the left sub expression is false then it will not check the right sub expression because the overall expression has already been determined as false. or operator short circuit - If the left sub expression is true then it will not check the right sub expression because the overall expression has already been determined as true.

If you print a variable that has not been assigned a value, the number 0 will be displayed. T or F

False

Programmers must be careful not to make syntax errors when writing pseudocode programs. T or F

False

This ___________ translates an assembly language program to a machine language program. a. assembler b. compiler c. translator d. interpreter

assembler

A(n) _______ makes a variable reference a value in the computer's memory. a. variable declaration b. assignment statement c. math expression d. string literal

assignment statement

The following shows a combination of the values true and false connected by a logical operator. Indicate whether the result of such a combination is true or false. False or False

False

The following shows a combination of the values true and false connected by a logical operator. Indicate whether the result of such a combination is true or false. not True

False

Variable names can have spaces in them. T or F

False

What does a professional programmer usually do first to gain an understanding of a problem?

First gain the requirement of the program for which it is being designed. Requirements include the task or goals which the program has to perform.

What is the difference between floating-point division and integer division?

Floating point division, /, - returns the output in floating data type. It gives the result in decimal places. Integer division, //, - returns the output in integer value. It ignores the decimal place value.

A compiler a. maintains a collection of programs b. tests a program's logic c. translates source code into executable code d. translates executable code to machine code

translates source code into executable code

Negative numbers are encoded using the __________ technique. a. two's complement b. floating point c. ASCII d. Unicode

two's complement

A _____ is any hypothetical person using a program and providing input for it. a. designer b. user c. gumea p1g d. test subject

user

A _____ is a name that references a value in the computer's memory. a. variable b. register c. RAM slot d. byte

variable

A location in memory used for storing data and given a name in a computer program is called a _________ because the data in the location can be changed.

variable

What number does a bit that is turned on represent? What number does a bit that is turned off represent?

1 represents a bit that is turned on. 0 represents a bit that is turned off.

What types of relationships between values can you test with relational operators?

> greater than < less than >= greater than or equal to <= less than or equal to == equal to != not equal to

What is a compound Boolean expression?

A combination of two or more Boolean expressions using logical operators such as "and", ""or", and "not".

Briefly describe how the "or" operator works.

An expression formed by the "or" operator is false only when both the 'first' and 'second' sub expressions are false. If the left sub expression is true then it will not check the right sub expression because the overall expression has already been determined as true, this is called "short cut evaluation".

A(n) _____ expression has a value of either true or false. a. binary b. decision c. unconditional d. Boolean

Boolean

What is a Boolean expression?

Boolean expressions check the truth of an expression, it checks whether the expression is true or false.

When a program runs on a computer, it is stored in _______.

RAM

This is a volatile type of memory that is used only for temporary storage while a program is running. a. RAM b. secondary storage c. the disk drive d. the USB drive

RAM (Random Access Memory)

What type of software controls the internal operations of the computer's hardware?

System Software. Such as Windows, Linux, Mac OS

A decision structure can be nested inside another decision structure. T or F

True

An interpreter is a program that both translates and executes the instructions in a high level language program. T or F

True

Any piece of data that is stored in a computer's memory must be stored as a binary number. T or F

True

The following shows a combination of the values true and false connected by a logical operator. Indicate whether the result of such a combination is true or false. True or False

True

When you write an if-else statement, under what circumstances do the statements that appear after the else clause execute?

When the if condition is false the program follows the else clause.

A bit is a. a metallic rod inserted into a horses mouth to control it while riding. b. a small amount of data. c. an alternative term for byte. d. an electronic device used in computers. e. a binary digit, like 0 or 1.

a binary digit, like 0 or 1

At each step of its operation, the input to a Central Processing Unit is: a. a program. b. an instruction. c. main memory. d. a control unit.

an instruction

In the __________ numbering system, all numeric values are written as sequences of Os and 1s. a. hexadecimal b. binary c. octal d. decimal

binary

A byte is made up of eight __________ a. CPUs b. instructions c. variables d. bits

bits

A __________ is enough memory to store a letter of the alphabet or a small number. a. byte b. bit c. switch d. transistor

byte

A(n) _________ program translates a high-level language program into a separate machine language program. a. assembler b. compiler c. translator d. utility

compiler

A _____ structure can execute a set of statements only under certain circumstances. a. sequence b. circumstantial c. decision d. Boolean

decision

A(n) _____ structure tests a condition and then takes one path if the condition is true, or another path if the condition is false. a. if statement b. single alternative decision c. dual alternative decision d. sequence

dual alternative decision

A _____ is a Boolean variable that signals when some condition exists in the program. a. flag b. signal c. sentinel d. siren

flag

You use a(n) _____ statement to write a single alternative decision structure. a. test-jump b. if c. if-else d. if-call

if

A binary digit a. is either positive or negative. b. is zero or one. c. requires one byte of storage. d. is 2. e. is none of the above.

is zero or one

The words that make up a high-level programming language are called __________ a. binary instructions b. mnemonics c. commands d. key words

key words

Words that have a special meaning in a programming language are called ________.

keywords

Today, CPUs are small chips known as __________ a. ENIACs b. microprocessors c. memory chips d. operating systems

microprocessors

What are the short words that are used in assembly language called?

mnemonics

A compound Boolean expression created with the ____ operator is true if either of its subexpressions is true. a. and b. or c. not d. either

or

Monitors, printers, status lights are all examples of _______ devices.

output

The tiny dots of color that digital images are composed of are called __________ a. bits b. bytes c. color packets d. pixels

pixels

A(n) is a set of instructions that a computer follows to perform a task. a. compiler b. program c. interpreter d. programming language

program

What best defines a "programming language"? a. It allows us to control a computer. b. It allows us to make a calculation. c. It allows to execute a program. d. It allows us to express an algorithm.

It allows us to express an algorithm

Why is the CPU the most important component in a computer?

It is the brain of the computer and is the place that actually runs the programs.

What are the words that make up a high-level programming language called?

Keywords because they are the words that convey special meaning to the compiler or interpreter.

Which statement is NOT true: a. Machine languages can be used to express algorithms. b. Machine languages can be used to write programs that can run on any machine. c. Machine language consists of zeros and ones. d. Machine language is produced by compilers.

Machine languages can be used to write programs that can run on any machine.

What is a single alternative decision structure?

Single alternative decision structure is a control structure that only provides one alternative path of execution. If the condition is true the alternative path is taken, if the condition is false the alternative path is skipped.

What is a control structure?

The logical design which is used to control or handle the execution order of statements.

A compound Boolean expression created with the "and" operator is true only when both subexpressions are true. T or F

True

The following shows a combination of the values true and false connected by a logical operator. Indicate whether the result of such a combination is true or false. True and True

True

RAM, random-access memory, is called that because: a. it is optimized for random number processing. b. accesses are randomized to prevent clogging the control lines. c. you can pick any two random locations and it will take the same time to access the data. d. when power is turned off, its contents are lost and replaced by random bits. e. none of the above.

You can pick any two random locations and it will take the same time to access the data.

In the __________ part of the fetch-decode-execute cycle, the CPU determines which operation it should perform. a. fetch b. decode c. execute d. immediately after the instruction is executed

decode

Real numbers are encoded using the _______ technique. a. two's complement b. floating point c. ASCII d. Unicode

floating point

You use a(n) _____ statement to write a dual alternative decision structure. a. test-jump b. if c. if-else d. if-call

if-else

What statement do you use in Python to write a dual alternative decision structure?

if..... else

Mice, trackpads, keyboards, scanners, joysticks are all examples of ________ devices.

input

Application software a. processes applications for jobs, school admission, etc. b. is any software that runs with the support of the operating system. c. was invented by Microsoft. d. is applied to the computer for the purpose of running the operating system. e. none of the above.

is any software that runs with the support of the operating system.

and, or, and not are _____ operators. a. relational b. logical c. conditional d. ternary

logical

Computers can only execute programs that are written in __________ a. Java b. assembly language c. machine language d. Python

machine language

The computer stores a program while the program is running, as well as the data that the program is working with, in __________ a. secondary storage b. the CPU c. main memory d. the microprocessor

main memory

The _____ operator takes a Boolean expression as its operand and reverses its logical value. a. and b. or c. not d. either

not

When a program is not running, it is stored a. on a disk. b. in level-2 cache (L2). c. in main memory. d. on the ethernet or wifi.

on a disk

A video display is a(n) ________ device. a. output b. input c. secondary storage d. main memory

output

The symbols >, <, and == are all _____ operators. a. relational b. logical c. conditional d. ternary

relational

Flash drives, CDs, external disks are all examples of ________ storage (memory) devices.

secondary

A type of memory that can hold data for long periods of time, even when there is no power to the computer, is called __________ a. RAM b. main memory c. secondary storage d. CPU storage

secondary storage

A _____ structure provides one alternative path of execution. a. sequence b. single alternative decision c. one path alternative d. single execution decision

single alternative decision

The code that a programmer writes is called ________ code.

source

In a math expression, multiplication and division takes place before addition and subtraction. T or F

True

Machine language is the only language that a CPU understands. T or F

True

Main memory is also known as RAM. T or F

True

A program can be made of only one type of control structure. You cannot combine structures. T or F

False

This symbol marks the beginning of a comment in Python. a. & b. * c. ** d. #

#

This operator performs division, but instead of returning the quotient it returns the remainder. a. % b. * c. ** d. /

%

This is an operator that raises a number to a power. a. % b.* c. ** d. /

**

This operator performs integer division. a. // b. % c. ** d. /

//

A bit that is turned off represents the following value: a. 1 b. -1 c. 0 d. "no"

0

Which of the following statements will cause an error? a. x = 17 b. 17 = X C. X = 99999 d. X = '17'

17 = X

Which of the following is NOT a legal identifier? a. outrageouslyAndShockinglyLongRunon b. _42 c. _ d. lovePotionNumber9 e. 7thheaven

7thheaven

What is a flag variable?

A Boolean variable that when the flag value is true it means the condition exists, while a false value of the flag means the condition does not exist.

What values can you assign to a bool variable?

A bool variable can only store one of two possible values: True or False. Example: x = true; y = false

Which of the following is not true? a. An algorithm allows ambiguity. b. An algorithm, when carried out, must eventually stop. c. An algorithm, can be carried out by a human being.

An algorithm allows ambiguity.

What is a decision structure?

Decision structures are control structures which provide a different set of instructions to be executed based on different choices made by the user.

What is pseudocode?

It is an informal description of the algorithm.

Which of the following names in a program is equivalent to the name int? a. Int b. INT c. All of the above d. None of the above

None of the above

Computer programs typically perform what three steps?

Receiving of input Processing of input Producing output from received input

Replace the underlines with the words in parentheses that follow: The ____ solves the ____ of a ____ by expressing an ____ in a ____ to make a ____ that can run on a ____. algorithm computer problems program programmer programming language user

The programmer solves the problems of a user by expressing an algorithm in a programming language to make a program that can run on a computer.

In Python the first character of a variable name cannot be a number. T or F

True

The character escape sequence to represent a double quote is:

\"

The character escape sequence to represent a single quote is:

\'

The character escape sequence to represent a backslash is:

\\

The character escape sequence to force the cursor to go to the next line is:

\n

The character escape sequence to force the cursor to advance forward to the next tab setting is:

\t

Which of the following IS a legal identifier? a. 5_And_10 b. Five_&_Ten c. ____________ d. LovePotion#9 e. "Hello World"

____________ Correct - Weird, but valid.

A byte in memory is identified by a unique number called its _______.

address

A(n) _______ is a set of well-defined logical steps that must be taken to perform a task. a. logarithm b. plan of action c. logic schedule d. algorithm

algorithm

A component that collects data from people or other devices and sends it to the computer is called __________ a. an output device b. an input device c. a secondary storage device d. main memory

an input device

Short notes placed in different parts of a program explaining how those parts of the program work are called _______. a. comments b. reference manuals c. tutorials d. external documentation

comments

An error in a program that involves a violation of language rules will be detected at _______ time.

compile

A string literal in Python must be enclosed in a. parentheses. b. single-quotes. c. double-quotes. d. either single-quotes or double-quotes.

either single-quotes or double-quotes

A _______ error does not prevent the program from running, but causes it to produce incorrect results. a. syntax b. hardware c. logic d. fatal

logic

The purpose of testing a program with different combinations of data is to expose run-time and _______ errors.

logical

Of the following variable names, which is the best one for keeping track of whether an integer might be prime or not? a. divisible b. isPrime c. mightBePrime d. number

mightBePrime

In the expression 12 + 7, the values on the right and left of the + symbol are called a. operands b. operators c. arguments d. math expressions

operands

An informal language that has no syntax rules and is not meant to be compiled or executed is called _______. a. faux code b. pseudocode c. Python d. a flowchart

pseudocode

A _______ is a single function that the program must perform in order to satisfy the customer. a. task b. software requirement c. prerequisite d. predicate

software requirement

Word processing programs, spreadsheet programs, email programs, web browsers, and games are all examples of utility programs. T or F

False

You can write any program using only sequence structures. T or F

False

Which of these is not a programming language? a. C b. C++ c. HTML d. Java

HTML

Assembly language is considered a high-level language. T or F

False

The following shows a combination of the values true and false connected by a logical operator. Indicate whether the result of such a combination is true or false. False and True

False

The following shows a combination of the values true and false connected by a logical operator. Indicate whether the result of such a combination is true or false. True and False

False

Today, CPUs are huge devices made of electrical and mechanical components such as vacuum tubes and switches. T or F

False

Windows, Linux, Android, iOS, and Mac OSX are all examples of application software. T or F

False

What is a flag and how does it work?

Flags are Boolean variables that indicate whether a specific condition exists or not. When the flag value is true it means the condition exists, while a false value of the flag means the condition does not exist.

Explain what is meant by the term "conditionally executed."

Is a set of statements that are executed only when a certain condition is true. If the condition is false they will not be executed. Also called a single alternative decision structure.

What would you call a device that works with binary data?

A digital device. Such as a computer or digital camera.

Briefly describe how the "and" operator works.

An expression formed by the "and" operator is true only when both the 'first' and 'second' sub expressions are true. If the left sub expression is false then it will not check the right sub expression because the overall expression has already been determined as false, this is called "short cut evaluation".

When a program runs on a computer, the part of the computer that carries out the instructions is called the _______.

CPU

What is the difference between a compiler and an interpreter?

Compiler Compiler is a program that translates a high level code into machine language. In case of this, compiling and executing are two different processes. Compiler scans the entire program on the whole and report for errors. Example: C++ programming language uses compiler. Interpreter Interpreter is a special program that does the translation and simultaneously executes each and every instruction also. In this, both translation and execution are done simultaneously. Interpreter performs the translation and execution line by line and reports the error if any. Example: Python Programming language uses interpreter.

How does a dual alternative decision structure work?

Dual alternative decision structure is a control structure with two possible paths of execution. The program will follow one path if condition equals true and another if condition equals false.

You need to test a condition and then execute one set of statements if the condition is true. If the condition is false, you need to execute a different set of statements. What structure will you use?

Dual alternative decision structure.

A single alternative decision structure tests a condition and then takes one path if the condition is true, or another path if the condition is false. T or F

False

A syntax error does not prevent a program from being compiled and executed. T or F

False

Images, like the ones you make with your digital camera, cannot be stored as binary numbers. T or F

False

The following shows a combination of the values true and false connected by a logical operator. Indicate whether the result of such a combination is true or false. False and False

False

An operating system a. is the chief hardware unit in a computer. b. is loaded into the computer each time it needs to carry out an operation. c. ensures that programs will not run on the computer at the same time. d. allocates resources like memory to programs that are running. e. all of the above.

allocates resources like memory to programs that are running.

A compound Boolean expression created with the _____ operator is true only if both of its subexpressions are true. a. and b. or c. not d. both

and

When determining whether a number is inside a range, which logical operator is it best to use?

and


Conjuntos de estudio relacionados

Multiple choice Midterm #2 review macroecon

View Set