Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Issue with Console Printing

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.
I am trying to print a value to the console repeatedly. I print a value that increases by 1 each second. I have a function that spaces out the value so you can not see the previous time it was printed. My issue is that it skips past numbers (ex. from 1, 2, 4, 5, 7, etc.) Did I do something wrong or is it my slow computer?

(I am using Python on Replit. I am new to Python.)
[Here is the code and Console][1]


 [1]: https://i.stack.imgur.com/Dm7q7.png
 
Saloon Keeper
Posts: 4608
182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You print 25 empty lines after each timeValue. Can it be that the timeValue simply scrolls out of sight? How many lines can that console contain?
 
Piet Souris
Saloon Keeper
Posts: 4608
182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch!
 
Carter Timmons
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even without the adding 25 lines, the timing is still inconsistant. Is using time.sleep inaccurate?
 
Marshal
Posts: 73748
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch (again)

Carter Timmons wrote:. . . Is using time.sleep inaccurate?

What does it say in its documentation? What precision are you using for timeValue and for the sleep() call?
I would expect a sleep() method would not be very precise in its timing.
 
If you look closely at this tiny ad, you will see five bicycles and a naked woman:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic