Write with sys.stdout

Easysys Module Programs · 8 of 20

Write a Python program that prints a progress bar with sys.stdout.write.

Advertisement
Output
#.... 20%
##... 40%
###.. 60%
####. 80%
##### 100%

Approach

  1. write does not add a newline.

Solution

Python
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.

More sys module programs

← All 20 sys Module Programs

Leave a Comment