Programming

πŸŽ€ PROGRAMMING 511 EXAM CUE CARDS πŸŽ€

πŸƒ Cue Card 1: File Handling

Front:

πŸ“ What are the 4 file modes?

Back:

βœ… r = Read file

βœ… w = Write (creates/overwrites)

βœ… a = Append (adds to file)

βœ… open() = Opens file

Example:

Python

file = open("data.txt", "r")

content = file.read()

file.close()

πŸ’‘ Always remember to close files!

πŸƒ Cue Card 2: If Statements

Front:

πŸ€” When do we use an if statement?

Back:

Used when a condition must be checked.

Python

age = 18


if age >= 18:

print("Adult")

Relational Operators:

Operator

Meaning

==

Equal to

!=

Not equal to

>

Greater than

<

Less than

>=

Greater than or equal

<=

Less than or equal

πŸƒ Cue Card 3: Logical Operators

Front:

🧠 What are logical operators?

Back:

Used to combine conditions.

Python

and

or

not

Examples:

Python

if age >= 18 and age <= 60:

βœ” Both conditions must be true.

Python

if mark >= 50 or bonus == True:

βœ” At least one condition must be true.

πŸƒ Cue Card 4: Nested Decisions

Front:

🌳 What is a nested if?

Back:

An if inside another if.

Python

if salary >= 30000:

if years >= 2:

print("Approved")

πŸ’‘ Used when multiple conditions must be checked.

πŸƒ Cue Card 5: Functions

Front:

βš™ What are the 3 function parts?

Back:

1⃣ Function Definition

Python

def greet():

2⃣ Parameters

Python

def greet(name):

3⃣ Function Call

Python

greet("Natasha")

4⃣ Return Value

Python

def add(a,b):

return a+b

πŸƒ Cue Card 6: While Loops

Front:

πŸ”„ What is a while loop?

Back:

Repeats while condition is True.

Python

count = 1


while count <= 5:

print(count)

count += 1

πŸ’‘ Be careful of infinite loops!

πŸƒ Cue Card 7: Sentinel Values

Front:

πŸšͺ What is a sentinel value?

Back:

A special value that stops a loop.

Python

name = ""


while name != "quit":

name = input("Enter name:")

Here: βœ… Sentinel Value = "quit"

πŸƒ Cue Card 8: Nested Loops

Front:

πŸ” What is a nested loop?

Back:

A loop inside another loop.

Python

for row in range(3):

for col in range(3):

print("*", end="")

Output:


***

***

***

⭐ Commonly used for pattern questions.

πŸƒ Cue Card 9: Input Validation

Front:

βœ” What is input validation?

Back:

Ensures correct user input.

Python

age = input("Age: ").strip()


while not age.isdigit():

age = input("Enter valid age: ")

Important Functions:

βœ… int()

βœ… float()

βœ… lower()

βœ… strip()

πŸƒ Cue Card 10: Debugging

Front:

🐞 What errors can appear?

Back:

Syntax Error

Code written incorrectly.

Python

if age > 18

Missing :

Logic Error

Program runs but answer is wrong.

Python

total = price - vat

Should have been:

Python

total = price + vat

πŸƒ Cue Card 11: Business Calculations

Front:

πŸ’° What business calculations may appear?

Back:

VAT

Python

vat = amount * 0.15

Discount

Python

discount = price * 0.10

Penalty

Python

penalty = balance * 0.05

Always:

Input

Process

Output

πŸƒ Cue Card 12: IPO Principle

Front:

πŸ“Š What is IPO?

Back:

I β†’ Input

User enters data

Python

name = input()

P β†’ Processing

Calculations

Python

total = price * qty

O β†’ Output

Python

print(total)

πŸ’‘ Every program follows IPO.

πŸƒ Cue Card 13: Reading Requirements

Front:

πŸ“– How do I answer programming questions?

Back:

Ask yourself:

βœ… What inputs are needed?

βœ… What calculations are needed?

βœ… What decisions are needed?

βœ… What output is required?

Then write:

INPUT ➜ PROCESS ➜ OUTPUT

πŸƒ Cue Card 14: Complete Program Checklist

Front:

⭐ Before submitting, check:

Back:

β˜‘ Inputs collected correctly

β˜‘ Variables named properly

β˜‘ Functions used

β˜‘ Decisions used correctly

β˜‘ Loops end correctly

β˜‘ Output displays correctly

β˜‘ File opened and closed

β˜‘ No syntax errors

β˜‘ Tested with different values