Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

ENGR 102 EXAM 2 fully solved & updated (latest version verified for accuracy) | Latest!!

Rating
-
Sold
-
Pages
18
Grade
A+
Uploaded on
20-10-2025
Written in
2025/2026

ENGR 102 EXAM 2 fully solved & updated (latest version verified for accuracy) | Latest!!

Content preview

ENGR 102 EXAM 2 fully solved & updated 2025-2026(latest
version verified for accuracy) | 2024\2025Latest!!
1. List 5 good coding practices that have been mentioned in this course. - Answer: # Q1

# always comment your code

# keep your code simple

# test your code often, work through it in groups

# be consistent with your code

# use good identifying variables

# write as few of lines as possible



2. In the following dictionary, identify the keys and values. Write the command to add the items
'Orange' and 1 to the dictionary. What does the command print(mydict.items()) output to the
console? mydict = {'Apple' : 3, 'Pear' : 5, 'Banana' : 2} - Answer: # Q2

mydict = {'Apple' : 3, 'Pear' : 5, 'Banana' : 2}

mydict['Orange'] = 1

print(mydict.items()) # prints items as list

print(mydict) # **** whats diff ??? ****

# cannot do this, a dictionary does not have append or add

# mydict.append("'Orange' : 1")



3. Explain how dictionaries are different from lists, and how lists are different from tuples. -
Answer: # Q3

# dictionaries are a table of key values while a list

# is an ordered collection of items

# lists are mutable, tuples are not



4. Identify and explain 3 ways strings are similar to lists - Answer: # Q4

# are similar bc both are used to store data and are a collection of items

,ENGR 102 EXAM 2 fully solved & updated 2025-2026(latest
version verified for accuracy) | 2024\2025Latest!!


5. List all of the data types we have seen in this course and provide an example of each. Identify
which ones are mutable and which are immutable. - Answer: # Q5

# integers : 9 : immutable

# floating-point : 2.9 : immutable

# tuples/ strings : "" : immutable

# lists/ dictionaries : [] {} : mutable



6. In your own words, explain the difference between the top-down and bottom-up design
methods. Name at least one advantage and one disadvantage for each. - Answer: # Q6

# Top down programming, in simple terms, is dividing

# and conquering a problem, Bottum-up programming is

# used when you're not sure where to start your code



7. Describe the various components of a hierarchy. How can we use one in program design? -
Answer: # Q7

# A hierarchy is an organized structure where items are

# ranked based on level of importance. As the tree

# descends, the tasks become less important.



8. What type of coding error do you hate the most and why? - Answer: # Q8

# Syntax Errors occur when the program contains invalid code that cannot be understood.

# Indentation Errors occur when the lines of a program are not properly indented.

# Value Errors occur when an invalid value is used - can occur if letters are given to int().

# Name Errors occur when the program tries to use a variable that does not exist.

, ENGR 102 EXAM 2 fully solved & updated 2025-2026(latest
version verified for accuracy) | 2024\2025Latest!!
# Type Errors occur when an operation uses incorrect types - can occur if adding an integer to a
string.



9. When you are trying to fix your code, what are some alternatives to using a debugger? -
Answer: # Q9

# starting with a visual inspection can be helpful

# the try and excpect method aka guess and check

# method is helpful to check blocks of code



10. When would it be best to use the myfile = open(...) / myfile.close() commands for opening
files as opposed to the with open(...) as myfile: command? - Answer: # Q10

### option 1

myfile = open()

x=1

myfile.close()

### option 2

with open() as myfile:

meow = 1



# option 2 is better because it is less lines of code



11. When opening files, what is the difference between the designators r, w, r+, and a? -
Answer: # Q11

# r = read

# w = write

# a = append

Document information

Uploaded on
October 20, 2025
Number of pages
18
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
£19.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
sylvia11

Get to know the seller

Seller avatar
sylvia11 Teachme2-tutor
View profile
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
10 months
Number of followers
0
Documents
125
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions