Skip to content

Instantly share code, notes, and snippets.

@AlgorithmAlchemy
Created June 29, 2023 10:41
Show Gist options
  • Save AlgorithmAlchemy/5a8c3cd0ce6941a56870fdd6dcef39e2 to your computer and use it in GitHub Desktop.
Save AlgorithmAlchemy/5a8c3cd0ce6941a56870fdd6dcef39e2 to your computer and use it in GitHub Desktop.
Simple Progress bar
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