- Joined
- Feb 12, 2004
- Location
- The Netherlands
So, for college we have to learn some (basic) scripting using Python. Anyhow, this is supposed to be week 1 stuff but I can't get my head around it. I have zero idea how to do it. I've even got 'A Byte of Python' printed out, used google and other various resources but alas.
Here's the deal:
I have to write a program that creates the following:
xxxxx
x----x
xxxxx
(you can ignore the ---, but the forum wouldn't place the closing x in the right place so I had to draw it like this)
A rectangle. Length = equal to whatever Int you input. Height (or breadth) is always 3
I'm supposed to use the + and - operators aswell as \n
So far I have:
lengte = int(input("Geef de lengte op"))
a = 'x'
print(a*lengte)
print(a)
print(a*lengte)
This gives me:
xxxxx
x
xxxxx
Obviously I haven't used +. - or \n and no amount of math that I can think of would complete the rectangle. The college sheets we have are pretty useless aswell. I have another 83page python pdf with various examples, but none that cover this. I wish people would make a true beginners guide for this stuff. "Damnit Teacher I'm a network engineer, not a code junkie". Extremely frustrating.
Any help would be appreciated. Thanks.
Here's the deal:
I have to write a program that creates the following:
xxxxx
x----x
xxxxx
(you can ignore the ---, but the forum wouldn't place the closing x in the right place so I had to draw it like this)
A rectangle. Length = equal to whatever Int you input. Height (or breadth) is always 3
I'm supposed to use the + and - operators aswell as \n
So far I have:
lengte = int(input("Geef de lengte op"))
a = 'x'
print(a*lengte)
print(a)
print(a*lengte)
This gives me:
xxxxx
x
xxxxx
Obviously I haven't used +. - or \n and no amount of math that I can think of would complete the rectangle. The college sheets we have are pretty useless aswell. I have another 83page python pdf with various examples, but none that cover this. I wish people would make a true beginners guide for this stuff. "Damnit Teacher I'm a network engineer, not a code junkie". Extremely frustrating.
Any help would be appreciated. Thanks.
Last edited: