Revision - Quiz 1_ Attempt review _ iLearn.pdf
Document Details
Uploaded by PlushSchrodinger
Macquarie University
2024
Tags
Full Transcript
Started on Sunday, 11 August 2024, 12:46 AM State Finished Completed on Sunday, 11 August 2024, 1:08 AM Time taken 22 mins 49 secs Marks 16.32/21.00 Grade 77.72 out of 100.00 Information This quiz should be...
Started on Sunday, 11 August 2024, 12:46 AM State Finished Completed on Sunday, 11 August 2024, 1:08 AM Time taken 22 mins 49 secs Marks 16.32/21.00 Grade 77.72 out of 100.00 Information This quiz should be used for revision purposes only. It is not a mock exam and does not reflect how many questions will be in your actual exam. Question 1 Correct Mark 1.00 out of 1.00 What is the decimal equivalent of binary number 10111101? Answer: 189 The correct answer is: 189 Question 2 Correct Mark 1.00 out of 1.00 What is the binary equivalent of the decimal number 207? Answer: 11001111 The correct answer is: 11001111 Question 3 Incorrect Mark 0.00 out of 1.00 What is the decimal equivalent of the following base 9 number? 235 Answer: 162 The correct answer is: 194 Question 4 Incorrect Mark 0.00 out of 1.00 What is the octal (base-8) equivalent of the decimal number 242? Answer: 162 The correct answer is: 362 Question 5 Incorrect Mark 0.00 out of 1.00 What is the decimal equivalent for the octal number 507? Answer: 377 The correct answer is: 327 Question 6 Correct Mark 1.00 out of 1.00 Type in the internal types of each of the following values (or expressions) 42: int 17.29: float "Futurama": str (5 > 3): bool 2 + 3 * 4: int 7 / 3: float 17 // 5: int 'g': str Question 7 Correct Mark 1.00 out of 1.00 What is the value of the following arithmetic expression? (20 - 5) * (2 + 4) / 3 - 10 Answer: 20 The correct answer is: 20 Question 8 Correct Mark 1.00 out of 1.00 What is the value of variable result? a, b, c, d = 1, 7, 2, 9 result = a + b // c * d Answer: 28 The correct answer is: 28 Question 9 Partially correct Mark 0.57 out of 1.00 Consider the following statement: s = "Fundamentals" Answer the following questions: 1. len(s) = 12 2. s = m 3. s[:4] = Funda 4. s[-3] = t 5. s[:-4] = Fundame 6. s[2:7] = ndame 7. s[4:-4] = amen Question 10 Partially correct Mark 0.75 out of 1.00 What is the highest base for which the numerical values are valid? 172 decimal 10110 binary ACDC hexadecimal 6012 base-8 Question 11 Partially correct Mark 3.00 out of 4.00 What is the lowest base for which the numerical values are valid? 172 decimal 10110 binary ACDC hexadecimal 4012 base-6 Question 12 Correct Mark 1.00 out of 1.00 What is the value of each one of the following boolean expressions? -5 < -5 False -5 >= -5 True -5 >= -5 True -5 > -5 False 10 == 70 False 20 != 90 True 10 == 10.0 True Question 13 Correct Mark 1.00 out of 1.00 Assume the existence of two int variables var1 and var2. Write one line of code to assign the result of 5 plus 2 multiplied by var1 to the power of var2 into a variable named answer. The exponentiation should happen first, multiplication second and addition last. For example: Test Result var1 = 4 answer is 37 var2 = 2 var1 = 6 answer is 93317 var2 = 6 var1 = 10 answer is 20000000000005 var2 = 13 var1 = 9 answer is 9565943 var2 = 7 Answer: (penalty regime: 0 %) 1 answer = 5 + 2 * (var1 ** var2) Test Expected Got var1 = 4 answer is 37 answer is 37 var2 = 2 var1 = 6 answer is 93317 answer is 93317 var2 = 6 var1 = 10 answer is 20000000000005 answer is 20000000000005 var2 = 13 var1 = 9 answer is 9565943 answer is 9565943 var2 = 7 Passed all tests! ▸ Show/hide question author's solution (Python3) Correct Marks for this submission: 1.00/1.00. Question 14 Correct Mark 1.00 out of 1.00 Assume the existence of three variables: price_per_ball (float) num_boba_balls (int) extra_weekend_rate (float - the amount to increase the total price by as a percent from 0.0 to 1.0) Define a variable named total_price which contains the price of purchasing the given number of boba balls using the variables provided. Example: If the extra weekend rate was 0.2 and the TOTAL price of the given boba balls was 16.5, then the total price should become 19.8 i.e. a 20% increase. For example: Test Result price_per_ball = 1 total_price is 15.0 num_boba_balls = 10 weekend_rate = 0.5 price_per_ball = 0.5 total_price is 13.5 num_boba_balls = 20 weekend_rate = 0.35 price_per_ball = 0.86 total_price is 13.244 num_boba_balls = 14 weekend_rate = 0.10 Answer: (penalty regime: 0 %) 1 total_price = price_per_ball * num_boba_balls + (price_per_ball * num_boba_balls * weekend_rate) Test Expected Got price_per_ball = 1 total_price is 15.0 total_price is 15.0 num_boba_balls = 10 weekend_rate = 0.5 price_per_ball = 0.5 total_price is 13.5 total_price is 13.5 num_boba_balls = 20 weekend_rate = 0.35 price_per_ball = 0.86 total_price is 13.244 total_price is 13.244 num_boba_balls = 14 weekend_rate = 0.10 Passed all tests! ▸ Show/hide question author's solution (Python3) Correct Marks for this submission: 1.00/1.00. Question 15 Correct Mark 1.00 out of 1.00 Assume the existence of a variable data. Create a new variable named information containing the type of the data variable. For example: Test Result data = True information is "" data = "cat" information is "" data = [] information is "" data = 5 information is "" data = 81.3 information is "" Answer: (penalty regime: 0 %) 1 information = str(type(data)) Test Expected Got data = True information is "" information is "" data = "cat" information is "" information is "" data = [] information is "" information is "" data = 5 information is "" information is "" data = 81.3 information is "" information is "" Passed all tests! ▸ Show/hide question author's solution (Python3) Correct Marks for this submission: 1.00/1.00. Question 16 Correct Mark 1.00 out of 1.00 Assume the existence of a String variable text. Create a new variable named cleaned containing the data from text but in uppercase and with all leading and trailing spaces removed. For example: Test Result text = ' this is some text ' cleaned is "THIS IS SOME TEXT" text = ' AND THIS is SOME more text ' cleaned is "AND THIS IS SOME MORE TEXT" text = ' last one ' cleaned is "LAST ONE" Answer: (penalty regime: 0 %) 1 cleaned = text.upper().strip() Test Expected Got text = ' this is some text ' cleaned is "THIS IS SOME TEXT" cleaned is "THIS IS SOME TEXT" text = ' AND THIS is SOME more cleaned is "AND THIS IS SOME MORE cleaned is "AND THIS IS SOME MORE text ' TEXT" TEXT" text = ' last one ' cleaned is "LAST ONE" cleaned is "LAST ONE" Passed all tests! ▸ Show/hide question author's solution (Python3) Correct Marks for this submission: 1.00/1.00. Question 17 Correct Mark 1.00 out of 1.00 Assume the existence of a String variable data. Print every third character starting from the 4th index (inclusive) to the 40th index (exclusive). For example: Test Result data = 'practice is key to learning to program' tesetlrntpgm data = 'please be sure to attempt the revision quizzes well before your actual quiz' sbseotm eesn data = 'the drop-in center is also available starting from week 2' dpneeiaovlls Answer: (penalty regime: 0 %) 1 print(data[4:40:3]) Test Expected Got data = 'practice is key to learning to program' tesetlrntpgm tesetlrntpgm data = 'please be sure to attempt the revision quizzes well before your sbseotm eesn sbseotm eesn actual quiz' data = 'the drop-in center is also available starting from week 2' dpneeiaovlls dpneeiaovlls Passed all tests! ▸ Show/hide question author's solution (Python3) Correct Marks for this submission: 1.00/1.00. Question 18 Correct Mark 1.00 out of 1.00 Assume the existence of a variable named study_hours. Print "Good" if the number of hours studied is 10 or more, "Okay" if the number of hours studied is between 5 and 10 (exclusive) and ":(" otherwise. For example: Test Result study_hours = 10 Good study_hours = 15 Good study_hours = 7 Okay study_hours = 8 Okay study_hours = 5 Okay study_hours = 4 :( Answer: (penalty regime: 0 %) 1 ▼ if study_hours >= 10: 2 print('Good') 3 ▼ elif study_hours >=5 and study_hours