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

CMPSC 101 EXAM 2 QUESTIONS & ANSWERS(RATED A+)

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

Branching - ANSWERdirects a program to execute either one group of statements or another Function - ANSWERPredefined set of code that takes in Input and produces some sort of Output Function Cell - ANSWERfunctionName(argument1, argument2, ...) List - ANSWERA collection of values grouped together Why use lists? - ANSWERWhen you have lots of variables that store related information List examples - ANSWERmyList = [] myList = [1,2,3,4] myList = list('Hello World') How to access values in a list - ANSWERlist[index] List length - ANSWERlists start at index 0 and go up to the list length - 1 Tuples - ANSWERUse () rather than [] Are immutable while lists are mutable Tuple example - ANSWERmyTuple = (1,2) myTuple[0] = 1 Can you change the values in a tuple? - ANSWERNo, it's immutable List of lists - A

Show more Read less
Institution
CMPSC 101
Course
CMPSC 101









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

Written for

Institution
CMPSC 101
Course
CMPSC 101

Document information

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

Subjects

Content preview

CMPSC 101 EXAM 2 QUESTIONS &
ANSWERS(RATED A+)
Branching - ANSWERdirects a program to execute either one group of statements or
another

Function - ANSWERPredefined set of code that takes in Input and produces some
sort of Output

Function Cell - ANSWERfunctionName(argument1, argument2, ...)

List - ANSWERA collection of values grouped together

Why use lists? - ANSWERWhen you have lots of variables that store related
information

List examples - ANSWERmyList = []
myList = [1,2,3,4]
myList = list('Hello World')

How to access values in a list - ANSWERlist[index]

List length - ANSWERlists start at index 0 and go up to the list length - 1

Tuples - ANSWERUse () rather than []
Are immutable while lists are mutable

Tuple example - ANSWERmyTuple = (1,2)
myTuple[0] = 1

Can you change the values in a tuple? - ANSWERNo, it's immutable

List of lists - ANSWER:my2DList = [[1,2,3],[4,5,6],[7,8,9]]

Referencing list of lists - ANSWERmy2DList[0] is [1,2,3]
my2DList[1][2] #would be 6

List1 + List2 - ANSWER[1.2] + [3,4] = [1,2,3,4]

3*List - ANSWER[1,2,1,2,1,2]

len(list) - ANSWERLength of the list

list.append(x) - ANSWERadd x to the end of the list

list.remove(x) - ANSWERremove x from the list

, del list[x] - ANSWERdeletes the value at position x

list.insert(index,value) - ANSWERinserts value at position index

Dictionaries - ANSWERsimilar to lists but have a key tied to every value instead of a
position

Keys - ANSWERanything that is immutable (ints, strings, tuples, etc)

Why use dictionaries? - ANSWERThere are two pieces of information tied together

continue - ANSWERCease executing the current repetition of a loop. If there's
another iteration of the loop, moves on to the next one

unpacking - ANSWERa process that performs multiple assignments at once, binding
comma-separated names on the left to the elements of a sequence on the right

enumerate() - ANSWERretrieves both the index and corresponding element value at
the same time,

nested loop - ANSWERa loop that appears as part of the body of another loop


Dictionary examples - ANSWERmyDictionary = {}
myDictionary = {'M':1, 'i':1, 's':2}

Assignments - ANSWERmyDictionary['a'] = 1
myDictionary['M'] = 1

key in dictionary - ANSWERChecks to see if a key is in the dictionary

loop - ANSWERexecutes the same code over and over again as long as some
condition is True

while loop - ANSWERexecutes a block of code as long as the loop's expression is
True

for loop - ANSWERa statement loops over each element in a container one at a
time, assigning the next element to a variable that can then be used in the loop body

range() - ANSWERgenerates a sequence of numbers, starting at zero and ending
before a value given inside the parentheses

break - ANSWERcauses an immediate exit of the loop

infinite loop - ANSWERa loop that will always execute because the loop's expression
is always True

Boolean - ANSWERTrue or False

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
View profile
Follow You need to be logged in order to follow users or courses
Sold
421
Member since
2 year
Number of followers
253
Documents
13986
Last sold
1 week ago

3.8

72 reviews

5
27
4
18
3
17
2
2
1
8

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