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)

CMPSC 101 EXAM 1 ACCURATE 100%

Rating
-
Sold
-
Pages
2
Grade
A+
Uploaded on
26-02-2025
Written in
2024/2025

What does the "float" function do? - ANSWERUsing float allows the input to be converted to a decimal when needed for a calculation. If you want to round your value to a certain decimal place when inside the print statement, how would you go about it? - ANSWERprint (f'{x : .2f} {y : .2f} {z : .2f}') this will print the values all rounded to 2 decimal places When you add these two lists together, what are the results? vec1 = [1, 2, 3] vec2 = [0, 1, -1] - ANSWER[1, 2, 3, 0, 1, -1] If you are relating two lists to each other and want to know what value something holds in the other list, what do you do? For example, given a list with months and a separate list with days, how would you find out how many days are in a given month? - ANSWERGiven month_name prompted from the user we can match that with how many days in that month: month_days = days[(month_name)] When searching in a dictionary, what would an example of the code look like? - ANSWERdays_in['Feb'] will return what is on the right side of the colon from Feb.

Show more Read less
Institution
CMPSC 101
Course
CMPSC 101

Content preview

CMPSC 101 EXAM 1 ACCURATE 100%
What does the "float" function do? - ANSWERUsing float allows the input to be
converted to a decimal when needed for a calculation.

If you want to round your value to a certain decimal place when inside the print
statement, how would you go about it? - ANSWERprint (f'{x : .2f} {y : .2f} {z : .2f}')

this will print the values all rounded to 2 decimal places

When you add these two lists together, what are the results?

vec1 = [1, 2, 3]
vec2 = [0, 1, -1] - ANSWER[1, 2, 3, 0, 1, -1]
If you are relating two lists to each other and want to know what value something
holds in the other list, what do you do? For example, given a list with months and a
separate list with days, how would you find out how many days are in a given
month? - ANSWERGiven month_name prompted from the user we can match that
with how many days in that month:
month_days = days[month.index(month_name)]

When searching in a dictionary, what would an example of the code look like? -
ANSWERdays_in['Feb'] will return what is on the right side of the colon from Feb.


What is the difference between a lists, tuples, and dictionaries? - ANSWERA list can
be changed, or is "mutable", and is made with brackets []
A tuple is not able to be changed, or is "immutable", and it made with parenthesis ()
A dictionary allows for easy access to information associated with a search key, and
made up of braces {} and colons :. To the left of the colon is what you search for and
the object on the right is what Python prints.

How do you add something to a list in a specific place? And give an example. -
ANSWERUse the insert method: L.insert(index, value)
Example: If you wanted to add February in the correct place in this list months =
['Jan', 'March', 'April', 'May', etc], you would type months.insert(1, 'Feb')

How do you tack something onto the end of the list? - ANSWERlist.append(value)

What is a problem with dictionaries that we ran into in Recitation? -
ANSWERDictionaries only remember the most resent instance of a value, so if you
have two search keys associated with the same value, for example the number 4,
only the most recent instance will be remembered, as it can only remember one

Which of the following best describes a software engineering process used by most
successful programmers? - ANSWERDesign a solution carefully; document the
design; then code accordingly

Written for

Institution
CMPSC 101
Course
CMPSC 101

Document information

Uploaded on
February 26, 2025
Number of pages
2
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

€14,02
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


Also available in package deal

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.
papersbyjol West Virginia
Follow You need to be logged in order to follow users or courses
Sold
446
Member since
3 year
Number of followers
254
Documents
14151
Last sold
2 weeks ago

3,7

78 reviews

5
29
4
20
3
18
2
2
1
9

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