Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Repeating a block of code
#8
Bass basically answered this already, but I wanted to chime in and let you know what I did to my son a few days ago (I try to show my kids everything I learn in some fun way; perhaps spark a creative want for programming to see if it wants to stick with them). I called my son in and told him I can type "I am the world's greatest Dad!" so fast I can do it 1,000 times in only a few seconds. Wide-eyed and achin' to see me try, he told me to type it once. I pulled up IDLE and typed "I am the world's greatest Dad!" rather slowly.

After calculating mere seconds are already expired he called me on my bluff. What he did not realize, I had already typed this into IDLE:
p = "I am the world\'s greatest Dad!"
I pulled up my phone's timer and handed him my phone then told him to time me and let me know when to start. When he told me to go I typed:
for i in range(1000):
    print(p)
NOTE: Hit ENTER twice here after closing that last parenthesis.

As soon as I hit ENTER the second time I acted like I was typing so fast causing my fingers to rattle the keys to simulate me typing (when I wasn't). Oh the look on his face... it was so much fun. Poor kid didn't even stop the timer. After about 15 seconds he set the phone down, politely said, "Cheater!" and walked away. I had way too much fun with that one. You guys and gals should have seen it.
Reply


Messages In This Thread
Repeating a block of code - by owdcoder - Jun-11-2017, 02:52 PM
RE: Repeating a block of code - by Bass - Jun-11-2017, 02:58 PM
RE: Repeating a block of code - by buran - Jun-11-2017, 03:03 PM
RE: Repeating a block of code - by owdcoder - Jun-11-2017, 03:57 PM
RE: Repeating a block of code - by wavic - Jun-11-2017, 05:36 PM
RE: Repeating a block of code - by Bass - Jun-11-2017, 05:48 PM
RE: Repeating a block of code - by Larz60+ - Jun-11-2017, 07:27 PM
RE: Repeating a block of code - by RodNintendeaux - Jun-12-2017, 12:01 AM
RE: Repeating a block of code - by nilamo - Jul-14-2017, 03:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why is 2/3 not just .666 repeating? DocFro 4 884 Dec-12-2023, 09:09 AM
Last Post: buran
  python multiple try except block in my code -- can we shorten code mg24 10 6,892 Nov-10-2022, 12:48 PM
Last Post: DeaD_EyE
  repeating a user_input astral_travel 17 2,643 Oct-26-2022, 04:15 PM
Last Post: astral_travel
  if else repeating Frankduc 12 2,858 Jul-14-2022, 12:40 PM
Last Post: Frankduc
  "If Len(Word) == 0" Code Block in Pig Latin Program new_coder_231013 3 2,220 Jan-02-2022, 06:03 PM
Last Post: deanhystad
  Try,Except,Else to check that user has entered either y or n (Code block pasted) RandomNameGenerator 3 2,442 Jun-29-2021, 08:21 PM
Last Post: RandomNameGenerator
  Repeating lines of code by an input Josh_Albanos 3 2,555 Oct-15-2020, 01:04 AM
Last Post: deanhystad
  factorial, repeating Aldiyar 4 2,974 Sep-01-2020, 05:22 PM
Last Post: DPaul
  Block of code, scope of variables and surprising exception arbiel 8 3,622 Apr-06-2020, 07:57 PM
Last Post: arbiel
  zlib decompress error: invalid code lengths set / invalid block type DreamingInsanity 0 7,076 Mar-29-2020, 12:44 PM
Last Post: DreamingInsanity

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020