Chapter 2: Input, Processing, and Output Flashcards
Stages of “The Program Development Cycle”:
- Design the Program
- Write the Code
- Correct Syntax Errors
- Test the Program
- Correct Logic Errors
What is a SYNTAX ERROR?
Mistake such as: misspelled key word, missing punctuation, or incorrect use of an operator
What is a LOGIC ERROR?
Mistake that does not prevent the program from running but causes it to produce incorrect results.
What is PSEUDOCODE?
An informal language that has no syntax rules and is not meant to be compiled or executed.
Used by programmers to create models, or “mock-ups” of programs.
What is a FLOWCHART?
Diagram that graphically depicts the steps that take place in a program
Computer programs typically perform a 3 Step Process:
- INPUT is received
- Some PROCESS is performed on the input
- OUTPUT is produced
Print Function
Used to display output on the screen.
Print function SYNTAX:
STRING/STRING LITERAL (str) must be enclosed in a pair of quote marks-
print(‘argument’)
> > > print(‘Hello World’)
Hello world
comments
Notes of explanation that document lines or sections of a program.
- part of the program, but ignored by Python interpreter
- intended for people reading source code
Variable
A name that references a value in the computer’s memory.
Assignment statement
& operator
Used to create variable and make it reference a piece of data
variable = expression
print(the value stored in a variable)
>>> width = 10 >>> length = 5 >>> print(width) 10 >>> print(length) 5 >>> print(length, width) 10 5
VARIABLE Naming Rules
- Cannot use a Python key word
- Cannot contain spaces
- First character must be: a-z, A-Z, or an underscore_
- After first char., may use: a-z, A-Z, 0-9, or underscores_
- Upper & lower case char.’s are distinct
camelCase naming convention
variableName begins with lower case letters & the first char. of the second and subsequent words written in uppercase-
camelCaseNamingConvention
Python allows display of multiple items with one call to the print function by:
Separating items with a comma-
firstName = ‘Jane’
lastName = ‘Doe’
»> print(firstName, lastName)
Jane Doe