Created
June 29, 2023 10:41
-
-
Save AlgorithmAlchemy/5a8c3cd0ce6941a56870fdd6dcef39e2 to your computer and use it in GitHub Desktop.
Simple Progress bar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
def progress_bar(progress, total, bar_length=40): | |
filled_length = int(bar_length * progress // total) | |
bar = '█' * filled_length + '-' * (bar_length - filled_length) | |
percentage = progress / total * 100 | |
print(f'Progress: [{bar}] {percentage:.2f}%') | |
def simulate_process(total_time): | |
for t in range(total_time + 1): | |
progress_bar(t, total_time) | |
time.sleep(1) | |
total_time = 20 | |
simulate_process(total_time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment