365 Days of Python: Day #18 — Unpredictable Users
Implementing user input into a program can be tricky.
What if the user enters a string instead of an integer?
What if the user enters a value that causes the program to put his/her computer into overdrive?
What if the user enters nothing?
All of the above questions need to be considered when you are a writing a program that requires user input.
Day #18 (12/2/2022)
“Assuming what people want is about as controlled as using fireworks to start a fire.”
— Criss Jami
Accomplishments
- Learned how to create new columns derived from existing columns using pandas
- Learned how to calculate summary statistics using pandas
- Began writing my PotW
Weekly Goals
- Learn the basics of pandas (60%)
- Write a program that reads data from a Microsoft Excel spreadsheet and performs data analysis on it (40%)
Closing Thoughts
Whenever I am writing a program, I try to shift my perspective to that of the user. This often leads to the reformatting of input prompts, print statements, etc.
Additionally, I always consider what could go wrong. It is not the end of the world if the terminal spits out an error message; however, I would rather have the program terminate. Therefore, I tend to use “try…except” statements where applicable.
To let the user have control, or not to let the user have control, that is the question.