Write a program to ask for a number to multiply by and then lists the multiplication table for that number from 1 to 10. This process will repeat until you enter quit as which point the program will exit.
Wow. Seems complicated! We'll use the technique called problem simplification to make this problem a little easier to solve.
First we'll write a complete program to solve part of the problem, then we will take our new level of understanding to solve the entire problem.
Let's write a program to simply input a number and then uses a loop to print out the multiplication table up to 10 for that number.
For example, when you input 5
:
Enter number to multiply by: 5
1 x 5 = 5
2 x 5 = 10
3 x 5 = 15
4 x 5 = 20
5 x 5 = 25
6 x 5 = 30
7 x 5 = 35
8 x 5 = 40
9 x 5 = 45
10 x 5 = 50
In [1]:
# Step 2: write code for sub-problem 1
Now that you have part of the problem figured out, try to solve the entire problem. The program should keep asking for numbers and then print out multiplcation tables until you enter quit
. Here's an example:
Example Run:
Enter number to multiply by or type 'quit': 10
1 x 10 = 10
2 x 10 = 20
3 x 10 = 30
4 x 10 = 40
5 x 10 = 50
6 x 10 = 60
7 x 10 = 70
8 x 10 = 80
9 x 10 = 90
10 x 10 = 100
Enter number to multiply by or type 'quit': 5
1 x 5 = 5
2 x 5 = 10
3 x 5 = 15
4 x 5 = 20
5 x 5 = 25
6 x 5 = 30
7 x 5 = 35
8 x 5 = 40
9 x 5 = 45
10 x 5 = 50
Enter number to multiply by or type 'quit': quit
NOTE: you need another loop to complete this program. Take the code you wrote in the first part and repeat it in a second loop until you type quit.
In [2]:
# Step 4: Write code for full problem
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 ==--