Now You Code 1: Vote or Retire?

Part 1

Write a program to ask for your age as input, then output 1) whether or not you can vote and 2) whether your not you can retire. Let's assume the voting age is 18 or higher, and the retirement age is 65 or higher.

NOTE: This program is making two seprate decisions, and thus should have two separate if else statements.

Example Run:

Enter your age: 45
You can vote.
You cannot retire.

Step 1: Problem Analysis

Inputs:

Outputs:

Algorithm (Steps in Program):


In [1]:
#Step 2: write code here

Part 2

Now that you have it working, re-write your code to handle bad input using Python's try... except statement:

Example run:

Enter your age: threve
That's not an age!

Note: Exception handling is not part of our algorithm. It's a programming concern, not a problem-solving concern!


In [2]:
## Step 2 (again): write code again but handle errors with try...except

Step 3: Questions

  1. What specific Python Error are we handling (please provide the name of it)?

Answer:

  1. What happens when you enter an age of -50? Does the program still run? Fix your program so that it says That's not an age when a value less than zero is entered.

Answer:

  1. How many times (at minimum) must we execute this program and check the results before we can be reasonably assured it is correct?

Answer:

Step 4: Reflection

Reflect upon your experience completing this assignment. This should be a personal narrative, in your own voice, and cite specifics relevant to the activity as to help the grader understand how you arrived at the code you submitted. Things to consider touching upon: Elaborate on the process itself. Did your original problem analysis work as designed? How many iterations did you go through before you arrived at the solution? Where did you struggle along the way and how did you overcome it? What did you learn from completing the assignment? What do you need to work on to get better? What was most valuable and least valuable about this exercise? Do you have any suggestions for improvements?

To make a good reflection, you should journal your thoughts, questions and comments while you complete the exercise.

Keep your response to between 100 and 250 words.

--== Write Your Reflection Below Here ==--