Week 1 Recap

“What ultimately matters in this course is not so much where you end up as much as where you started, relative to yourself.”
— David J. Malan
What week 1 covered
In Week 1 of CS50P, I delved deeper into the fundamentals of programming logic, focusing on conditionals and control flow. The lecture introduced essential concepts such as if
, elif
, and else
, which enable programs to make decisions. I also learned to utilize logical operators like and
or
to combine multiple conditions. Additionally, we examined comparison operators, the modulo operator (%
) for checking divisibility, and techniques for writing cleaner, more “pythonic” code that adheres to Python’s design philosophy. A notable addition was the match
statement—Python’s modern alternative to switch
in other languages, which enhances the readability of multi-case conditions. Overall, this week focused on teaching the computer to think logically, equipping me with the tools to develop more intelligent programs.
Problem set 2 breakdown
Deep Thought
Home Federal Saving Banks
File Extensions
Math Interpreter
Meal Time
Difficulties I faced
For me, “Deep Thought” and “File Extensions” were relatively straightforward. The remaining problems demanded more logical thinking and problem-solving skills. They also required the use of new built-in and functions.
“Home Federal Saving Banks” was easy, but it required using a new string method called str.startswith()
, which is mentioned in Python’s documentation for string methods.
I struggled the most with “Math Interpreter”.,
Problem 1: Using return
statement alongside the if
, elif
statements
Solution: return
statements need to be inside a function to work. So instead I defined functions based on the operators and used the return
statement in them.
Problem 2: Unexpected output/return value occurred. When returning float values, the +
operator was concatenating the values instead of actually adding them, and the other operators were producing errors.
Solution: This happened because I used float()
incorrectly. Instead of converting the result to a float and then returning it, I first converted the input values to floats and then performed the arithmetic operations.
In "Meal Time," the primary challenge I encountered was defining the convert function to return the input (24-hour format) as hours in float. Once I resolved this, I realized it was relatively simple, though it required considerable time for me to arrive at the solution.
I haven't finished the challenge of making the program work with the 12-hour format yet. I'll share the update on my X profile and in my upcoming articles as soon as I solve it.
Conclusion
CS50P is not just about learning Python—it's about learning how to think like a programmer. Problem set 1 encourages me to think deeply and apply more logic to solve problems. With each set, the challenge increases, and so does our ability to brainstorm and come up with creative solutions.
Subscribe to my newsletter
Read articles from CircuitCoder directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
