8.1 Problem

While running a time consuming program we may see a progress bar that will provide the user with visual cues as to the course of its execution.

So here is a task for you. Write a computer program that will animate a mock progress bar that goes from 0% to 100% (if you want, make it similar to the one in Figure 2). Don’t worry about the complex calculations (the task is just to animate the bar) and use sleep before printing the bar in each iteration. In order to redraw a bar in a terminal you may want to read about ANSI escape codes. If the above is too much for you try to use carriage return, i.e. print(progress_bar1), print("\r") and print(progress_bar2).

Figure 2: A mock progress bar (animation works only in an HTML document)


CC BY-NC-SA 4.0 Bartlomiej Lukaszuk