The Student Room Group

Help me with my computer science plz.

Write pseudocode for a program that prints 5 lines in the pattern shown below.
X
XXX
XXXXX
XXXXXXX
XXXXXXXXX
Reply 1
Original post by learner38
Write pseudocode for a program that prints 5 lines in the pattern shown below.
X
XXX
XXXXX
XXXXXXX
XXXXXXXXX

DId it ask for a for loop or anything like that if not ill write it for you now but my pseudocode is pretty terrible
Original post by learner38
Write pseudocode for a program that prints 5 lines in the pattern shown below.
X
XXX
XXXXX
XXXXXXX
XXXXXXXXX


Show us your attempt. Pseudocode has no syntax, just show some basic understanding using plain English.
(edited 4 years ago)
Reply 3
Original post by EKGreb
DId it ask for a for loop or anything like that if not ill write it for you now but my pseudocode is pretty terrible

#A variable has to be defined before use
Xs = ("X")
#After a variable has been defined it can be printed
print (Xs)
#Redifining the variable allows another x to be added each time
Xs = ("XXX")
print (Xs)
Xs = ("XXXXX")
print (Xs)
Xs = ("XXXXXXX")
print (Xs)
Reply 4
Original post by EKGreb
DId it ask for a for loop or anything like that if not ill write it for you now but my pseudocode is pretty terrible


No it didnt
Reply 5
THANK YOU EVERYONE I didn’t think it was this simple. I overthought it.
letter = "X"
lines = 5
currentLines = 0
while(lines != currentLines):
print(letter)
letter += "XX"
currentLines+=1

Efficient, can work for as many lines as you want
I've seen the other answers being just print statements, I assure you that's not what they want.
Original post by learner38
THANK YOU EVERYONE I didn’t think it was this simple. I overthought it.

You are right, it's not just meant to be print statements. See by answer above
Reply 9
Original post by Hammad(214508)
You are right, it's not just meant to be print statements. See by answer above


Thank you.
Original post by Hammad(214508)
letter = "X"
lines = 5
currentLines = 0
while(lines != currentLines):
print(letter)
letter += "XX"
currentLines+=1

Efficient, can work for as many lines as you want


Thank you soo much
Can someone help me with another question. It’s a pseudocode.

Star=1
While star < 5
Write(“*”)
Next n
Writeline
Star=star 1
Endwhile

What will be the output?
(edited 4 years ago)
Original post by learner38
Can someone help me with another question. It’s a pseudocode.

Star=1
While star < 5
Write(“*”)
Next n
Writeline
Star=star 1
Endwhile

What will be the output?

*
**
***
****
I assume it is this, your code looks very confusing
Original post by Hammad(214508)
*
**
***
****
I assume it is this, your code looks very confusing


It’s a pseudocode and I didn’t make it. Thank youuu
Original post by learner38
It’s a pseudocode and I didn’t make it. Thank youuu

The real question is whether you really understand how to apply computational thinking skills to solve these problems for yourself? I would strongly recommend that you ignore all the answers you've been given in this thread and sit down to figure it out for yourself. You really need to practice finding these solutions by yourself otherwise you're going to have a difficult time in the exam, and from here onwards the programming problems you'll be faced with are only going to get more complicated.

Writing the actual Python or Pseudocode syntax is the easy part because that's something that you can memorise and find on Google; the hard part is the thought process which goes into analysing the problem, breaking the problem down, looking for patterns and trying to think about the steps which form the solution -- this isn't something that you can memorise and it's not something you can find on Google either; it's a new way of thinking and a skill that you need to learn, but you can only learn that skill and way of thinking through practice with solving problems like this. It just takes a bit of time but it will click if you give it a go.

The 'print' steps are actually a really useful starting point because they should show you the pattern that you need to implement and find a more generalised (abstract) way to solve, so that you can do the same thing for 'any' number of lines without needing to change the code.

If you are having trouble finding solutions to problems like this then you really need to practise finding these solutions for yourself otherwise you are going to have a very difficult time in the exam.

Have a look at some of these videos, they'll explain the kinds of methods you need to learn and how to approach any programming problem:
https://student.craigndave.org/videos/2-1-algorithms
(edited 4 years ago)
Original post by winterscoming
The real question is whether you really understand how to apply computational thinking skills to solve these problems for yourself? I would strongly recommend that you ignore all the answers you've been given in this thread and sit down to figure it out for yourself. You really need to practice finding these solutions by yourself otherwise you're going to have a difficult time in the exam, and from here onwards the programming problems you'll be faced with are only going to get more complicated.

Writing the actual Python or Pseudocode syntax is the easy part because that's something that you can memorise and find on Google; the hard part is the thought process which goes into analysing the problem, breaking the problem down, looking for patterns and trying to think about the steps which form the solution -- this isn't something that you can memorise and it's not something you can find on Google either; it's a new way of thinking and a skill that you need to learn, but you can only learn that skill and way of thinking through practice with solving problems like this. It just takes a bit of time but it will click if you give it a go.

The 'print' steps are actually a really useful starting point because they should show you the pattern that you need to implement and find a more generalised (abstract) way to solve, so that you can do the same thing for 'any' number of lines without needing to change the code.

If you are having trouble finding solutions to problems like this then you really need to practise finding these solutions for yourself otherwise you are going to have a very difficult time in the exam.

Have a look at some of these videos, they'll explain the kinds of methods you need to learn and how to approach any programming problem:
https://student.craigndave.org/videos/2-1-algorithms


Omg you sound like my teacher but I shall revise these it’s because I’ve just learnt this topic

Quick Reply

Latest

Trending

Trending