Python Flow Chart For a 'for' Loop In Python

  • Thread starter Thread starter Taylor_1989
  • Start date Start date
  • Tags Tags
    Flow Loop Python
AI Thread Summary
The discussion centers on creating effective flowcharts to complement Python code. Participants highlight the challenge of representing concepts like loops clearly, noting that flowchart conventions can vary by programming language. While there are established shapes for different functions—such as rectangles for processes and diamonds for decisions—there's flexibility in how flowcharts are drawn and what information is included. The conversation emphasizes that flowcharts should serve the creator's understanding and communication needs, suggesting that the level of detail should reflect the intended audience and purpose. Some participants advocate for a concise, one-page flowchart approach to maintain clarity, while others argue for the necessity of more detailed representations for complex processes. The use of pseudocode is also mentioned as an alternative to flowcharts, appealing to those who prefer a textual representation of algorithms. Overall, the discussion underscores the balance between standardized flowcharting practices and personal expression in coding documentation.
  • #51
The Art of Computer Programming by Donald Knuth

https://en.m.wikipedia.org/wiki/The_Art_of_Computer_Programming
These are classics in the field though not everyone owns a copy. They are akin to an encyclopedia of algorithms and as such take some skill and effort to understand not necessarily a good fit for a newbie programmer.

I considered getting a copy but when i saw it coming out in fascicles decided to wait until it was finished. I am still waiting since 1982, it isn't finished and I imagine granddaughter will just have to wait too.
 
  • Like
Likes sysprog, Taylor_1989, QuantumQuest and 1 other person
Technology news on Phys.org
  • #52
I don't use flowcharts that much but that is because I've finished learning how to use python and don't need them anymore. But, back when I was still learning python they were persistent on flowcharts being used as it was easier to understand the code. The way I learned it was that parallelograms are a input or output, rectangles are a processes, ellipses are start or end, and diamonds are a decision or check whether a condition is met. I wouldn't stress about flowcharts because when you finish learning it no one uses it seriously.
 
  • Like
Likes Taylor_1989
  • #53
jedishrfu said:
The Art of Computer Programming by Donald Knuth

https://en.m.wikipedia.org/wiki/The_Art_of_Computer_Programming
These are classics in the field though not everyone owns a copy. They akin to an encyclopedia of algorithms and as such take some skill and effort to understand not necessarily a good fit for a newbie programmer.

I considered getting a copy but when i saw it coming out in fascicles decided to wait until it was finished. I am still waiting since 1982, it isn't finished and I imagine granddaughter will just have to wait too.
Professor Donald Knuth is a man the praises regarding whom I cannot sing highly enough. Maybe his pipe organ (yes, everyone, he explains why it has to be a real pipe organ) can sing that high, but I can't. May all that is good be presented to that great man. And oh yeah when you use ##\TeX## you're using that man's code. He wrote it.
 
  • Like
Likes Klystron and Taylor_1989
  • #54
At one of my old jobs, we bought a program (AllClear) that converted psuedocode into a flowchart, but after a couple of months, it became clear that the pseudocode was easier to follow than the flowchart, and the flowcharts were abandoned.

As for Python using a list for a counter, it's not clear with 3.0 and later versions what happens in range(). In Python 2.7, xrange() was used to iterate a counter, not produce a list, unlike range(), but Python 3.0 deprecated xrange(), and I'm not sure if Python doesn't optimize range() into xrange() depending on how it's used.
 
Last edited:
  • #55
My understanding is that range() is dynamic in this respect and similar to xrange() returning an iterator that generates the next number in sequence whereas the old range() generated a list, taking up a fair amount of memory, that was then iterated over.

https://www.pythoncentral.io/pythons-range-function-explained/
So range() became deprecated and xrange() became the new range() in python3.
 
  • Like
Likes Taylor_1989 and sysprog
  • #56
rcgldr said:
At one of my old jobs, we bought a program that converted psuedocode into a flowchart, but after a couple of months, it became clear that the pseudocode was easier to follow than the flowchart, and the flowcharts were abandoned.

As for Python using a list for a counter, it's not clear with 3.0 and later versions what happens in range(). In Python 2.7, xrange() was used to iterate a counter, not produce a list, unlike range(), but Python 3.0 deprecated xrange(), and I'm not sure if Python doesn't optimize range() into xrange() depending on how it's used.
Yes, that's true -- it was a problem regarding memory pre-allocation versus ad hoc dynamic allocation -- now it's dynamic-only ...
 
  • #57
jedishrfu said:
My understanding is that range() is dynamic in this respect and similar to xrange() returning an iterator that generates the next number in sequence whereas the old range() generated a list, taking up a fair amount of memory, that was then iterated over.

https://www.pythoncentral.io/pythons-range-function-explained/
So range() became deprecated and xrange() became the new range() in python3.
I agree with what Sifu Jedi said.
 
  • #58
