Write a Python program to print a hollow square pattern of stars (*) with a hash (#) symbol at the center of the square. The side length n of the square shall be entered by the user as an odd integer number greater than 4. 0.2.1 Sample Run 1 Please enter the side length of the square: 9 0.2.2 Sample Run 2 Please enter the side length of the square: -6 wrong input, the side length should be an odd integer greater than 4. Try again !!! Please enter the side length of the square: 4 wrong input, the side length should be an odd integer greater than 4. Try again !!! Please enter the side length of the square: 8 wrong Input, the side length should be an odd integer greater than 4. Try again !!! Please enter the side length of the square: 5
Added by Julia V.
Close
Step 1
First, we need to take input from the user for the side length of the square. We will use a while loop to keep asking for input until the user enters a valid value. ```python side_length = 0 while side_length <= 4 or side_length % 2 == 0: side_length = Show more…
Show all steps
Your feedback will help us improve your experience
Mohan Jain and 59 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Write a program to print a diamond made up of left- and right-aligned right-angled isosceles triangles, all of positive integer height specified by the user's keyboard input (a positive integer), as follows: Enter triangle height: 6 ************ ***** ***** **** **** *** *** ** ** * * ** ** *** *** **** **** ***** ***** ************
William M.
write an algorithm to input a side of a square and print area and perimeter of square
Haricharan G.
Write a program in python to print square of numbers from 1 to 10.
Willis J.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD