Stanford Code in Place
Introduction to Python
About Code in Place
Code in Place is a global Python programming course developed by Stanford University, based on their CS106A curriculum. Over six weeks, I built a strong foundation in core programming concepts including functions, control flow, data structures, rejecting invalid inputs, and debugging. The course culminated in an independent final project — PolyPicker — where I applied these skills to develop a tool that would be helpful for design engineers like me. PolyPicker’s code is described below.
Course Syllabus
Week 1: Learn how to write for-loops, while-loops, and if-statements with Karel
Week 2: Learn how to take loops a step further using stepwise refinement
Week 3: Learn how to set and manipulate variables, leverage AI, and generate random numbers
Week 4: Learn how to combine while/for loops and if statements with variables in Python
Week 5: Learn how to combine while/for loops and Python canvas to generate graphics
Week 6: Learn how to create, index, and modify lists and dictionaries
Final Project: Use learnings to create your own Python script or canvas
PolyPicker main
At the heart of PolyPicker is the main()
function which acts as the central coordinator that manages user prompting and interaction, data processing, and material recommendation. It ties together several modular functions, each handling a specific task in the material selection workflow. In order to expand the program to include more detailed filtering, cost optimization, and integration with material databases, I laid the code out in this fashion to make it easy to maintain and extend.
Image 1: Longboard Full Assy View
Welcome & User Pref
The program begins with the welcome_statement()
function, which introduces users to PolyPicker and outlines its purpose. This is immediately followed by get_user_pref_unit()
, where users are asked to specify their preferred temperature unit — Fahrenheit or Celsius. This selection ensures that all subsequent user inputs are correctly processed, laying the groundwork for accurate material matching. Together, these functions establish a user-friendly entry point and ensure clarity before the technical input begins
Collecting User Input
In this stage, the program gathers essential design constraints from the user — specifically the minimum and maximum operating temperatures and whether chemical resistance is required. The temperature inputs are automatically converted based on the user's preferred unit (Fahrenheit or Celsius), ensuring consistency during material comparison. This data is stored for validation and later use in filtering suitable polymers from the database.
Error Identification
After collecting user input, the program verifies the data by prompting the user to confirm its accuracy. If the user indicates something is incorrect, the program uses the find_error_cat()
function to pinpoint which specific input (e.g., minimum temperature, maximum temperature, or chemical resistance) needs to be corrected. This targeted approach avoids forcing the user to re-enter all data.
Error Removal
After the error category is identified, the fix_error_cat()
function is called to collect only the necessary corrections. It prompts the user to re-enter the specific data point that needs updating — whether it's a temperature value or the chemical resistance requirement — without resetting the entire input flow.
User & Polymer Dict Creation
After collecting and confirming input, the program converts both the user requirements and the polymer material database into structured dictionaries. The form_user_req_dict()
function organizes the user's inputs into a single, consistent format. Afterwards, poly_dict_formation()
creates a list of dictionaries where each entry represents a polymer and its relevant properties. This format allows for efficient comparison between the user’s design constraints and the capabilities of each material.
Comparison & Recommendation
With both user requirements and polymer data structured into dictionaries, the program uses the compare_dicts()
function to evaluate which materials meet the specified constraints. Each polymer is checked against the user's inputs. Suitable matches are collected into a recommendation list, which is then passed to print_out_rec()
to display the results.