• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 160 pages
Exam (elaborations)

Csci 1301 Final Questions With 100% Correct Answers

Document preview thumbnail
Preview 4 out of 160 pages

CSCI 1301 FINAL QUESTIONS WITH 100% CORRECT ANSWERS

Content preview

Complete the code to handle the exception and to generate 'Error Occurred'
new_string = 'Python'
my_index = 0


try:
while my_index != len(new_string) / 2:
print(new_string[my_index:len(new_string)/2])
my_index += 1


XXX
print('Error Occurred')

,A. except (TypeError, IndentationError):
B. except (IndentationError, AttributeError):
C. except (AttributeError, IndentationError):
D. except (NameError, TypeError):


Give this one a try later!


D. except (NameError, TypeError):




What is the output?
new_list = [0, 1, 2, 3, 4]
print(all(new_list))
print(min(new_list) + max(new_list))


A. True
4
B. False
4
C. False
10
D. True
10


Give this one a try later!


A. True
4




Choose the option that gives ['ABC', 'ABC'] as the output.
A. my_list = ['ABC', 'DEF']
my_list[len(my_list)-1] = 'DEF'
print(my_list)

,B. my_list = ['ABC', 'DEF']
my_list[len(my_list)] = 'ABC'
print(my_list)
C. my_list = ['ABC', 'DEF']
my_list[len[my_list)-1] = 'ABC'
print(my_list)
D. my_list = ['DEF', 'ABC']
my_list[len(my_list)-1] = 'ABC'
print(my_list)


Give this one a try later!


C. my_list = ['ABC', 'DEF']
my_list[len[my_list)-1] = 'ABC'
print(my_list)




Python uses _________ constructs to handle errors during execution.
A. control
B. class method
C. exception-handling
D. conditional


Give this one a try later!


C. exception-handling




Which function is most appropriate to improve the given code?
power_consumption_app1 = 600.85
hours_of_use1 = 12.8
energy_per_day1 = (power_consumption_app1 * hours_of_use1) / 1000


power_consumption_app2 = 1800.45
hours_of_use2 = 0.45

, energy_per_day2 = (....)


power_consumption_app3 = 70
hours_of_use3 = 1.5
energy_per_day3 = (...)


total_energy_consumed = energy_per_day1 + energy_per_day2 + energy_per_day3


print(f'The total energy consumed per day is {total_energy_consumed:f}')


A. def print_power_consumed(total_energy_consumed):
print(total_energy_consumed)
B. def input_values(power, hours):
power = float(input())
hours = float(input())
C. def compute_energy_consumed(power, hours):
return (power * hours) / 1000
D. def compute_total(energy_day1, energy_day2, energy_day3):
return energy_per_day1 + energy_per_day2 + energy_per_day3


Give this one a try later!


C. def compute_energy_consumed(power, hours):
return (power * hours) / 1000




Given that my_val is a list of float values, which of the following is an example of a
built-in function?
A. my_val.capitalize()
B. my_val.title()
C. len(my_val)
D. average(my_val)


Give this one a try later!

Document information

Uploaded on
December 5, 2025
Number of pages
160
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$10.50

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

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.
TestITandFixIT
3.7
(13)
Sold
58
Followers
0
Items
7529
Last sold
2 weeks ago




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