SimeonTs

SUPyF2 Functions-Exercise - 08. Loading Bar

Oct 8th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. """
  2. Functions - Exercise
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1728#7
  4.  
  5. SUPyF2 Functions-Exercise - 08. Loading Bar (not included in final score)
  6.  
  7. Problem:
  8. You will receive a single integer number between 0 and 100 which is divided with 10 without residue (0, 10, 20, 30...).
  9. Your task is to create a function that visualizes a loading bar depending on that number you have received in the input.
  10.  
  11. Examples:
  12. Input:          Output:
  13. 30              30% [%%%.......]
  14.                Still loading...
  15.  
  16. 50              50% [%%%%%.....]
  17.                Still loading...
  18.  
  19. 100             100% Complete!
  20.                [%%%%%%%%%%]
  21. """
  22.  
  23.  
  24. def loading_bar(percentage):
  25.     loading_bar_list = ["."] * 10
  26.     end = int(percentage / 10)
  27.     if percentage == 100:
  28.         print("100% Complete!")
  29.         print("[%%%%%%%%%%]")
  30.     else:
  31.         for i in range(0, end):
  32.             loading_bar_list[i] = "%"
  33.         print(f"{percentage}% [{''.join(loading_bar_list)}]")
  34.         print("Still loading...")
  35.  
  36.  
  37. loading_bar(int(input()))
Add Comment
Please, Sign In to add comment