A201 Introduction to Programming 1

A201 Homework 5

Due Date: Tuesday, September 26, 2025.

Goal: to use for loops with a range in Python.

Make sure to complete Lab 5 before doing the homework.

Create a Python script file called hw5.py. Add your name at the top as a comment, along with the class name and date. Both exercises should be in this file, with a comment before each of them to mark it.

Ex. 1. For loops

Write a for loop displaying each of the following sequence of numbers, where the upper bound mentioned should be included in all of them:

Print a message before each sequence explaining what will be printed.

Ex. 2.

Write a program that inputs an integer number from the user, then prints a letter "O" in ASCII art using a width of 5 and the input number as height. For example, if the user enters 6, then the output should look like this:

 *** 
*   *
*   *
*   *
*   *
 ***

Hint: Print the string " ***" first, then use a for loop with a range based on the input number (the height, maybe -1) to print the intermediate strings "*   *", and then the string " ***" again at the end.

Homework Submission

Upload the files lab5.py and hw5.py in Canvas, Assignments, Homework 5.