Drawing a square with "." and " " only in Python

how to draw a square with a compass
how to draw a square box
drawing square tool
draw a square of side 4.5 cm
draw a rectangle
how to draw a square with 3 lines
how to draw a cube
construct a square of side 5cm

I am trying to make a square with spaces and dots only, but I am having an issue. I need to make the code in that way, so I can change the size of the square in just 1 input for each parameter. I am having issues with the "sides" variable how can I make the space between left side and right side automated by just giving only 1 input value.

def square_shape(top,sides,bottom):
            top = ". "*top
            sides =((".")+("     .\n"))*sides
            bottom = ". "*bottom
            print top
            print sides,bottom
        square_shape(8,7,8)

P.S With this code it works perfectly fine, but when I change the size of top and bottom , the space needed is not created in the sides. I hope I was clear.

Thank you in advance

Make the space being dependent on length of square and don't use \n in the string or else your last line will also print a newline -

def square_shape(leng): # no need to use 3 variables
        print (". "*leng)
        for _ in range(leng-2):
            print (". " + "  " * (leng - 2) + ".")
        print (". "*leng)
square_shape(8)

Output -

. . . . . . . . 
.             .
.             .
.             .
.             .
.             .
.             .
. . . . . . . . 

How to Draw a Perfect Square, How do you construct a square with a given side? This page shows how to construct (or draw) a square given the length of a side. It starts with a given line segment AB. It then erects a perpendicular at one end of the line, which will become the second side of the square. The compass is then set to the length of the given side, and the other three sides are marked off.

What about this?

def square_shape(size):
    print '. ' * size + '.'
    print ('.' + '  ' * (size-1) + ' .\n') * (size-1),
    print '. ' * size + '.'

How to Draw a Square: 9 Steps (with Pictures), How to Draw a Perfect Square. Part of the series: Drawing Simple Shapes & Lines. Drawing Duration: 4:03 Posted: May 26, 2015 Protractor Method 1. Draw a side of the square using ruler. Keep track of the length of this side so you can make all four sides the same 2. Considering the side drawn in the previous step as one of the arms, construct a right angle on each end of it. 3. Mark a point on each of the newly drawn

little bit optimized!

square_shape = int(input())
print ("."*square_shape)
for _ in range(square_shape-2):
    print ("."+ " "*(square_shape-2) + ".")
print ("."*square_shape)

How to construct (draw) a square, To draw a square, start by drawing a straight line using a ruler. Then, measure the line so you can make the other sides of the square the same length. Next, draw a line going straight up from each end of the first line that are the same length as the first line. Step Two: Position a framing square against the nails. Step Three: Hold a pencil in the corner of the framing square. Step Four: Rotate the pencil with the framing square as a guide. Step Five: Once you have completed the first half of the circle, flip the framing square and repeat steps three and four. To see this tip in action, watch the

Construct Square - MathBitsNotebook (Geo, This page shows how to construct (draw) a square with a given side length with compass and straightedge or ruler. It works by first erecting a perpendicular and  09. Drawing. Here's the final and most important line: gl.drawArrays(gl.TRIANGLES, 0, numItems); The first argument of the drawArrays function specifies the drawing mode. We want to draw a solid square, so we use gl.TRIANGLES. You can also try gl.LINES and gl.POINTS.

Simple drawing with turtle, Using your straightedge, draw a reference line, if one is not provided. Copy the side of the square onto the reference line, starting at a point labeled A'. Construct a perpendicular at point B' to the line through . Place your compass point at B', and copy the side of the square onto the perpendicular. To align the plane of your polygon with a specific drawing axis or other geometry, press the arrow key that corresponds your desired alignment. For example, the up arrow align's the polygon's plane with the blue axis. See the earlier table in Drawing a rectangle or square for details.The Measurements box changes to display the radius. You can

How To Draw Any Animal From A Square, A Triangle And A Circle , Simple drawing with turtle¶. Introduction¶. “Turtle” is a python feature like a drawing board, which lets you command a turtle to draw all over it  Try drawing a quadrilateral, and measure the angles. They should add to 360° Types of Quadrilaterals. There are special types of quadrilateral: Some types are also included in the definition of other types! For example a square, rhombus and rectangle are also parallelograms. See below for more details. Let us look at each type in turn: The

Comments
  • That's perfect but I haven't learned the (.join) method yet and I am having a mid-term next week, so I don't know if it would be a problem if I use it. Thanks a lot for your time!
  • @Bendik This won't print a perfect square, there'll be a newline after the before the last line.
  • Now its a perfect square, of area size*size, fixed the number of rows just now.