Python Practice › sys Module Programs › Program 8
Write with sys.stdout
Write a Python program that prints a progress bar with sys.stdout.write.
Output
#.... 20% ##... 40% ###.. 60% ####. 80% ##### 100%
Approach
writedoes not add a newline.
Solution
import sys for step in range(1, 6): sys.stdout.write("#" * step + "." * (5 - step) + f" {step * 20}%\n")Output
#.... 20% ##... 40% ###.. 60% ####. 80% ##### 100%
Learn the concept
New to this topic? Read the lesson, then come back.