I made a glaring error in a post in response to @.Scott.
sysprog said:
You could wire the plug-board on a card duplicating machine to allow that, but how would you get, say, an IBM model 29 keypunch machine to do that? It not only doesn't detect which corner is cut, but also as far as I know, it has no capability to read anything on a card, except if you wrap the card around the program drum to be used as a program card, and in that case it could only heed the codes specific to that keypunch machine; not duplicate the card.
This is wrong. It completely ignores the read station on the Model 29. If, for example, you made an error on a single column of a card, say column 51, and didn't notice until you had typed all the way through column 71, you could feed the next blank card, the hit the reg (register) key, which would advance the prior card to the read station, and position the new card at the punch station. Then you could hit and hold the dup key to duplicate the first 50 characters, then type the corrected character for column 51. and then hit and hold the dup key for the rest of the remaining non-incorrect characters. Then when you hit the release key, you could discard the errant card, and be on your merry way. Sorry about the mis-statement earlier.
 
  • #59
I am reminded of a story at GE years ago where a top keypunch operator noted for her speed was brought into test the latest and greatest new keypunch machine guaranteed to handle the fastest typist until they met Sue. She typed so fast there were noticeable pauses on the machine while it struggled to keep up. She liked the machine but sadly no it’s wasn't fast enough for the best operators. The sales guy was quite flummoxed over it but GE bought a few anyway.
 
Last edited:
  • #60
Professor Knuth (Donald Knuth, of TAoCP and ##\TeX## fame) used to regularly outspeed the fastest electric typewriters. He loved the first IBM Selectric he encountered, in part because although he could outspeed it too, its buffering capability allowed it to catch up when he'd pause.
 
  • #61
The secret of the ASR 33 and ASR 35 teletype machines was some kind of force feedback (I don't know how it worked), that forced you to slow down and type in perfect rhythm with the machine. That did not make fast typing, but it greatly reduced the error rate.

Even today, I wager that I could type with fewer errors with the help of a metronome.
 
  • #62
Some vintage history on the teletype

http://www.samhallas.co.uk/repository/telegraph/teletype_story.pdf
And more specifically the asr33

https://en.m.wikipedia.org/wiki/Teletype_Model_33
The heavier key press was due to electromechanical feel of a typewriter. I suspect it may have been an engineering scheme to control the speed of the character bits written to tape or sent over the line as well as typing it on the paper. It’s true though you developed a certain rhythm when typing at about 10 characters per second.
 
Last edited:
  • #63
anorlunda said:
The secret of the ASR 33 and ASR 35 teletype machines was some kind of force feedback (I don't know how it worked), that forced you to slow down and type in perfect rhythm with the machine.
A key part of that mechanism was the requirement for deep keystrokes. You had to push the key down about half an inch for it to register - and once one key was down, the next could not be pressed at all until the first key had fully returned to its original position. Since a key would not return to its original position until the cycle had ended, you couldn't type ahead at all.
 
  • Like
  • Informative
Likes jbriggs444 and anorlunda
  • #64
I've tried using Ctrl +C to break infinite loops, to no effect, in Jupyter notebooks . Do you know anything else that would break an infinite loop?
 
  • #65
WWGD said:
I've tried using Ctrl +C to break infinite loops, to no effect, in Jupyter notebooks . Do you know anything else that would break an infinite loop?

1671582850912.png

https://en.wikipedia.org/wiki/Power_symbol
 
  • Like
Likes DrJohn and WWGD
  • #66
WWGD said:
I've tried using Ctrl +C to break infinite loops, to no effect, in Jupyter notebooks . Do you know anything else that would break an infinite loop?
Kernel -> Interrupt, or the ■ button.
 
  • #67
sysprog said:
You could wire the plug-board on a card duplicating machine to allow that, but how would you get, say, an IBM model 29 keypunch machine to do that? It not only doesn't detect which corner is cut, but also as far as I know, it has no capability to read anything on a card, except if you wrap the card around the program drum to be used as a program card, and in that case it could only heed the codes specific to that keypunch machine; not duplicate the card.
Since this thread has been bumped. I'll respond to this.
Here is a link to a 029 instructional video.
The actual mp4 file is here.
The photos below are from frames of that video.
This first image shows the part of the card bed between the punching station (out of frame to the right) and the read station (on the left).
029KeyPunchReadstationB.jpg

I have circled an important part of the card path. It is where a card can be manually fed to the read station.
There's a corresponding slot on the bottom of the card bed that is only barely visible from the cameras viewing angle.
To duplicate a damaged card, feed that damaged source card through that "slot" and feed a blank card to the punching station.
Then, hold down the "DUP" key:
029KeyPunchReadstationD.jpg

029KeyPunchReadstationE.jpg
 

Similar threads

Replies
5
Views
1K
Replies
10
Views
3K
Replies
43
Views
4K
Replies
16
Views
2K
Replies
31
Views
3K
Replies
3
Views
1K
Back
Top