Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Putting It All Together

NOTE: For the following application questions, write two programs for each- one that uses a while loop and one that uses a for loop to accomplish the same task.

Question 7

Q7: Write a program that asks the user to enter three numbers: a starting value, an ending value, and an increment. Your program should then “count” based on these criteria, as shown in the sample output below. Answer to this question includes programs with a while loop and a for loop + comments that document process and explain your code.

This program counts for you.
Enter the starting value: 3
Enter the ending value: 13
Enter the increment: 2
3
5
7
9
11
13

Question 8

Q8: Write a program that prints the numbers 1 through 10, except that between 7 and 8 it should print the word “happy.” Answer to this question includes programs with a while loop and a for loop + comments that document process and explain your code.

Sample output for this program:

1
2
3
4
5
6
7
happy
8
9
10