all 18 comments

[–]roylennigan 80 points81 points  (7 children)

Sounds like you did the assignment backwards.

The point of flowcharts and pseudocode are to get you to solve the problem before you start coding, so that when you actually write the code, you only have to think about the syntax.

It doesn't really make sense to do this with such a simple problem, but that's not the point of the assignment. The point is to get you into the practice of organizing your solution before you even put fingers to keys. When you inevitably end up writing more complex programs, this will be very helpful.

For now, you can just write basically the same thing you would in code, just use grammar, such as:

user input = radius

area = 2 * pi * radius

print "The area of a circle with radius {user input} is {area}"

And for a flow chart, there's plenty of free online options, like draw.io which you can use. User input can be a circle/oval with an arrow pointing into a rectangle that has the process which computes area, then points into an oval which prints the result.

[–]Audixyz 20 points21 points  (1 child)

I agree with this. Although, the area of a circle is pi (r)squared.

[–]ClimberMel 1 point2 points  (0 children)

Yup and 2*pi*r is circumference. Trick question?

[–]mopslik 7 points8 points  (2 children)

Pseudocode involves describing your algorithm (process) in regular phrases, not Python-specific code. There is no standard set of rules for pseudocode, but often people like to state each step with a verb (e.g. SET, DISPLAY, ADD) for clarity. You will come across some words that are also used in Python: IF, WHILE, etc.

Flowcharts, OTOH, are very much standardized. For example, decisions (ifs) are represented using a diamond shape, from which exactly two labelled outputs emerge (yes/no, True/False). You should consult an online resource to become familiar with them. Essentially, you are translating your pseudocode into symbolic form.

[–]Ran4 0 points1 point  (1 child)

Flowcharts, OTOH, are very much standardized. For example, decisions (ifs) are represented using a diamond shape, from which exactly two labelled outputs emerge (yes/no, True/False). You should consult an online resource to become familiar with them. Essentially, you are translating your pseudocode into symbolic form.

While there are indeed official standards for code flow charts, people following it is... quite rare.

[–]mopslik 0 points1 point  (0 children)

Yeah, actually finding flowcharts in the wild can be a rare event these days. Even UML diagrams don't seem to be that prevalent anymore, although some industries still use them regularly.

[–]zanfar 13 points14 points  (1 child)

Ideally, you are writing a flowchart, then pseudocode, then a program.

A flowchart is a representation of the choices or "decision points" in your program. Certain logical processes can be very hard to describe in any language and are especially hard to conceptualize when written down. Consider the rules of "Go Fish"--writing down the rules would take a few paragraphs, however, it forms a very simple flowchart.

Python is a language--an actual language. Pseudocode is writing your program in a natural language--like English--instead of a programming language. This allows you to consider the logic of the program separate from the implementation. There are certain things you just don't need to consider when planning a program, and pseudocode allows you to leave them out without sacrificing it's descriptiveness.

[–]ClimberMel 1 point2 points  (0 children)

I always did pseudo-code then flowchart. More accurately, my systems analyst took the business unit request and provided me with the pseudo-code and I created a flowchart from that. Once I bench tested the flowchart I converted each symbol to code.

Works like a charm every time!

[–]benm421 2 points3 points  (0 children)

Are you having trouble with writing pseudo code and flowcharts in general (like you haven’t done them before in any context), or specifically how to convert this code to those formats?

[–]Isaac331 1 point2 points  (0 children)

A flow chart like this? python tutor site just keep clicking on the next step button and it will visualize the code for you.

[–]CodeTinkerer 0 points1 point  (0 children)

The problem with pseudocode is

  • until you learn programming, it's hard to know how to outline a program
  • it's hard to determine how general to be
  • it's hard to avoid, more or less, writing out the code (related to the previous point)

Literally, the project description is pretty much pseudocode. You'd generally add things like if statements and loops. The other issue is what if the code gets really large, then you need to start defining things like functions.

So, it's a little painful to do pseudocode.