1/88
CSC171QR VanBerkum Python
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
Computer
A machine that stores and manipulates information under the control of a changeable program.
Computer Program
A detailed, step-by-step set of instructions telling a computer what to do.
Programming / Coding
The process of creating software.
Algorithm
A step-by-step process for solving a problem or achieving a desired result.
CPU (Central Processing Unit)
The "brain" of the computer; carries out all basic operations on data.
Main Memory (RAM)
Fast, volatile memory that stores programs and data the CPU is currently using.
Secondary Memory
Permanent storage (e.g., hard drive, SSD).
Fetch-Execute Cycle
The process the CPU uses to execute a program
Operating System (OS)
Software that controls the computer's hardware resources and manages program execution.
Kernel
The core part of the OS that is always running.
Machine Language
The low-level language of 1s and 0s that the hardware can directly understand.
Compiler
Translates an entire high-level program into machine language before execution.
Interpreter
Translates and executes a high-level program one instruction at a time.
Specification
A description of what a program will do (inputs, outputs, and their relationship).
Pseudocode
A precise but informal English description of an algorithm.
IPO (Input, Process, Output)
A common program design model.
Test/Debug
The phase where you find and fix errors ("bugs") in the program.
Syntax
The precise form or grammar of a programming language structure.
Semantics
The precise meaning of a programming language structure.
Identifier
A name given to variables, functions, etc.
Reserved Words / Keywords
Words that are part of the Python language itself and cannot be used as identifiers.
Expression
A fragment of code that produces or calculates a new data value.
Literal
A representation of a specific value in code (e.g., 3.9, "Hello").
Statement
A complete line of code that performs an action.
Assignment Statement
Simultaneous Assignment
Assigning multiple variables at once (e.g., sum, diff = x+y, x-y).
Data Type
Determines what values a variable can have and what operations can be performed on it.
Integer (int)
A whole number without a fractional part.
Floating-Point (float)
A number that has a decimal fraction.
Type Conversion
Changing a value from one data type to another.
Explicit Typing
When the programmer directly controls the type conversion.
// (Operator)
Integer Division (floor division).
% (Operator)
Modulo (Remainder).
Math Library
A module providing mathematical functions (e.g., math.sqrt()).
String (str)
A sequence of characters. Immutable.
Indexing
Accessing a single character in a string using its position.
Slicing
Accessing a substring from a start index up to, but not including, an end index.
Concatenation
Gluing strings together with the + operator.
Repetition
Repeating a string with the * operator.
List
A sequence of arbitrary elements. Mutable.
Mutable
Can be changed "in place".
Immutable
Cannot be changed after it is created.
.append(x)
Adds an element x to the end of a list.
.extend(list2)
Adds all elements from list2 to the end of a list.
ASCII / Unicode
Standards that define a numeric code for every character.
ord(character)
Returns the numeric (ordinal) code for a single-character string.
chr(number)
Returns the character string for a given numeric Unicode code.
Function
A subprogram; a named sequence of statements that performs a specific operation.
Function Definition
The statement that creates a function (def function_name()
Call / Invoke
Using a function in a program.
Parameter
A variable that is initialized when the function is called.
Formal Parameter
The variable name listed in the function definition.
Actual Parameter / Argument
The actual value passed into the function when it is called.
Return Value
The value that a function sends back using the return statement.
Scope
The part of a program where a variable can be referenced.
Local Variable
A variable defined inside a function.
Global Variable
A variable defined outside of any function.
Pass by Value
The method Python uses for parameters. The function receives a copy of the value.
Stack
A data structure that manages function calls and local variables.
Definite Loop
A loop that executes a predetermined number of times (a for loop).
for Loop
for in
Loop Index
The variable that takes on each successive value in the sequence.
range() function
Generates a sequence of numbers.
Control Structure
A statement that alters the sequential flow of control in a program.
Decision Structures
Statements that allow a program to execute different instructions for different cases.
Condition
A Boolean expression that is either True or False.
Boolean Expression
An expression that produces either True or False.
if Statement (One-Way Decision)
if
if-else Statement (Two-Way Decision)
Provides two mutually exclusive paths of execution.
if-elif-else Statement (Multi-Way Decision)
Handles multiple, mutually exclusive cases.
Nesting
Putting one control structure inside another.
== (Operator)
Equal to (comparison).
Relational Operators
==, !=,
Lexicographic Ordering
The order used for string comparisons, based on Unicode/ASCII values.
Accumulator Algorithm
A pattern where you build up a result in a variable, often inside a loop.
Factorial (n!)
n * (n-1) * (n-2) * … * 1
Local scope
A variable can only be referenced where it was created (Local Use)
Global scope
A variable can be referenced throughout the whole program (Global use, throughout)
Immutability
A variable's value cannot be modified "in-place"
Mutability
A variable's value can be modified "in-place"
What does the following expression evaluate to?
chr(ord('a'))
'a'
Which of the following statements about Strings and Lists are true?
Strings are not mutable and Lists are mutable (Able to be changed in place)
Which of the following are valid boolean expressions? Assume that all variables are valid.
a: x % 3 == 1
b: (x > 5) > y
c: (x != 8) < y
d: False
e: x = 4
d and a. (e assigns value, b&c both sides should be both numeric or both Boolean)
Given the following String, called "phrase", which expression will evaluate to: "123"
phrase = "123 fizzbuzz"
phrase[0:3]
Given the following String, called "phrase", which expression will evaluate to: "buzz"
phrase = "123 fizzbuzz"
phrase[8:]
What will the following expression evaluate to?
[1, 2, 3] + 4
[1, 2, 3, 4]
What will the following expression evaluate to?
[1, 2, 3] * 2
[1, 2, 3, 1, 2, 3]
Which of the following will evaluate to the float value 12.0
Select all that apply.
Correct: 3.0 * 4, float(int(12.9)), 24 / 2.
Incorrect: 3 * 4, round(11.9), 24 // 2
True or False: Computers are more efficient with Floating-point values than with Integers
False