# LOL.py # Original skeleton by Profs Van Loan and Lee (cs-1110profs-L@cornell.edu) # and Alex Parkhurst (anp56@cornell.edu) # PLACE YOUR NAME(S) AND NETID(S) HERE # Feb 2016 """ Explores how long it takes you to enter a given random length-3 string.""" from datetime import datetime from random import choice # S1 is the random test string # S2 is the response string # t1 is the first timestamp string # t2 is the second timestamp string ## Note: if you want to make the text-entry challenge easier, delete some ## characters from alfa alfa = 'abcdefghijklmnopqrstuvwxyz' x = raw_input('Press the return key when you are ready.') S1 = choice(alfa) + choice(alfa) + choice(alfa) print '\n The test string: ' + S1 # First time stamp... t1 = str(datetime.utcnow()) S2 = raw_input('Enter the test string as fast as you can: ') # Second time stamp t2 = str(datetime.utcnow()) # Display the two timestamps... print print t1 print t2 ###### Only add code below this line ############################## # Process the correctness of the response... if len(S1) != len(S2): print 'Your response has the wrong number of characters!' elif S1 != S2: print 'There is a character mismatch in your response!' else: print 'Correct response.' # Compute the elapsed time T1 = float(t1[17:]) T2 = float(t2[17:]) if T1>T2: # Have to add 60 if a "new minute" begins during the response EllapsedTime = T2-T1+60 else: EllapsedTime = T2-T1 print 'Ellapsed Time = %6.3f seconds' % EllapsedTime