Pseudocode and comments

From 22116
Revision as of 19:26, 25 August 2025 by WikiSysop (talk | contribs)
Jump to navigation Jump to search
Previous: The path and simple file reading Next: Python Input-Output

Required course material for the lesson

Powerpoint: Pseudocode, comments and user interface
Video: The use of pseudocode and comments
Video: Playing the guessing game, detecting lies and endings.
Video: Live Coding
Blog: On User Interface 1, by the founder of StackExchange.
Blog: On User Interface 2, by the founder of StackExchange.
Blog: On User Interface 3, by the founder of StackExchange.
Blog: Designing the software product, by the founder of StackExchange.

Subjects covered

Pseudo code, which is "pretend" code, that tries to look like a program.
Comments, which is essential for understanding, maintenance, explanation, memory and other good stuff.
User interface, how the program should interact with the user.

Advice

Are you looking for files? See the top line of the Programme page.

Exercises to be handed in

In all these exercises, start with writing pseudo code first and the program after. This is how you should do normally.
The pseudo code is part of the hand-in.

  1. Returning to last weeks exercise 4, where you had to ask for a file name and you program would then calculate the average of the numbers in the file. Do the same this time, except you have to continue to ask for file names and calculate the average until you enter nothing - no file name. Test on the same files as last time.
  2. Playing time again. Make the guessing program (lesson 1, exercise 9) count how many attempts it needed to guess the number and print it when done guessing. It must be able to detect if you lie (and say so, of course). Also, if you haven't done it before, make the program guess in the fewest possible guesses (an example of 'binary search'). This is what most people naturally do by themselves when they play the game. You 'just' have to do it in the program. There is a system, a method - find it. Hint: it is probably better to start over than reuse your old program.

Exercises for extra practice