CS50P Journal: My Takeaways from Weeks 0 and 1


Hello,
SHORT OVERVIEW OF LECTURES
Week 0 is the very first lecture of CS50. It consisted of basic syntax, Functions like print, input and string methods to play around with strings. Then we moved on towards format print which is a special type of print function that allows you do task like round off the float value to 2 decimal points, helps you print commas between the numbers and many more functions that i am yet to learn. Most importantly i learned how to define functions and use them in code.
Week 1 was quite short and simple , I learned how to use Conditionals like If
, elif
and else
. Then went through “or“ & “and“… these two really made codes look much more compact and structured. after which I started with Assignments of Week 1… Let’s break down both week’s problem set and things i learned!
PROBLEM SET 0 - WEEK 0
Problem set 0 was very easy and mostly under 4 lines of code.
lower the case of entered text —> done with:
text = text.lower()
Replace spaces with “…“ in entered text —> done with:
text.replace(“ “ , “…“)
making emoticons [ :) ] into actual emojis —> done with:
text.find() and text.replace()
Simple calculator
Tip calculator : input total amount then enter what % of it you want to tip and you get final amount.
PROBLEM SET 1
Problem set 1 had total of 5 problems, 3 were very easy and mostly repetitive and other 2 were a bit complex here’s what those 2 problems asked and how i solved them:
PROBLEM 1
In a file called bank.py, implement a program that prompts the user for a greeting. If the greeting starts with “hello”, output $0
. If the greeting starts with an “h” (but not “hello”), output $20
. Otherwise, output $100
. Ignore any leading whitespace in the user’s greeting, and treat the user’s greeting case-insensitively.
code that i wrote to solve the problem :
An easy code to do the task given. here .strip()
removes the extra white space and .lower()
lowers the case of the entered text, why to lower? the problem says it must be case insensitive and to do that i lowercase the entire text and now i know that it wont be “Hello“ or “HeLLo“ it would only be “hello”.
PROBLEM 2
In a file called interpreter.py
, implement a program that prompts the user for an arithmetic expression and then calculates and outputs the result as a floating-point value formatted to one decimal place. Assume that the user’s input will be formatted as x y z
, with one space between x
and y
and one space between y
and z
, wherein:
x
is an integery
is+
,-
,*
, or/
z
is an integer
For instance, if the user inputs 1 + 1
, your program should output 2.0
SOLUTION :
Allow me to explain this code! x and z are int values… and hence nothing hard. The main reason why we get such a huge code is y variable… lets say 2 + 4 = 6 then here x is 2 and z is 4 but what is y ? its “+“ we cannot use this + because its a string and not an operator… so i had to manually enter all the 4 operators and an else statement
to avoid code crash… There was one other way to do it, i found out through ChatGPT, it was to import Operator
module… “but it isn’t taught yet so there must be some other way to solve it” i said to myself. and then did this!
THANK YOU
Thanks for reading this Article. I will be Updating my blogs and explaining all my learnings here on Hashnode.com. These articles will not just help me track my journey and maybe revise some points but also it might be helpful to you, if you code too! especially if you are also studying from CS50. Thanks Again!
LinkedIn Profile : https://www.linkedin.com/in/saddab-ansari-809b46367
i will Soon make a proper git hub account and post my best projects there for all of you to see, but until then it’ll just be my blogs and LinkedIn posts.
Subscribe to my newsletter
Read articles from Saddab Ansari directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Saddab Ansari
Saddab Ansari
I’m an aspiring computer science engineer interested in data science, AI, and coding. I enjoy learning by doing — from online courses to small projects and self-study. Right now, I’m focused on improving my programming skills, exploring new tech, and preparing for future opportunities to study and hoping to work abroad. Open to connecting with people who share similar interests or have advice to share.