CSC115 Final Flashcards
(83 cards)
What are the arithmetic operators in Python?
+ : addition
- : subtraction
* : multiplication
/ : division
// : floor division (removes decimal)
% : modulus (returns remainder)
** : exponentiation
Python follows PEMDAS for order of operations.
What is the difference between pseudocode and an algorithm?
Algorithm: Step-by-step instructions for solving a problem.
Pseudocode: A human-readable version of an algorithm using programming-like syntax.
What does a flowchart do?
A visual diagram that shows the flow of a program’s logic.
Uses symbols like: Oval: Start/End, Parallelogram: Input/Output, Rectangle: Process, Diamond: Decision (if/else)
What are the components of the Input → Process → Output model?
Input: Data received (e.g., user typing)
Processing: Logic and calculations applied to input
Output: Final result shown to user.
What are the types of computer memory?
RAM: Volatile memory, erased when power is off.
Secondary Storage: Long-term memory like hard drives (retains data after shutdown).
Main Memory refers to RAM.
What is camelCase?
Variable naming where the first word is lowercase, and each subsequent word starts with uppercase.
Example: totalScore, userInput
How are expressions evaluated in Python?
Python follows math precedence (PEMDAS):
1. **
2. *, /, //, %
3. +, -
Parentheses can override this order.
What are named constants in Python?
Assigned once, not changed later.
Written in ALL CAPS: PI = 3.14.
What are logical operators in Python?
and: True if both conditions are true.
or: True if at least one condition is true.
not: Reverses Boolean value.
What are augmented assignment operators?
+=, -=, *=, /=, %=, **= etc.
Shortcuts for updating variables: x += 1 means x = x + 1.
What is the difference between global variables and global constants?
Global variable: declared outside all functions, accessible globally.
Global constant: conventionally ALL CAPS, should not be changed.
What are some functions in the math module?
ceil(x) – rounds up to the nearest integer
floor(x) – rounds down
sqrt(x) – square root
hypot(x, y) – hypotenuse = √(x² + y²).
What is the difference between random() and uniform()?
random() – float from 0.0 to 1.0
uniform(a, b) – float between a and b.
What is the syntax for using range()?
Syntax: range(start, stop, step)
Example: range(1, 10, 2) → 1, 3, 5, 7, 9
What are functions in modules?
Modules are .py files with functions and variables.
Example: import mymodule
mymodule.greet()
What are the file modes in Python?
‘r’ – read
‘w’ – write (overwrites file)
‘a’ – append
‘w’ clears the file if it exists.
What is the difference between lists and tuples?
List: [], mutable
Tuple: (), immutable
Use tuples when data shouldn’t change.
What is the difference between ValueError and IOError?
ValueError: wrong value (e.g., int(“abc”))
IOError: file errors (e.g., file not found)
except catches errors to prevent crashes.
What are records in files?
One line = one record
Can store records as list items or dictionaries.
What is a program?
A program is a set of instructions executed by a computer.
What is RAM?
RAM = volatile memory; used temporarily while running.
What is secondary storage?
Secondary storage = hard drive, retains data long-term.
What is a byte?
Byte = 8 bits.
What does the CPU understand?
CPU understands only machine language (binary).