How to Convert Python Code to Effective Pseudocode?

  • Context: Python 
  • Thread starter Thread starter Mr Davis 97
  • Start date Start date
  • Tags Tags
    Code Python
Click For Summary

Discussion Overview

The discussion revolves around converting Python code into effective pseudocode, focusing on how to balance specificity and generality. Participants explore the nuances of describing code functionality in a way that is accessible to non-technical audiences while retaining necessary details.

Discussion Character

  • Exploratory
  • Conceptual clarification
  • Debate/contested

Main Points Raised

  • One participant suggests describing each line of code in human terms to avoid technical jargon.
  • Another participant emphasizes the importance of including specific details, such as the format of inputs, to ensure clarity.
  • There is a discussion about the representation of integer division in pseudocode, with suggestions to specify that the result should be integerized.
  • Some participants note the difference in division symbols between Python and other languages, highlighting the potential confusion this may cause in pseudocode.

Areas of Agreement / Disagreement

Participants express differing views on how much detail to include in pseudocode, indicating that there is no consensus on the best approach. The discussion remains unresolved regarding the balance between generalization and specificity.

Contextual Notes

Participants mention the potential variability in pseudocode acceptance based on educational context, which may influence how certain operations are represented.

Mr Davis 97
Messages
1,461
Reaction score
44
I have the following python code:

YYCRTe6.png


I need to know how to best convert this to pseudocode. On one hand, I am afraid of making it too python specific, and on the other hand, it can't be too general. For example, for the 2nd and 3rd blocks of code, how would I write them in pseudocode? What should I include and what should I leave out?
 
Technology news on Phys.org
Try describing what each line is doing to a non-techie.

You don't leave things out, you simply describe them in more human terms.

find position of colon1
take everything to the left of colon1, multiply it by 16
take everything to right of colon1 and add the above to it

This may or may not be the type of pseudocode acceptable in your class , for example, whether you should assign those values to variable to be more explicit.
 
DaveC426913 said:
Try describing what each line is doing to a non-techie.

You don't leave things out, you simply describe them in more human terms.

find position of colon1
take everything to the left of colon1, multiply it by 16
take everything to right of colon1 and add the above to it

This may or may not be the type of pseudocode acceptable in your class , for example, whether you should assign those values to variable to be more explicit.

Okay, I think that helps clear things up. So for the first two inputs would I just say "get initialWeight" our do I have to describe that the input is of the form "lbs:ozs"?
 
Well, that's up to you. It's a balance between making the code generalized and keeping the details.
Yea, I would include it. The code needs it, regardless of what language it gets written in.
 
DaveC426913 said:
Well, that's up to you. It's a balance between making the code generalized and keeping the details.
Yea, I would include it. The code needs it, regardless of what language it gets written in.
Alright, thanks! One final question. I know that the universal symbol for modulo division is mod. But what should I use or say to indicate integer division?
 
Mr Davis 97 said:
Alright, thanks! One final question. I know that the universal symbol for modulo division is mod. But what should I use or say to indicate integer division?
The / is pretty universal for division. You'd also specify that the result should be integerized.
 
Mr Davis 97 said:
Alright, thanks! One final question. I know that the universal symbol for modulo division is mod. But what should I use or say to indicate integer division?
Python uses two different symbols for division, unlike C.
Regular division (floating point result) /
Integer division (floor) //

For example, 6/5 == 1.2, while 6//5 == 1
 
Mark44 said:
Python uses two different symbols for division, unlike C.
Regular division (floating point result) /
Integer division (floor) //

For example, 6/5 == 1.2, while 6//5 == 1
Which is a good reason why he should not use it is his pseudocode. :wink:
 

Similar threads

  • · Replies 40 ·
2
Replies
40
Views
2K
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
1K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 4 ·
Replies
4
Views
4K
Replies
55
Views
7K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 8 ·
Replies
8
Views
4K