Lecture 2 - Input, Processing, and Output Flashcards
What is the three-step process a typical computer program performs?
obtain input: any data the program receives while it is running
perform some processing on the input: this could be simple (e.g., arithmetic calculation) or complex (e.g., full nature-language processing algorithm)
produce output: based on the input and processing
What is a function?
some pre-written code that performs an operation
A function is a black box (probably containing programming language statements, but not always) that accepts arguments from a program statement and which calculates a result value that is returned to the program statement ( where that value might be ignored!) and which also might have some possible side-effect on the computer itself.
What is print() ?
a built-in Python function that displays textual output onto the screen / console
What is argument?
the data given to a function
e.g., print(“University of Victoria”) would display the words “University of Victoria”
What is sequential order?
when statements are executed in the order they appear - from top to bottom
What is a string?
a sequence of characters
What is a string literal?
a string whose complete value appears in the code for the program
What are string literals enclosed by?
pairs of single quotes (‘) or pairs of double quotes (“)
There is also a special triple quote (“””) available for string literals (which permits them to span several lines if this is needed)
String literals must be ended using the same quotation mark with which they were begun.
What is a variable?
a name that represents a value stored in memory - we use such names to access and manipulate data in main memory
What is an assignment statement used for?
to associate a variable with a data value
the = symbol is used to indicate assignment
What are some variable naming rules?
Variable names cannot contain spaces
First character must be a letter or an underscore but after the first letter, you may use letters, digits, or underscores
Variable names are case sensitive
Variable names should reflect their purpose
Variable names cannot be a Python keyword
What is the main way that Python denotes comments?
When the # symbol appears on a Python line, Python ignores everything following that symbol.
What is variable reassignment?
Variables may reference different values at different times while a program is running
Values that were once referenced by a variable name but which at some point during the same interpreter session are no longer referenced by any variable name will have their memory-space allocation reclaimed by the interpreter (i.e., technically called garbage collection).
What are data types?
A data type is the way a high-level programming language categorizes a set of values that may be stored in memory and which also indicates the legal operations permitted on such a set.
Some operations may even behave differently depending upon the data type of the values given to the operation.
What are three examples of data types?
integer (or int) floating point (or float) for real numbers string (or str) A variable always has some type for the value assigned to it!