File Handling 3
Study the code below and explain what it does, line by line. 001 newFile = open(“file.txt”) 002 newFile.writeLine(“revisecs.com”) 003 newFile.close()
Study the code below and explain what it does, line by line. 001 newFile = open(“file.txt”) 002 newFile.writeLine(“revisecs.com”) 003 newFile.close()
Study the code below and explain what it does, line by line. 001 newFile = open(“file.txt”) 002 while NOT newFile.endOfFile() 003 print(newFile.readLine()) 004 endwhile 005 newFile.close()
The following modes of transport are stored in an array, with “transport” as the identifier: transport = [“car”, “bus”, “plane”, “boat”, “bicycle”] Complete the following output statement, so that the sentence it generates makes sense. print(“A ” + ______ + “travels through the air, whereas a” + ______ + “travels on water.”)
Study the following arrays. x_numbers = [2,5,3,1,3,2,4,5,2] y_numbers = [[2, 5, 3], [1, 3, 2], [4, 5, 2]] a) What type of array is x_numbers? b) How would the value of 4 be access in the array x_numbers? c) What type of array is y_numbers? d) How would the value of 4 be access in
Study the code below: 001 number1 = 3 002 number2 = 5 003 number3 = 7 004 if (number1 > number2) AND (number2 > number3): 005 print(number1, “is the bigger number”) The algorithm above has two different types of operator on line 004. State the names of each type of operator
Operations and String Methods 3 Read More »
Programming languages have many inbuilt string manipulation methods. State the output of the following algorithm and explain your answer fully. 001 name = “Elon Musk” 002 subName = name.subString(5, 4) 003 print(subName)
Operations and String Methods 2 Read More »
Explain the difference between the DIV and MOD operators, using the following calculations as examples: 1. 10 DIV 3 2. 10 MOD 3
Operations and String Methods 1 Read More »