Test 1 Review

Ace your homework & exams now with Quizwiz!

What is pseudocode?

"Fake code". An informal language that has no syntax rules, and is not meant to be compiled or executed. Instead, programmers use pseudocode to create models, or "mock-ups" of programs.

This symbol marks the beginning of a comment in Python.

#

This operator performs division, but instead of returning the quotient it returns the remainder.

%

Computer programs typically perform what three steps?

(1) Input is received. (2) Some process is performed on the input. (3) Output is produced.

This is an operator that raises a number to a power.

**

This operator performs integer division.

//

A bit that is turned off represents the following value: __________.

0

Use what you have learned about the binary numbering system to convert the following decimal numbers to binary: 11 65 100 255

1011 1000001 1100100 11111111

What will the following display? a = 5 b = 2 c = 3 result = a + b * c print(result)

11

Assume the variables result, w, x, y, and z are all integers, and that w = 5, x = 4, y = 8, and z = 2. What value will be stored in result after each of the following statements execute? a. result = x + y b. result = z * 2 c. result = y / x d. result = y - z e. result = w // z

12 4 2 6 2

Use what you have learned about the binary numbering system to convert the following binary numbers to decimal: 1101 1000 101011 111100

13 8 43 60

Which of the following statements will cause an error?

17 = x

What is the difference between a compiler and an interpreter?

A compiler is a program that translates a high-level language program into a separate machine language program. The machine language program can then be executed any time it is needed. An interpreter is a program that both translates and executes the instructions in a high-level language program. As the interpreter reads each individual instruction in the program, it converts it to a machine language instruction and then immediately executes it. Because interpreters combine translation and execution, they typically do not create separate machine language programs.

Use the internet to research the history of the Python programming language, and answer the following questions: A. Who was the creator of Python? B. When was Python created? C. In the Python programming community, the person who created Python is commonly referred to as "BDFL". What does this mean?

A. Guido Van Rossum B. 1989 C. Benevolent Dictator for Life

A set of 128 numeric codes that represent the English letters, various punctuation marks, and other characters is ______________ .

ASCII

A(n) ____________ expression has a value of either True or False.

Boolean

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

False

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.

False

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

False

Assembly language is considered a high-level language.

False

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

False

Images, like the ones created with your digital camera, cannot be stored as binary numbers.

False

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

False

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

False

Variable names can have spaces in them.

False

Windows, Linux, Android, iOS, and macOS are all examples of application software.

False

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

False

You can write any program using only sequence structures.

False

A ____________ is a Boolean variable that signals when some condition exists in the program.

Flag

What will the following statement display? print('George', 'John', 'Paul', 'Ringo', sep='@')

George@John@Paul@Ringo

Today, CPUs are small chips known as _______________.

Microprocessors

This is a volatile type of memory that is used only for temporary storage while a program is running.

RAM

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

True

A decision structure can be nested inside another decision structure.

True

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

True

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

True

In Python, the first character of a variable name cannot be a number.

True

In a math expression, multiplication and division take place before addition and subtraction.

True

Machine language is the only language that a CPU understands.

True

Main memory is also known as RAM.

True

If you were to look at a machine language program, you would see ____________ .

a stream of binary numbers

A(n) ________ is a set of well-defined logical steps that must be taken to perform a task.

algorithm

A component that collects data from people or other devices and sends it to the computer is called ____________

an input device

A magic number is _______________

an unexplained value that appears in a program's code

A compound Boolean expression created with the ___________ operator is true only if both of its subexpressions are true.

and

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

and

The __________ translates an assembly language program to a machine language program.

assembler

A(n) _____________ makes a variable reference a value in the computer's memory.

assignment statement

In the ______________ numbering system, all numeric values are written as sequences of 0s and 1s.

binary

A byte is made up of eight _________ .

bits

A ______________ is enough memory to store a letter of the alphabet or a small number.

byte

Short notes placed in different parts of a program explaining how those parts of the program work are called ______________

comments

A(n) program translates a high-level language program into a separate machine language program.

compiler

In the __________ part of the fetch-decode-execute cycle, the CPU determines which operation it should perform.

decode

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

digital device

Write a Python statement that subtracts the variable down_payment from the variable total and assigns the result to the variable due.

due = total - down_payment

A string literal in Python must be enclosed in _______________

either single-quotes or double-quotes.

Suppose the following statement is in a program: price = 99.0. After this statement executes, the price variable will reference a value of which data type?

float

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

float

Which built-in function can be used to convert an int value to a float?

float()

Real numbers are encoded using the ________ technique.

floating point

A __________is a diagram that graphically depicts the steps that take place in a program.

flowchart

The physical devices that a computer is made of are referred to as _______________.

hardware

Write Python code that prompts the user to enter his or her height and assigns the user's input to a variable named height.

