{"id":795,"date":"2021-11-01T05:59:53","date_gmt":"2021-11-01T05:59:53","guid":{"rendered":"https:\/\/ethosspace.com\/programmers\/?p=795"},"modified":"2023-05-23T08:30:27","modified_gmt":"2023-05-23T08:30:27","slug":"programs-to-print-different-square-rectangle-in-python","status":"publish","type":"post","link":"https:\/\/ethosspace.com\/programmers\/programs-to-print-different-square-rectangle-in-python\/","title":{"rendered":"Programs to print different Square, rectangle in Python Language"},"content":{"rendered":"\n<p>Below program will accept width and breadth from user. We can print SOLID rectangle, need to use two for loops along with print function with end parameter.<\/p>\n\n\n\n<p>Step 1) Accept breadth and width from user<br>Step 2) First for loop is to <a href=\"https:\/\/ethosspace.com\/programmers\/print-function-with-different-examples-in-detail\/\" title=\"Print function with different examples in detail\">print <\/a><\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>#Python program to print hollow rectangle, solid rectangle.\n#accept width and breadth from user\nwidth=int(input(&quot;Enter Width\\t&quot;))\nbreadth=int(input(&quot;Enter breadth \\t&quot;))\nfor i in range(0,breadth):\n    for j in range(0,width):\n        print(&quot;*&quot;,end=&quot;&quot;)\n    print()<\/code><\/pre><\/div>\n\n\n\n<p><strong>OUTPUT<\/strong><\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>Enter Width\t5\nEnter breadth \t3\n\n*****\n*****\n*****<\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Python Program to print hollow rectangle<\/h2>\n\n\n\n<p>This tricky program. It is important to use <a href=\"https:\/\/ethosspace.com\/programmers\/print-function-with-different-examples-in-detail\/\" title=\"https:\/\/ethosspace.com\/programmers\/print-function-with-different-examples-in-detail\/\">print <\/a>function along with end parameter effectively. Here is the complete code<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>#Python program to print hollow rectangle\n#accept width and breadth from user\nwidth=int(input(&quot;Enter Width\\t&quot;))\nbreadth=int(input(&quot;Enter breadth \\t&quot;))\nfor i in range(0,breadth):\n    for j in range(0,width):\n        if (i==0 or j ==0 or i==breadth or j==width):\n             print(&quot; *&quot;,end=&quot;&quot;)\n        else:\n             print(&quot; &quot;,end=&quot;*&quot;)\n    print()<\/code><\/pre><\/div>\n\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>Enter Width\t3\nEnter breadth \t4\n * * *\n * * *\n * * *\n * * *<\/code><\/pre><\/div>\n\n\n\n<p>Use free online<a href=\"https:\/\/ethosspace.com\/programmers\/free-online-python-compiler-interpreter\/\" title=\"https:\/\/ethosspace.com\/programmers\/free-online-python-compiler-interpreter\/\"> python compiler<\/a> to write execute any python program.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Below program will accept width and breadth from user. We can print SOLID rectangle, need to use two for loops along with print function with end parameter. Step 1) Accept breadth and width from userStep 2) First for loop is to print OUTPUT Python Program to print hollow rectangle This tricky program. It is important [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[11],"tags":[],"class_list":["post-795","post","type-post","status-publish","format-standard","hentry","category-running-code-and-program"],"aioseo_notices":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"sparkling-featured":false,"sparkling-featured-fullwidth":false,"tab-small":false},"uagb_author_info":{"display_name":"program45_-rt8nb","author_link":"https:\/\/ethosspace.com\/programmers\/author\/program45_-rt8nb\/"},"uagb_comment_info":1,"uagb_excerpt":"Below program will accept width and breadth from user. We can print SOLID rectangle, need to use two for loops along with print function with end parameter. Step 1) Accept breadth and width from userStep 2) First for loop is to print OUTPUT Python Program to print hollow rectangle This tricky program. It is important&hellip;","_links":{"self":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/795","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/comments?post=795"}],"version-history":[{"count":7,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/795\/revisions"}],"predecessor-version":[{"id":1401,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/795\/revisions\/1401"}],"wp:attachment":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/media?parent=795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/categories?post=795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/tags?post=795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}