Competency 1 - Chapter 2 - Input, Processing, and Output

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

end=' '

use if you don't want a new line of output when it finishes displaying print('One', end=' ') print('Two', end=' ') print('Three') One Two Three

sep=' '

use if you don't want a space between quote marks print ('One', 'Two', 'Three', sep=' ') OneTwoThree

A _____ is any hypothetical person using a program and providing input for it.

user

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

variable

Garbage Collection

when a value in memory is no longer referenced by a variable

Calling the function

when programmers execute a function

// Operator

when the result is positive, fractional part thrown away; when the result is negative, number rounded away from zero to the nearest integer

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

**

Difference between / and //

/ operator gives the result as a floating-point value // operator gives the result as a whole number

This operator performs integer division.

//

Program Development Cycle

1. Design the program *most important step 2. Write the code 3. Correct syntax errors 4. Test the program 5. Correct logic errors

Computer programs typically perform what three steps?

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

3 Step Process

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

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

11

Which of the following statements will cause an error?

17 = x

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 statement executes? result = w//z

2

What would the following display? num = 99 num = 5 print(num)

5

+

Addition Adds two numbers

\"

Causes a double quote mark to be printed

\'

Causes a single quotation mark to be printed

/

Division Divides one number by another and gives the result as a floating-point number

**

Exponent Raises a number to a power

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

False

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

False

(T/F) Variable names can have spaces in them.

False

input function

Format: variable = input(prompt)

Nested Function

Format: function1(function2(argument)) example: hours = int(input('How many hours did you work? '))

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

algorithm

Parentheses

allows you to break any part of a statement that is enclosed into multiple lines without using the line continuation character

Mixed-Type Expression

an expression that uses operands of different data types

Exception

an unexpected error that occurs while a program is running, causing the program to halt if the error is not properly dealt with

Magic Number

an unexplained value that appears in a program's code

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

assignment statement

Which Python statement divides 'a' by 3.14 and assigns the result to 'b'?

b = a/3.14

This built-in function can be used to convert an int value to a float.

float( )

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

flowchart

Numeric Literal

number written in a program

Terminal Symbols

ovals appear at the top and bottom of flowchart marking start and end

Input and Output Symbol

parallelograms represents steps in which the program reads input or displays output

Math Expression

performs a calculation and gives a value

Assume the variable sales references a float value. Write a statement that displays the value rounded to two decimal points.

print(format(sales, '.2f'))

Debug

programmer finds and corrects logic errors in the program

Processing Symbols

rectangles represent steps in which the program performs some process on data, such as mathematical calculation

Underscore

represents a space

Named Constant

represents a value that cannot be changed during the program's execution

When two ** operators share an operand, the operators execute from _____ to _____.

right;left

Comments

short notes placed in different parts of a program, explaining how those parts of the program work you begin a comment with a #

User

simply any hypothetical person that is using a program and providing input for it; sometimes called the end user

Enclose string literals with a set of _____ or _____ marks.

single; double

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

String literal

string that appears in actual code of a program

String Concatenation

the + is used with two strings print('This is ' + ' one string.') This is one string. print('Enter the amount of ' + 'sales for each day and ' + ' press Enter.') Enter the amount of sales for each day and press Enter.

Operands

the values on the right and left of the + operator

Assignment Statement

to create a variable and make it reference a piece of data; example age = 25

Statements in the program execute from _____ to _____.

top; bottom

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

%

//

Integer Division Divides one number by another and gives the result as a whole number

*

Multiplication Multiples one number by another

Math Operations

Please Excuse My Dear Aunt Sally

%

Remainder Divides one number by another and gives the remainder; also known as modulus operator

-

Subtraction Subtracts one number from another

(T/F) In Python, the first character of a variable name cannot be a number.

True

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

True

(T/F) Pseudocode is an informal language that has no syntax rules, and is not meant to be compiled or executed. Instead, the programmers use pseudocode to create models, or "mock-ups" of programs.

True

(T/F) The \t escape character advances the output to the next horizontal tab position.

True

When an operation is performed on an int and a float, the int value will be temporarily converted to a float and the result of the operation will be a float.

True

Line Continuation Character

a backslash \ and enables you to break a statement into multiple lines

Flowchart

a diagram that graphically depicts the steps that take place in a program

Logic Error

a mistake that does not prevent the program from running, but causes it to product incorrect results

Variable

a name that represents a value stored in the computer's memory

Function

a piece of prewritten code that performs an operation

Math Operators

a programmer's tools for performing calculations

String

a sequence of characters that is used as data

Algorithm

a set of well-defined logical steps that must be taken to perform a task

Software Requirement

a single task that the program must perform in order to satisfy the customer

Escape Character

a special character that is preceded with a backslash \

Format Specifier

a string that contains special characters specifying how the numeric value should be formatted

Data Types

categorize value in memory

\\

causes a backslash character to be printed

\n

causes output to be advanced to the next line

\t

causes output to skip over to the next horizontal tab position

End-Line Comment

comment that appears at the end of a line of code explaining the statement that appears in that line

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

comments

float(item)

converts item to a float

int(item)

converts item to an int

Print Function

displays output on the screen

print function

displays output on the screen

A string literal in Python must be enclosed in _____.

either single or double quotes

Assignment Operator

equal sign (=)

Pseudocode

fake code informed language that has no syntax rules and is not meant to be compiled or executed

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

float

When an operation is performed on two float values, the result will be a(n) ____.

float

Which Python statement prompts the user to enter his or her height in feet and assigns the user's input to a variable named height.

height = float(input("Enter height in feet: "))

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

input( )

Argument

inside the parentheses the data you want displayed, data given to a function

When an operation is performed on two int values, the result will be a(n) _____.

int

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

interview the customer

The variable that is receiving the assignment must appear on the _____ side of the = operator.

left

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

logic


Conjuntos de estudio relacionados

CH20-21 Assignment #24-30, 28-34

View Set

Chapter 8: Appendicular Skeleton

View Set

5.2.2 Quiz: Public Policy and Your Safety

View Set

GEOM A, U7L3: Proving That a Quadrilateral Is a Parallelogram

View Set

anatomy - heart and blood vessels

View Set

mastering A&P ch. 23 group 1 modules 23.1-23.5 DSM

View Set

KINE 307 Chapter 14: Sociocultural Influences on Motor Development

View Set

Unit 2 - Solving Multi-step equations

View Set

AP Statistics Chapter 15: Probability Rules!

View Set

MS 2 : Preclass quizzes : exam 1 (ABG, Hematology, Respiratory

View Set