Lesson 6/48 ยท ๐Ÿง  The Programmer's Mindset
๐Ÿง  The Programmer's MindsetLesson 6/48
Phase 0 ยท The Programmer's Mindset20 min

Pseudocode: Think Before You Type

Write your solution in plain English before touching Python

Pseudocode is a plain-English description of your algorithm. No syntax rules, no semicolons, just your thought process written down.
It's the bridge between *understanding a problem* and *writing code*.
Pseudocode example, Find the largest number in a list
START with the first number as "largest so far"
FOR each number in the list:
    IF this number > largest so far:
        update "largest so far" to this number
RETURN "largest so far"
Now translate that directly to Python, it's almost word-for-word:
Same logic in Pythonpython
def find_largest(numbers):
    largest = numbers[0]           # Start with first number
    for num in numbers:            # FOR each number
        if num > largest:          # IF this number > largest so far
            largest = num          # update largest
    return largest                 # RETURN largest
The pseudocode process:1. Read the problem2. Write pseudocode in plain English (2-5 lines)3. Translate each line to Python4. Test with examples
Stuck on a problem? Step away from the keyboard. Pick up a pen and write what you'd do in English. The code will follow naturally.
๐ŸŽฏ

Phase Complete!

The Programmer's Mindset

Before you write a single line of code, what's the most important thing to do? Describe the 3 steps you now take when approaching a new problem.

0/500

Practice Exercises

0/2 solved
Exercise 1 of 2easy
โฑ 00:00

Count Positives

Write a function count_positives(numbers) that returns how many numbers in the list are greater than zero.
Write your pseudocode as comments first, then implement.
solution.py
1 / 2
Exercise 2 of 2easy
โฑ 00:00

Largest Number

Write a function find_max(numbers) that returns the largest number in a list.
You can assume the list has at least one number.
solution.py
2 / 2
Solve all 2 exercises to unlock completion