Python (Fall 2026) Module 4-4: A4 Explanation
Overview
Bill Moseley explains A4, a Python assignment to build a practical calculator that accepts user input, converts it to numbers, applies a formula, and displays the result. He demonstrates a comments-first workflow by creating a rectangle-area calculator with `input()`, `int()`, f-strings, and `\n` line breaks, then encourages students to choose their own calculator and aim to use at least two or three inputs.
Key takeaways
- A practical A4 calculator should generally collect at least two or three numeric inputs, combine them with a formula, and print a useful result.
- Comments-first design turns a calculator assignment into five manageable steps: welcome the user, collect input, convert values, calculate, and display the result.
- Python's `input()` returns text, so the rectangle example uses `int()` to convert height and width strings before multiplying them.
- Using separate variables such as `strH` and `intH` makes the data-type change explicit and easier to follow.
- The `\n` escape sequence adds a line break in printed output, helping separate instructions, prompts, and results without inserting extra empty `print()` calls.
- Calculator difficulty can be scaled to the student's comfort: rectangle area is a moderate example, while interest-based monthly payments require more complex formulas.
Chapters
- A4 is for practical calculators such as car-payment, mortgage, interest, sphere-volume, or area calculators, not basic arithmetic calculators.
- Bill Moseley recommends collecting at least two or three numbers and applying a formula; a Fahrenheit-to-Celsius converter is an option for students who feel overwhelmed.
- He introduces comments-first design: use `#` comments to outline welcoming the user, collecting input, converting values, calculating, and printing results.
- Python ignores comments when executing code, while comments document intent for future programmers, teammates, and assignment review.
- The example welcomes users and instructs them to enter whole-number rectangle height and width, following the goal of making the program easy to use.
- The program stores responses from `input()` in `strH` and `strW`, and uses `.strip()` to remove surrounding spaces.
- It converts the strings into `intH` and `intW` with `int()`, then calculates `intResult = intW * intH`.
- An f-string prints the area; test inputs of 10 and 55 produce an area of 550.
- Bill Moseley improves readability with the `\n` newline escape character, adding blank lines around the input prompts and final result.
- He advises students not to submit the demonstrated rectangle calculator, but to create a calculator based on their own idea.
- Suggested challenges range from area or volume calculations to more complex monthly-payment or simple-interest formulas; temperature and currency converters are simpler alternatives.
- The assignment work period is about 30 minutes, and Moseley encourages students to use it to attempt a calculator with at least two inputs.
Transcript excerpt
0:00 Now I want to talk about A4 and give you the explanation before I set you loose to work. So A4 is a simple calculator assignment. Now, I am not referring to a calculator like this one. Okay, that's not the kind of calculator I'm talking about. The kind of calculator I'm talking about is like if you're going to go buy a new car and you want to see if you can afford the car payments, you go online and there's a car payment calculator at the Ford dealership or whatever. And you put in, this is how much money the car costs, this is how much money I have to put down for down payment. And then it's, then it spits out, here's what your monthly payment will be. And then you can see if you can afford it or not. There's mortgage calculators, there's interest
0:52 calculators, there's all kinds of things. You could calculate the volume of a sphere. You could calculate all kinds of different things. The idea is that you are getting at least two pieces of data. If, if you're really overwhelmed by this assignment, I will accept a temperature converter, in which case you're just getting the temperature in Fahrenheit and changing it to Celsius. I would strongly urge you to try and push yourself a little further and at least get two numbers from the user and use those. And then you have to figure out what the formula is, how does it look in Python, you're going to do the calculation, print the results. So, if you look at the assignment itself on Canvas, it does have all of this information for you.
1:48 And it's got a, a few sort of ideas here, things that you could use, but you don't
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Bill Moseley, Ph.D. - Computer Science Educator.