Objective
Develop a Python program that prompts the user to enter a number and a width, and displays a square of that width using that number for the inner symbol, as shown in this example:
Enter a number: 4
Enter the desired width: 3
444
444
444
Example Python Exercise
Show Python Code
# Prompt the user to enter a number
num = input("Enter a number: ")
# Prompt the user to enter the desired width
width = int(input("Enter the desired width: "))
# Use a while loop to display the square
i = 0
while i < width:
print(num * width)
i += 1
Output
Enter a number: 4
Enter the desired width: 3
444
444
444
Share this Python Exercise