Chapter 2 Flashcards
Program development cycle:
-design the program
-write the code
-correct syntax errors
-test the program
-correct logic errors
Most important part of the program development cycle
design
What is algorithm?
Set of well-defined logical steps that must be taken to perform a task
What is pseudocode?
Fake code
What is Flowchart?
A diagram that graphically depicts the steps in a program
-Ovals are terminal symbols
-Parallelograms are input and output symbols
-Rectangles are processing symbols
-Symbols are connected by arrows that represent the flow of the program
What three-step process do computers typically perform?
-Receive input
Input: any data that the program receives while it is running
-Perform some process on the input
Ex: mathematical calculation
-Produce output
A piece of prewritten code that performs an operation
Function
What displays output on the screen?
The print function
Data given to the function
Argument
Ex. data that is printed to screen
A sequence of characters that is used as data
String
String that appears in actual code of a program
String literal
-Must be enclosed in a single (‘) or double (“) quote marks
Notes of explanation within a program
Comments
-Intended for a person reading the programs code
-Being with #
What appears at the end of a line code?
End-line comment
-typically explains the purpose of that line
Name that represents a value stored in the computer memory
-Used to access and manipulate data stored in memory
-References the value it represents
Variable
Used to create a variable and make it reference data
-General format is variable = expression
Ex: age = 29
Assignment operator: the equal sign (=)
Assignment statement
Removal of values that are no longer referenced by variables. Carried out by Python interpreter.
Garbage collection
Data Types
Categorize value in memory
e.g. int for integer, float for real number, str used for storing strings in memory
Number written in program
-no decimal point considered int, otherwise, considered float
Numeric literal
Raises a number to a power
Ex: x ** y = x^y
Exponent operator (**)
Performs division and returns the remainder
aka modulus operator
Ex: 4%2=0, 5%2=1
Remainder operator (%)
Allows to break a statement into multiple lines
result = var1 * 2 + var2 * 3 + \
var3 * 4 + var4 * 5
Multiline continuation character ()
An unexplained numeric value that appears in a programs code
Ex: amount = balance * 0.069
Magic number