top of page

Odds and Even in Python

  • Writer: VC Healy
    VC Healy
  • Sep 29, 2020
  • 1 min read

There is a little Python idea to create a program that determines if a number input by a user is Odd or Even. This is to help develop basic programming. Anyone that knows me, they will know I am more of a find and fix problems in code.


I gave this a bash, from scratch without looking at any demo/tutorials/books/etc.


Okay, that was simple. Stick in an integer and away it goes.


Coming back to my original behaviour, I have found now that I have written this I am looking at problems in the code. Not what I have written but what is missing to make the code a bit more robust.


How does the user know what the program does?

- Clear screen command to clear the console was placed at the start.

- A header that states what the code does and what the user should do.

What if the input is not an integer?

A try-except captures if a ValueError is found.

A message to the user shows their input and that it was not a number

There is a small pause and then the program restarts

What if the user wants to do this more than once?

After a successful check of a users input, there was a pause, and the program restarts

Is there a clean way for the user to exit the program?

The ability for the user to enter '0' to exit the program, as detailed in the header.




 
 
 

Comments


© 2020 by Vincent Healy. Proudly created with Wix.com

bottom of page