bhargavnova / python-helper-modules

MIT License
7 stars 24 forks source link

Created random_sleep_time_module #13

Closed avyuktsoni0731 closed 9 months ago

avyuktsoni0731 commented 9 months ago

Closes issue #4

Made a Python module named "random_sleep_time_module"

  1. Imported time module.
  2. Imported random module.
  3. Made a definition named "random_time_sleep()".
  4. Made user enter the startTime (left hand limit for choosing random time) & endTime (right hand limit for choosing random time).
  5. Made user enter the number of seconds from which they want to begin the countdown.
  6. Made a while loop for the condition, till when the countdown hits 0.
  7. Inside the while loop, made conversions of time inputted in seconds to convert it in "hours:minutes:seconds" format.
  8. Made nested if-elif-else loops for different conditions of countdown time.
  9. Have put comments on every step being performed.

Please run the main.py file by putting different values to verify the program.

Let me know if any changes are required.

Thanks a lot ^_^

bhargavnova commented 9 months ago

As you can see here, we got min_time = 20, max_time = 21 using random found random_number = 21

as you can see countdown is changing at the same line, because of sys using \r, which brings cursor to beginning or the line, where print() always adds \n at the end, if you don't mention end=" " so this was second tip, you can also use print("" , end="\r")

sleeping for 21 seconds reached 17 sleeping for 21 seconds reached 17

sleeping for 21 seconds reached 16 sleeping for 21 seconds reached 16

sleeping for 21 seconds reached 14 sleeping for 21 seconds reached 14

avyuktsoni0731 commented 9 months ago

Hi @bhargavnova ! Thank you for explaining with such patience, really appreciate that. I am new to open source contributions, and wanted to contribute in a good python project. Took me a while to understand the assignment, but i suppose now I get it. Made it as close as possible, and as concise as possible.

Please have a look at it.

Thanks a lot :)