ONLINE PRACTICAL TEST Year: 2020 Trimester: 2 Subject: ISY1003/ISY104 Foundations of Programming Length of Test: 20 minutes (MCQ test) + 90 minutes (Essay questions + Programming questions) Weight:...

1 answer below »
Hi, I am an Undergraduate student doing foundations of programming. I have an exam tomorrow morning so I need your help if you can do that exam for me. I’ve got samples questions with me and similar questions to that are most likely to come.


ONLINE PRACTICAL TEST Year: 2020 Trimester: 2 Subject: ISY1003/ISY104 Foundations of Programming Length of Test: 20 minutes (MCQ test) + 90 minutes (Essay questions + Programming questions) Weight: 40% Total Marks: 40% Section Question Type Time Limitation Number of Questions Number of Marks per question TOTAL MARKS A MCQ 20 minutes 10 1 10 Marks B Essay questions. 90 minutes 5 2 10 Marks C Writing own code for a given problem. 4 5 20 Marks TOTAL / 40 Online Practical Test contains two parts that will be set up on Moodle: 1. Quiz 1 - MCQ questions - 20 minutes – Tuesday, October 13th, at 8:30 am. 2. Quiz 2 - Essay and programming questions – 90 minutes. Tuesday, October 13th, at 8:50 am You need to attempt quiz on Moodle on time! Keep in mind that quizzes have restriction and a time limitation of 20 + 90 minutes. They will not be reopened after that. If you experience any issue during the quiz, you need to take photos or screenshots as evidence especially if you would like to apply for special considerations. 2 SECTION A 10 Marks Answer all the questions in this section. Each question is worth 1 mark. 1. A byte is made up of eight __________. a. CPUs b. instructions c. variables d. bits 2. In Python, what does the "//" operator do in the expression 6 // 4? a. It performs an exponentiation to the 4th power. b. It returns a remainder or modulus. c. It returns a whole number as a result. d. It returns a float as a result of division. 3. What is the value of the following Python expression: 3**(5//2)%2-1 ? a. 0 b. 1 c. the expression is invalid d. -1 4. Which of the following are valid variable names? a. result! b. weight c. _height d. secondResult e. 2MoreToGo f. second Result 5. What is the output of the following code? a. It doesn’t generate any output. b. 1 2 4 c. 4 d. 1 2 3 4 3 6. Which Boolean value does this Python expression evaluate to? a. True b. False c. None 7. What is the output of the following program? a. GeeksforGeeks b. GFG c. GFG GeeksforGeeks d. Compilation error 8. When is the finally block statements executed? a. When a specific condition is satisfied b. When there is an exception in try block c. When there is no exception in try block d. always 9. Which of the following are true of Python dictionaries? a. All the keys in a dictionary must be of the same type. b. When you want to retrieve a specific value from a dictionary, you use the key that is associated with that value. c. Dictionaries are mutable objects. d. Elements in dictionary are sorted. 10. What’s the output of the code snippet in the figure? a. *walking* b. Woof! c. Arff! d. CanineError: Dog malfunction 4 SECTION B 10 Marks Read what is required from each question carefully and answer all parts of the question. Explain your answer and give an appropriate example. Each question is worth 2 marks. 1. Assume that setA is a set that contains the following elements: 15, 1, 3, 8, 17, and 21. Assume that setB is a set that contains the following elements: 4, 8, 16, 2, 3, and 21. What are the values in the following sets? a. setA ^ setB b. setA – setB c. setA.union(setB) d. setA & setB ANSWER: setA ^ setB = {1, 2, 4, 15, 16, 17} setA – setB = {1, 15, 17} setA.union(setB) {1, 2, 3, 4, 8, 15, 16, 17, 21} setA & setB = {3, 8, 21} 2. Construct truth table for the following Boolean expressions: (A or B) and not B ANSWER A B A or B not B (A or B) and not B True True True False False True False True True True False True True False False False False False True False 3. The Python file, named apple.py contains the following segment of code: 5 a. On line 9, = appears. What does this do? b. On line 4, == appears. What does this do? c. What will line 11 cause the script to print? d. What will line 12 cause the script to print? e. What is the purpose of the function apple? ANSWER: 4. What happens when the programmer forgets to update the loop control variable in a while loop? Explain with example. ANSWER: The loop will be infinite. If a loop does not have a way of stopping, it is called an infinite loop. An infinite loop continues to repeat until the program is interrupted. Infinite loops usually occur when the programmer forgets to write code inside the loop that makes the test condition false. In most circumstances, you should avoid writing infinite loops. The program in the Figure demonstrates an infinite loop. It misses the code that modifies the keep_going variable in the body of the loop. Each time the expression keep_going == 'y' is tested in line 6, keep_going will reference the string 'y'. As a con-sequence, the loop has no way of stopping. (The only way to stop this program is to press Ctrl+C on the keyboard to interrupt it.) 5. What is the difference between floating-point and integer division? Explain with example. 6 ANSWER. 7 SECTION C 20 Marks Each question is worth (5) marks. Read what is required from each question carefully and answer all parts of the question. 1. Construct a program that has a function that receives a list and calculates the sum of the values in that list. 2. Construct a program that has a function which receives a string from the user and creates a dictionary that maps each character in the given string to its frequency, that is, how many times that character appears in the given string. For example, if the given string is "book", the program creates the following dictionary: b : 1 o : 2 k : 1 8 3. Write a code segment that opens a file for input and prints the number of four-letter words in the file. If the file cannot be opened catch the exception and display appropriate message. ANSWER 4. Write a Python class named Circle constructed by a radius and two methods which will compute the area and the perimeter of a circle. ANSWER:
Answered Same DayOct 12, 2021

Answer To: ONLINE PRACTICAL TEST Year: 2020 Trimester: 2 Subject: ISY1003/ISY104 Foundations of Programming...

Sudipta answered on Oct 12 2021
147 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here