Objectives Achieved
This newsletter is primarily a digital notebook to document and track my learning of different technical skills each week. This should hopefully motivate me to keep learning in preparation for my future career.
And for now, in the summer of 2024, I have been following Python Programming MOOC 2023 from the University of Helsinki’s Computer Science Department.
The first section is Introduction to Programming, which consists of 7 parts.
The second section is Advanced Course in Programming, which also consists of 7 parts.
I am planning to complete the MOOC before I begin my final year of study at university.
Some Statistics
Parts Completed: 1st, 2nd
Exercises Completed: 50
Here are some codes I did this week
PIN and number of attempts: My Solution
This program keeps asking the user for a PIN code until they type in the correct one, which is 4321.
It works by forming a while-True loop and using the variable attempts to keep track of how many times the user has typed the PIN.
The break command here is executed when the user has typed the correct PIN.
I have also used the variable success to determine which statement to print out based on the number of attempts of the user.
PIN and number of attempts: Model Solution
The model solution is more neat as it does not require the success variable.
Instead it uses an if-else statement coupled with the variable attempts to determine which statement to print out.
Count, Sum, Mean, Positive and Negatives: My Solution
This program asks the user to input integers. It will keep asking the user until the user types 0.
And based on the numbers, it will print out their sum and mean, as well as the number of positive numbers and negative numbers.
The program does not consider 0 as one of the numbers. It does so by using the break command within the while-True loop.
Count, Sum, Mean, Positive and Negatives: Model Solution
The model solution is again more neat as it finds the number of negative numbers by treating it as the difference of all numbers minus the negative numbers.
This omits one of the if-statements in my solution.
That’s it for this week!
About Me
Hello I am Barry and I study mathematics at the University of Warwick. I also write on Medium.
If you want to reach out, please do so below 🦁