height = int(input('Enter your height: '))

You use a(n) _______________ statement to write a single alternative decision structure.

if

Write an if statement that assigns 0 to the variable b, and assigns 1 to the variable c if the variable a is less than 10.

if a < 10: b = 0 c = 1

Write nested decision structures that perform the following: If amount1 is greater than 10 and amount2 is less than 100, display the greater of amount1 and amount2.

if amount1 > 10 and amount2 < 100: if amount1 > amount2: print (amount1) elif amount2 > amount1: print (amount2) else: print('Both values are the same.')

Write an if-else statement that determines whether the points variable is outside the range of 9 to 51. If the variable's value is outside this range it should display "Invalid points." Otherwise, it should display "Valid points."

if points < 9 or points > 51: print ('Invalid points') else: print ('Valid points')

The following code contains several nested if-else statements. Unfortunately, it was written without proper alignment and indentation. Rewrite the code and use the proper conventions of alignment and indentation. if score >= A_score: print('Your grade is A.') else: if score >= B_score: print('Your grade is B.') else: if score >= C_score: print('Your grade is C.') else: if score >= D_score: print('Your grade is D.') else: print('Your grade is F.')

if score >= A_score: print('Your grade is A.') else: if score >= B_score: print('Your grade is B.') else: if score >= C_score: print('Your grade is C.') else: if score >= D_score: print('Your grade is D.') else: print('Your grade is F.')

A(n) __________ structure tests a condition and then takes one path if the condition is true, or another path if the condition is false.

if statement

Write an if statement that uses the turtle graphics library to determine whether the turtle is inside of a rectangle. The rectangle's lower-left corner is at (100, 100) and its upper-right corner is at (200, 200). If the turtle is inside the rectangle, hide the turtle.

if turtle.xcor() > 100 and turtle.xcor() < 200 and turtle.ycor() > 100 and turtle.ycor() < 200: turtle.hideturtle()

Which built-in function can be used to read input that has been typed on the keyboard?

input()

The words that make up a high-level programming language are called .

key words

A _________ error does not prevent the program from running, but causes it to produce incorrect results.

logic

and, or, and not are ___________ operators.

logical

Computers can only execute programs that are written in ____________.

machine language

The computer stores a program while the program is running, as well as the data that the program is working with, in ____________.

main memory

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

mnemonic

A ____________ is a name that represents a value that does not change during the program's execution.

named constant

The ____________ operator takes a Boolean expression as its operand and reverses its logical value.

not

In the expression 12 + 7, the values on the right and left of the + symbol are called ____________

operands

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

operating system

A compound Boolean expression created with the ___________ operator is true if either of its subexpressions is true.

or

A video display is a(n) ______________ device.

output

The tiny dots of color that digital images are composed of are called _______________.

pixels

Assume the following statement has been executed: number = 1234567.456 Write a Python statement that displays the value referenced by the number variable formatted as 1,234,567.5

print(format(number, ',.1f'))

A(n) __________ is a set of instructions that a computer follows to perform a task.

program

An informal language that has no syntax rules and is not meant to be compiled or executed is called ______________.

pseudocode

The symbols >, <, and == are all __________ operators.

relational

A type of memory that can hold data for long periods of time, even when there is no power to the computer, is called _______________.

secondary storage

A _____________ structure provides one alternative path of execution.

single alternative decision

A _________ is a single function that the program must perform in order to satisfy the customer.

software requirement

A ______________ is a sequence of characters.

string

The rules that must be followed when writing a program are called .

syntax

The part of a computer that runs programs is called _____________ .

the CPU

Write a Python statement that multiplies the variable subtotal by 0.15 and assigns the result to the variable total.

total = subtotal * 0.15

Write the turtle graphics statements to draw a square that is 100 pixels wide on each side and filled with the color blue.

turtle.fillcolor('blue') turtle.begin_fill() turtle.forward(100) turtle.left(90) turtle.forward(100) turtle.left(90) turtle.forward(100) turtle.left(90) turtle.forward(100) turtle.end_fill()

Negative numbers are encoded using the ___________ technique.

two's complement

An extensive encoding scheme that can represent characters for many languages in the world is ___________________ .

unicode

A _____________ is a name that references a value in the computer's memory.

variable


Related study sets

Combo with "music,art,dance, theater" and 13 others

View Set

Motion and Forces Chapter 1 Study Guide

View Set

Disorders of the bladder and lower urinary tract Ch. 35

View Set

The Development of Modernist Art: the Early 20th Century (Ism's Galore!) by tennislove (Chapter 33)

View Set

Chapter 28 Child, Older Adult, and Intimate Partner Violence

View Set

Oral tissues; osteoblasts, osteocytes, and osteoclasts

View Set