Computers and Technology

1. The following pseudocode tests how quickly a user can type a given sentence without making any mistakes. The statement finishTime = time.clock() returns wall-clock seconds elapsed since the first call to this function and places the answer in finishTime.import timesentence = "The quick brown fox jumped over the lazy dog"n = len(sentence)print ("Sentence to type: ", sentence)errorFlag = Falseprint ("Press Enter when youre ready to start typing! Press Enter when finished ")ready = input()print(Go)time.clock() # you can call the function without returning a value mySentence = input()finishTime = time.clock()if mySentence sentence then errorFlag = TrueendiffinishTime = round(finishTime,1)if errorFlag == True then print ("You made one or more errors")else print ("Total time taken ",totalTime, "seconds")endif (a) What does the statement import time do? [1] (b) What type of variable is each of the following? [4] (i) errorFlag (ii) n (iii) totalTime (iv) mySentence (c) What does line 15 do? [1] (d) Alter the program so that instead of storing the sentence The quick brown fox jumped over the lazy dog, the user can enter the sentence on which they will be timed. [3]2. A customer entering security details when logging into a bank website is asked to enter three random characters from their password, which must be at least 8 characters long and contain no spaces.Assume that in this case the password is HC&dt2016. The letters are then compared to those in the password held on file for that customer. Kelly has a first attempt at writing pseudocode for the algorithm.import randomcustomerPassword = "HC&dt2016" #(assume read from file)numChars = len(customerPassword)index1 = random.randint(0, numChars-1)index2 = random.randint(0, numChars-1)index3 = random.randint(0, numChars-1)print ("Please enter characters ", index1+1, index2+1, index3+1, "from your password.")print ("Press enter after each character: ")char1 = input()char2 = input()char3 = input()if print("Welcome")elseprint ("Password incorrect") (a) What value is assigned to numChars at line 3? [1] (b) Complete the if statement at line 12. [3] (c) What possible values may be assigned to index1 at line 4? [1] (d) Describe two weaknesses of this algorithm. [2]2. Write pseudocode for one or more selection statements to decide whether a year is a Leap year. The rules are: A year is generally a Leap Year if it is divisible by 4, except that if the year is divisible by 100, it is not a Leap year, unless it is also divisible by 400. Thus 1900 was not a Leap Year, but 2000 was a Leap year. [4]