update print python 1

update print python

from time import sleep

N=12

for i in range(N):
   sleep(0.5)
   print(f"{i/N*100:.1f} %", end="\r")

Here is what the above code is Doing:
1. We’re using a for loop to iterate over the range of numbers from 0 to N.
2. We’re using the sleep function to pause the execution of the code for 0.5 seconds.
3. We’re printing the percentage of the loop that has been completed.
4. We’re using the end=”\r” argument to print the percentage on the same line.

Similar Posts