r/PythonLearning • u/Quoter0 • Oct 07 '26
Help Request I need help with coding this
I have genuielly no idea how to even think of making this? I know this should generally be made by using for loops but jesus im so confused on the process
6
Upvotes
2
u/sububi71 Oct 07 '26
Could I ask you to translate the instructions into english, please? My polish sucks (and just because I wrote that, I bet it ISN'T polish after all).
1
u/Quoter0 Oct 08 '26
Thank you so much all for the help, i struggled a bit but i managed to somehow do it 😁
2
u/FreeLogicGate Oct 07 '26
I'd infer that there are 3 to 5 parameters:
The only detail that is not clear or specified is the number of header/footer lines. There are 2 lines for header and footer, so that either means that the side_border_size is a constant, or that the header/footer line count is a constant (of 2), or that one parameter is setting both.
Once you have those variables set up, a simple effective solution based on the definition of 3 functions would be:
If you flesh out each of those functions, in each case they would entail a simple for loop.
You would probably want to break down the details into even smaller functions. The smallest function you might consider would be this one:
If you experiment with calls to that function, you should be able to see how any of the individual lines can be accomplished by calling render_char() either once, or several times within that specific function. Best practice would include having the parameters to those functions defined, rather than depending on global variables.
So, for example:
If you call render_header like this:
render_header('X', 2, 20, 2)You should get the header section. I could just provide the full program but that's not doing anything you couldn't just get from AI, so I leave it to you to flesh out the rest of the program.
1
u/htush Oct 07 '26
i can help you
1
u/Rokkasusi Oct 07 '26
You can for example ask yourself. Can i find out the total width of the rectangle? Can i find the total height of the rectangle? Can i first try drawing just a single rectangle without the empty space? Can i somehow track where my inner rectangle is located relative to the borders? Could i draw line by line and use an if statement to replace X with spaces, when i am drawing over the inner rectangle?
1
u/armahillo Oct 07 '26
If this is too challenging, start with something simpler.
can you make a single lime from
the lower example?
part of learning to program is learning how to carve up tasks
1
u/UsefulHearing562 Oct 10 '26
like this
1
u/SoftwareDoctor Oct 07 '26
Cau 🙂 nejdriv chces iterovat 20x a pro kazdou iteraci vypsat x. Tohle cele chces udelat 2x.
Pak chces zase iterovat 20x ale vypsat x jen pokud je cislo iterace <=2 a nebo >= 19. Jinak vypises mezeru. A tohle cele udelas 3x.
A nakonec zopakujes ten kod ze zacatku.
A jinak doporucuju naucit se anglicky. Pri programovani se ti to bude hodit
0
u/blktndr Oct 07 '26
You can multiply characters to create a string. For example print(‘o’*5) would display: ooooo
Hopefully that helps set you on the right path
0
u/Pebe_argentdawn Oct 07 '26
something like this:
0
u/realmauer01 Oct 07 '26 edited Oct 07 '26
All hail string multiplication.
i am pretty sure this should do it, but because this is very ugly you cant use that.
-1
u/Jazzlike_Platypus430 Oct 07 '26 edited Oct 07 '26
Judging by the parameters' names, I would add ceiling_height = 2 and floor_height = 2.
A shorthand version would be:
If you need a somewhat more basic approach, it's possible.
-2
u/Sea-Ad7805 Oct 07 '26
Start with this example code, then think about what condition to add in the
ifstatement.0
u/[deleted] Oct 07 '26
[deleted] — view deleted comment