Quadrilateral Dimensions - Python Programming Exercise

In this exercise, you will develop a Python program to prompt the user for a number and then display a rectangle 3 columns wide and 5 rows tall using that digit. The program will use loops to print the digit in the specified pattern. This task helps you practice handling user input and using loops to control the flow of the program for repetitive tasks. By completing this exercise, you will enhance your understanding of Python syntax and become more proficient in using loops to create patterns. This is an important skill in Python programming, as loops allow you to automate repetitive tasks and work with user input dynamically. Mastering these fundamental concepts will prepare you for more advanced programming challenges in Python.

 Category

Your First Steps in Python

 Exercise

Quadrilateral Dimensions

 Objective

Develop a Python program to prompt the user for a number and then display a rectangle 3 columns wide and 5 rows tall using that digit. For example:

Enter a digit: 3
333
3 3
3 3
3 3
333

 Example Python Exercise

 Copy Python Code
# Prompt the user to enter a digit
digit = input("Enter a digit: ")

# Display the rectangle using the entered digit
print(digit * 3)
print(digit + " " + digit)
print(digit + " " + digit)
print(digit + " " + digit)
print(digit * 3)

 Output

Enter a digit: 3
333
3 3
3 3
3 3
333

 Share this Python Exercise

 More Python Programming Exercises of Your First Steps in Python

Explore our set of Python Programming Exercises! Specifically designed for beginners, these exercises will help you develop a solid understanding of the basics of Python. From variables and data types to control structures and simple functions, each exercise is crafted to challenge you incrementally as you build confidence in coding in Python.

  •  Conversion

    In this exercise, you will develop a Python program that asks the user for a temperature in Celsius and converts it to both Kelvin and Fahrenheit...

  •  Initial interaction with Python

    In this exercise, you will develop a Python program to output "Hello" on the screen, followed by your name on a separate line. This exercise is perfect for pra...

  •  Addition of two values

    In this exercise, you will develop a Python program to print the result of adding 12 and 13 on the screen. This exercise is perfect for practicing basic arithm...

  •  Divide two values

    In this exercise, you will develop a Python program to display the result of dividing 24 by 5 on the screen. This exercise is perfect for practicing basic arit...

  •  Complex Calculations and Order of Operations

    In this exercise, you will develop a Python program to calculate and display the results of several mathematical operations. You will work with expressions such as 1 + 3 ...

  •  Variable-Based Multiplication

    In this exercise, you will develop a Python script to calculate and display the product of two numbers entered by the user. This task introduces you to handlin...