Skip to content

Instantly share code, notes, and snippets.

@afeish
Created September 28, 2020 02:22
Show Gist options
  • Save afeish/5c81fdef62c8857590fb97707650dc77 to your computer and use it in GitHub Desktop.
Save afeish/5c81fdef62c8857590fb97707650dc77 to your computer and use it in GitHub Desktop.
progressing-bar using python
import time
scale = 50
print("starting".center(scale // 2,"-"))
start = time.perf_counter()
for i in range(scale + 1):
a = "*" * i
b = "." * (scale - i)
c = (i / scale) * 100
dur = time.perf_counter() - start
print("\r{:^3.0f}%[{}->{}]{:.2f}s".format(c,a,b,dur),end = "")
time.sleep(0.1)
print("\n"+"end".center(scale // 2,"-"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment