Question: CCIT 4 0 2 0 Introduction to Computer Programming - Assignment 3 SECTION B: Code Tracing [ 1 0 marks ] - Write down the

CCIT4020 Introduction to Computer Programming - Assignment 3
SECTION B: Code Tracing [10 marks]
- Write down the output if there are no syntax or runtime errors in the code segment, and put 'NA' in the 'Reason' column.
- Write down the output together with the error type when a logic error is found. Describe the reason in the 'Reason' column.
- Choose the error type from one of the following: [SyntaxError; RuntimeError; LogicError] when an error is found. Describe the reason in the "Reason" column.
Each question carries \(\mathbf{2}\) marks.
\begin{tabular}{|c|c|c|c|}
\hline & Code Segment & Output/Error Type & Reason \\
\hline B-1 & ```
numbers =[1,2,3,4,5,6]
squared ={x:x**2 for x in numbers if x82!=0}
aList =[]
for x in squared.keys():
aList. append (squared [x])
print(set(aList)- set(numbers))
``` & & \\
\hline B-2 & ```
def calculate_ops(set1, set2, set3):
return (set1|set2)-(set1.intersection(set3))
u ={10,6,3)
v ={3,4,15}
w ={2,5,7}
print(calculate_ops(u, v, w))
``` & & \\
\hline B-3 & ```
file1= open('greeting.txt','w')
file1.write("Hello, World!")
file1.close()
file2= open('greeting.txt','r')
content = file1.read()
file2.close()
print(content)
``` & & \\
\hline
\end{tabular}
1
Student Name: [
]
Student ID: [
] Class Code: [
]
CCIT 4 0 2 0 Introduction to Computer Programming

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!