Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CPSC 217 Midterm 2 Exam With 100% Correct And Verified Answers 2024, Exams of Advanced Education

CPSC 217 Midterm 2 Exam With 100% Correct And Verified Answers 2024 Nested Loop - Correct Answer-A loop inside the body of another loop. Infinite loop - Correct Answer-When the loop condition is always satisfied --> Loop never ends Functions - Correct Answer-Block of code that accomplishes a single purpose, such asa calculating an average from a list of values, or printing a message to code Parameters - Correct Answer-Acts like a variable and holds the value we give tot he function when we call it Arguments - Correct Answer-inputs that a function takes in Functions overview - Correct Answer-1. Facilitate code reuse 2. Reduce code complexity 3. Easy maintenance Scope of Variables - Correct Answer-Are memory locations that are used for the temporary storage of data

Typology: Exams

2023/2024

Available from 08/30/2024

Qualityexam
Qualityexam 🇰🇪

2.5

(4)

2.7K documents

1 / 3

Toggle sidebar

Related documents


Partial preview of the text

Download CPSC 217 Midterm 2 Exam With 100% Correct And Verified Answers 2024 and more Exams Advanced Education in PDF only on Docsity!

CPSC 217 Midterm 2 Exam With 100%

Correct And Verified Answers 2024

Nested Loop - Correct Answer-A loop inside the body of another loop. Infinite loop - Correct Answer-When the loop condition is always satisfied --> Loop never ends Functions - Correct Answer-Block of code that accomplishes a single purpose, such asa calculating an average from a list of values, or printing a message to code Parameters - Correct Answer-Acts like a variable and holds the value we give tot he function when we call it Arguments - Correct Answer-inputs that a function takes in Functions overview - Correct Answer-1. Facilitate code reuse

  1. Reduce code complexity
  2. Easy maintenance Scope of Variables - Correct Answer-Are memory locations that are used for the temporary storage of data Local Variables - Correct Answer-- Only accessible to the function where they are defined
  • Memory is only allocated when the function is running and deallocated when the function reaches the end Local scope variable - Correct Answer-Variables that are declared within the body of a function Global scope variable - Correct Answer-Variables that are declared outside the body of a function Global Variables - Correct Answer-Variables declared in the main body of the program and so can be accessed anywhere in the code Global variable lifetime - Correct Answer-Exists until the program terminates Local variable lifetime - Correct Answer-Exists until the function containing it finishes List - Correct Answer-- Collection of values Element - Correct Answer-- Items in a list
  • Each one has an index Index - Correct Answer-Unique integer identifying it position in the list Slicing a List - Correct Answer-Can produce copies and sub-lists of a list using the range of indices (:) indices - Correct Answer-plural of index Modifying Elements - Correct Answer-Lists are mutable, so their elements can be changed Mutable - Correct Answer-open to or capable of change Inster (i, x) - Correct Answer-Inserts a single element into a list at index i Extend (L) - Correct Answer-Extends the list by appending the given list to it Indexing - Correct Answer-Access a list element Membership - Correct Answer-Query whether or not an item is in the list Length - Correct Answer-Get the number of items in a list Append - Correct Answer-Add an item to the end of the list Insert - Correct Answer-Insert an item at certain position Sort - Correct Answer-Sort the list Reverse - Correct Answer-Reverse the items in the list Count - Correct Answer-Count the number of occurrences of an item Searching For Elements - Correct Answer-Use in to check if an item is present in a list Removing Elements - Correct Answer-Use the remove method
    • Removes the first occurrence of the item
    • Subsequent identical items remain in the list
    • Item must exist or a ValueError will occur Two dimensional (2D) Lists - Correct Answer-- A list of lists (Images, movies, tables, matrices -> all 2D data) Sorting - Correct Answer-The process of ordering elements of a list in ascending or descending order

Strings - Correct Answer-- Class (type) of objects that is represented as a sequence of characters in member

  • Immutable. Meaning, their values cannot chance after is has been created String Concatenation - Correct Answer-- Combine two or more strings together
  • print ('John' + 'Smith') = John Smith
  • Cannot combine a string with an integer Method - Correct Answer-A function that is associated with a specific object/class Slice operator - Correct Answer-- [n:m] returns the part of the string from the n'th character to the m'th character
  • Including the first but excluding the last
  • default values are o and length - 1 split() - Correct Answer-- Function takes a string argument (delimiter) returns a list of words of the original string split on this delimiter