Python Programming Unit 1

Python Foundations

Build the habits students need before larger programs, data work, and AI projects.

This unit helps students become comfortable writing and reading small Python programs. Students work with variables, expressions, input and output, type conversion, arithmetic, strings, conditionals, Boolean logic, loops, counters, accumulators, tracing, and simple debugging. The focus is not just syntax. Students learn how to predict what code will do, test small cases, read error messages, and make steady corrections.

Who This Unit Is For

Best for new Python students, AP CSP students who need stronger coding confidence, and Java students who want a smoother bridge into Python syntax.

Learning Goals

  • Use variables, expressions, input, output, arithmetic, and type conversion correctly.
  • Work with strings using indexes, slices, methods, formatting, and parsing.
  • Write conditionals and loops that handle normal cases and edge cases.
  • Trace code by hand and use print statements to debug small programs.
  • Build short menu programs, calculators, and validation loops with confidence.

Key Concepts

What students practice in this unit

Python moves quickly once the basics are clear. A student who can trace a loop, clean a string, and test a small input case is prepared for functions, lists, files, and data projects. These habits also help in AP Computer Science Principles and later Java/AP CSA work.

Variables and expressions

Students learn how names store values, how expressions are evaluated, and why integer, float, Boolean, and string values behave differently.

Strings and slices

Students practice indexing, slicing, cleanup methods, case conversion, and parsing strings from user input.

Branching and repetition

Students use if/elif/else statements and loops to handle choices, repeated tasks, counters, and accumulators.

Tracing and debugging

Students learn to slow down, inspect variable values, read error messages, and test one small case at a time.

Practice

Exercises and mini-project ideas

These are public practice prompts students can use to strengthen the unit without exposing the full internal lesson sequence.

Practice Exercises

  • Build a number guessing helper that tells the user whether a guess is high, low, or correct.
  • Clean a username by trimming spaces, converting to lowercase, and checking length rules.
  • Write a simple calculator that asks for two numbers and one operation.
  • Create a menu program that repeats until the user chooses to quit.
  • Print patterns with loops, then change the pattern size from user input.
  • Write an input validation loop that keeps asking until a valid score is entered.

Mini-Project Ideas

  • Study timer that converts minutes into hours and minutes and gives a short summary.
  • String cleanup tool for names, emails, or club signup responses.
  • Beginner quiz app with score counting and a final message.

Common Student Mistakes

  • Forgetting that input returns a string until it is converted.
  • Mixing up indexes and positions when slicing strings.
  • Writing a loop that never changes the variable used in the condition.
  • Testing only one friendly input and missing blank, uppercase, or boundary cases.
  • Trying to fix many lines at once instead of checking one variable at a time.

Challenge Extension

Add a small test table for each program: normal input, smallest allowed input, largest allowed input, and one invalid input. Students explain what each case should do before running the code.

How This Prepares the Next Step

Students leave this unit ready to wrap repeated logic inside functions, separate input from processing, and design programs that are easier to test.

Related Code Scholars Paths

Ready to practice?

Build Python skills with a guided plan.

Students can use this page for review, then work with Code Scholars on targeted exercises, debugging support, projects, and next-step planning.