100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

ENGR 102 EXAM 2 fully solved & updated

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

1. List 5 good coding practices that have been mentioned in this course. - # 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(()) output to the console? mydict = {'Apple' : 3, 'Pear' : 5, 'Banana' : 2} - # Q2 mydict = {'Apple' : 3, 'Pear' : 5, 'Banana' : 2} mydict['Orange'] = 1 print(()) # prints items as list print(mydict) # **** whats diff ??? **** # cannot do this, a dictionary does not have append or add # d("'Orange' : 1") 3. Explain how dictionaries are different from lists, and how lists are different from tuples. - # 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 - # Q4 # are similar bc both are used to store data and are a collection of items 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. - # Q5 # integers : 9 : immutable # floating-point : 2.9 : immutable # tuples/ strings : "" : immutable # lists/ dictionaries : [] {} : mutable

Show more Read less
Institution
ENGR 102
Course
ENGR 102










Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
ENGR 102
Course
ENGR 102

Document information

Uploaded on
October 22, 2025
Number of pages
18
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

ENGR 102


ENGR 102 EXAM 2 fully solved &
updated 2025-2026
1. List 5 good coding practices that have been mentioned in this course. - # 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} - # 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. - # Q3
# dictionaries are a table of key values while a list
# is an ordered collection of items
# lists are mutable, tuples are not



ENGR 102

,ENGR 102




4. Identify and explain 3 ways strings are similar to lists - # Q4
# are similar bc both are used to store data and are a collection of items


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. - # 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. - # 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? - # 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? - # 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.



ENGR 102

, ENGR 102


# 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.
# 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?
- # 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? - # 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? - #
Q11
# r = read
# w = write


ENGR 102

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Lectsavvy Chamberlain College Of Nursing
View profile
Follow You need to be logged in order to follow users or courses
Sold
90
Member since
2 year
Number of followers
39
Documents
3682
Last sold
1 week ago
Lectsavvy

Unlock academic success with me! I'm Lectsavvy, your go-to expert for top-notch study materials, notes, and exam prep on Stuvia. Browse my uploads for: Accurate and concise notes Exam-focused study guides Past papers and solutions High-quality summaries Let's ace those exams together! Follow me for updates, and feel free to reach out with any questions or requests.

4.0

15 reviews

5
9
4
0
3
4
2
1
1
1

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

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

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right 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 aced it. It really can be that simple.”

Alisha Student

Frequently asked questions