πŸ‘©β€πŸŽ“PCEP Python Prep

Description

This flexible activity series is designed to help students learn foundational Python programming concepts while controlling a four-motor rover. Aligned with the PCEP-30-02 Certified Entry-Level Python Programmer exam, each self-contained activity focuses on a specific Python topicβ€”such as variables, control flow, loops, data collections, and functionsβ€”while applying the concept to real rover movement. Students modify a single function in a provided rover control program to experiment with code and immediately observe the physical results on the robot. Each lesson pairs a clear programming objective with guided code examples, TODO challenges, and real-world rover testing. Instructors can mix and match activities or run them sequentially to fit different schedules, making the course adaptable for short workshops, multi-day camps, or full introductory Python classes.

Overview

This guide covers:

  • Generating PWM commands for the ROV.

  • Understanding how PWM settings affect motor drive and direction.

  • Running user-generated Python using LLM output based on guided input.

triangle-exclamation

Bleak library

  • This library must be installed first https://github.com/hbldh/bleak

  • From the command prompt run: Run β€œpip install bleak”

RoverLLM.py

circle-check

Each activity aligns with topics from the PCEP‑30‑02 Certified Entry‑Level Python Programmer exam.

This course teaches Python programming while controlling a four‑motor rover.

In every activity:

β€’ Save the file as activityX.py β€’ Run the program using Visual Studio Code β€’ Modify or debug the StartProgram() function β€’ Do NOT modify the rover Bluetooth code

You will fix bugs, complete missing code, and extend programs.


Running Programs in Visual Studio Code

  1. Open Visual Studio Code

  2. Open your rover project folder

  3. Create a new file (example: activity1.py)

  4. Paste the rover base program into the file

  5. Modify StartProgram()

  6. Run the program

Open the terminal:

Terminal β†’ New Terminal

Run:


Rover Motor Command

The rover moves using:

Values range -100 to 100

Value
Meaning

100

Full Forward

50

Half Forward

0

Stop

-50

Reverse

-100

Full Reverse


SECTION 1 – Python Fundamentals


Activity 1 – Instructions and Comments

Objective

Learn:

β€’ Python instructions β€’ indentation β€’ comments

Save

Starter Code

Student Task

Complete the program so the rover:

  1. Moves forward 2 seconds

  2. Stops

  3. Waits 1 second

Add comments explaining the code.


Activity 2 – Variables

Objective

Learn:

β€’ variables β€’ integers β€’ storing values

Save

Starter Code

Student Task

Fix the missing value so the rover moves forward 2 seconds.

Add a variable called:


Activity 3 – Operators (Debugging)

Objective

Learn:

β€’ operators β€’ modifying variable values

Starter Code (Bug)

Student Task

Fix the bug so speed increases each loop.

Expected speeds:

10 20 30 40 50


SECTION 2 – Control Flow


Activity 4 – Conditional Statements

Objective

Learn:

β€’ if β€’ elif β€’ else

Starter Code

Student Task

Add commands:


Activity 5 – Loops

Objective

Learn:

β€’ for loops β€’ repetition

Starter Code

Student Task

Fix the loop so the rover repeats the movement 5 times.


Activity 6 – Movement Pattern

Objective

Learn:

β€’ combining loops with movement

Starter Code

Student Task

Add turning code so the rover drives in a square.


SECTION 3 – Data Collections


Activity 7 – Lists

Objective

Learn:

β€’ lists β€’ iterating through lists

Starter Code

Student Task

Add more speeds:


Activity 8 – Movement Sequences (Debugging)

Starter Code (Bug)

Student Task

Fix the program so the rover executes the sequence.

Hint: MoveMotors() requires 4 arguments.


Activity 9 – Dictionaries

Objective

Learn:

β€’ dictionaries β€’ key/value lookups

Starter Code

Student Task

Add commands:


SECTION 4 – Functions


Activity 10 – Functions

Objective

Learn:

β€’ defining functions β€’ parameters

Starter Code

Student Task

Finish the function so the rover:

  1. Moves forward

  2. Waits

  3. Stops


Activity 11 – Exception Handling

Objective

Learn:

β€’ try β€’ except β€’ preventing program crashes

Starter Code

Student Task

Add exception handling so the program does not crash if the user enters text.


Activity 12 – Command Parser

Objective

Learn:

β€’ strings β€’ text commands β€’ program logic

Starter Code

Student Task

Complete the commands so the rover responds correctly.

Add a command:


Final Challenge – Rover Patrol

Create a new file:

Write a program that:

  1. Drives in a square

  2. Spins in place

  3. Returns to the starting point

  4. Stops

Use:

β€’ loops β€’ functions β€’ conditionals β€’ lists

Last updated