Basics Flashcards
Program
Set of instructions given to a computer
Process of program execution
Ingest information from the real world (input)
Process information internally
Send computed data back to the real world (output)
IDE
Integrated Development Environment
Comments
Short descriptions of non-obvious parts of the code
Information about the code, author and date at top of program
Syntax errors
Program does not conform to the structure required
Logic errors
Program runs but does not work as expected
Escape sequences
Special characters that cannot be represented easily in the program
e.g. tabs, newlines, quotes
2 numeric data types
Integers and float point numbers
Integers
Numeric data type - whole number with no fractional part
Floating point number
Numeric data type - number with fractional part
(precision limited, stores approximation of real number)
Modulus - symbol and function
%, a%b returns remainder of a/b (or subtract the nearest multiple of b from a)
Integer division - symbol and function
//, a//b returns a/b rounded toward negative infinity
Identifiers
Used to name parts of the program
Start with _ or letter, followed by zero or more of _, letter or digit
Reserved identifier words
Words which have a special meaning in python and cannot be used as identifiers
e.g. if, for, else
Variables
Sections of memory where date can be stored
Defined by assigning an initial value
Most variables have names (identifiers)
Input function always returns a _____
string
eval() function
Converts a string into a number
Integer if input is integer
Float if input is not an integer
Increment/decrement syntax
a+=b is equivalent to a=a+b
same for - , * and /
Implicit conversions
One type of of value is converted to another
Type of narrower range is promoted up only
Explicit conversions
Typecast methods such as eval(), float() or int() convert one value type to another
Functions
A named sequence of instructions that perform a collective purpose
Arguments
Items passed into a function