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)

ISE 135 Test 2 | Questions and Answers

Rating
-
Sold
-
Pages
31
Grade
A+
Uploaded on
09-12-2024
Written in
2024/2025

Exam of 31 pages for the course ISE 135 at ISE 135 (ISE 135 Test 2)

Institution
Course

Content preview

ISE 135 Test 2

1. Consider the following code snippet. What will be stored in the list
prices after this code executes?

prices = [10.00, 15.50, 13.50, 20.15]
for i in range(len(prices)) :
prices[i] = prices[i] * 1.06

a. [10.60, 16.43, 14.31, 21.36]
b. [1.06, 1.06, 1.06, 1.06]
c. [10.00, 15.50, 13.50, 20.15]: a. [10.60, 16.43, 14.31, 21.36]
2. Given the following code snippet, what is the value of the variable
indexVal- ue?
states = ["Alaska", "Hawaii", "Florida", "Maine", "Ohio",
"Florida"] indexValue = states.index("Hawaii")

a. 1
b. -1
c. 2
d. 0: a. 1
3. Given the following code snippet, what is the value of the variable
removed- Value?
states = ["Alaska", "Hawaii", "Florida", "Maine", "Ohio", "Florida"]
removed- Value = states.pop(3)

a. Florida
b. Maine
c. 3
d. Hawaii: b. Maine
4. Given the following code snippet, what is the content of the list states?
states = ["Alaska", "Hawaii", "Florida", "Maine", "Ohio", "Florida"]
states.pop()

a. ["Hawaii", "Florida", "Maine", "Ohio", "Florida"]
b. ["Alaska", "Hawaii", "Florida", "Maine", "Ohio"]
c. ["Alaska", "Hawaii", "Florida", "Maine", "Ohio", "Florida"]
d. []: b. ["Alaska", "Hawaii", "Florida", "Maine", "Ohio"]
5. Given the following code snippet, what is
printed? nums = [1, 2, 3, 4, 5] nums2 = [5, 4, 3, 2, 1]
if nums == nums2 :



, ISE 135 Test 2

print("lists are equal")






, ISE 135 Test 2

else :
print("lists are not equal")

a. lists are equallists are not equal
b. an error occurs and nothing is printed
c. lists are equal
d. lists are not equal: d. lists are not equal
6. What is the resulting value of this code

snippet? sum([1, 2, 3, 4, 5])

a. 121
b. 15
c. 16
d. 14: b. 15
7. Which of the following statements looks for the name 'Bob' in the
list names?
Select one:
a.if "Bob" found in names : print("found Bob")
b.if names.indexOf("Bob") >= 0 : print("found Bob")
c.if names contains "Bob" : print("found Bob")
d.if "Bob" in names : print("found Bob"):
d. if "Bob" in names : print("found Bob")
8. Given the following code snippet, which statement correctly creates an
alias for the list prices?
prices = [10.00, 15.50, 13.25, 20.15]

a. values = prices
b. values[10] = prices[10]
c. values[10] = prices
d. for element in prices : values = element: a. values = prices
9. What is the value of the variable indexValue after the following code
snippet runs?
states = ["Alaska", "Hawaii", "Florida", "Maine", "Ohio",
"Florida"] indexValue = states.index("Pennsylvania")

a. -1
b. 6




, ISE 135 Test 2

c. A ValueError exception is raised.
d. 0: c. A ValueError exception is raised
10. What is the value of names after the following code segment has
run? names = [] names.append("Amy") names.append("Bob") names.ap-
pend("Peg")
names[0] = "Cy"
names.insert(0, "Ravi") names.insert(4, "Savannah")

a. ['Ravi', 'Cy', 'Amy', 'Bob', 'Peg', 'Savannah']
b. IndexError: list assignment index out of range
c. ['Ravi', 'Cy', 'Bob', 'Peg', 'Savannah']
d. ['Cy', 'Amy', 'Bob', 'Peg', 'Savannah']: c. ['Ravi', 'Cy', 'Bob', 'Peg',
'Savannah']
11. When reading a file in Python, you must specify two items:

a. a file name and file properties
b. a file name and data type
c. a file name and mode
d. a file name and size: c. a file name and mode
12. Before accessing a file, the program must:

a. open the file
b. name the file
c. read the file
d. close the file: a. open the file
13. After executing the following code snippet, what part is the file
object? infile = open("input.txt", "r")

a. "r"
b. infile
c. "input.txt"
d. input: b. infile
14. In the following code snippet, what does the "r"
represent? infile = open("input.txt", "r")

a. read
b. random
c. recursive
d. replace: a. read

Written for

Course

Document information

Uploaded on
December 9, 2024
Number of pages
31
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$9.49
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
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.
smartchoices Chamberlain College Of Nursing
Follow You need to be logged in order to follow users or courses
Sold
36
Member since
5 year
Number of followers
5
Documents
4499
Last sold
4 weeks ago

4.8

9 reviews

5
7
4
2
3
0
2
0
1
0

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

Working on your references?

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

Working on your references?

Frequently asked questions