
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















◉ What is a compiler? Answer: A program that produces other programs. The compiler does all the work at once and then runs the new program. We're translating the code we wrote to computer code all at once. This is often when we produce an .exe (executable) file. ◉ What is an interpreter? Answer: A program that runs code one line at a time. Instead of converting all of the code at once it runs each line as it's needed. It interprets that specific line from your code to computer code. ◉ What is an operator and what does it do? Answer: An operator takes two operands (values) and does something with them. It is an object capable of manipulating a value. If it is a comparison or logical operator it would compare to see if
they are similar or dissimilar. If it is a mathematical operator it would perform mathematical calculations. ◉ What is an expression? Answer: something that has a value. ◉ What is the difference in a terminal and non-terminal expression? Answer: A terminal is a final value, while a non-terminal can be reduced further. ◉ What is proper Python grammar for making an expression? Answer: Expression → Expression Operator Expression The Expression non-terminal that appears on the left side can be replaced by an Expression, followed by an Operator, followed by another Expression. For example, 1 + 1 is an Expression Operator Expression. ◉ What is a variable? Answer: a name that refers to a value ◉ What are the three main types of data covered? How do you declare each one? Answer: string is a sequence of characters surrounded by quotes, either single or double
Answer: Using the + sign to concatenate the values ◉ What does it mean to index a string? How do you do that with Python code? Answer: This is what we call selecting a sub-sequence of a string. You do this in Python by specifying the character you want to access by its index position. Index position begins at 0. For example, this code would print out the letter J: name = 'John' print name[0] ◉ What does it mean to slice a string? How do you do that with Python code? Answer: Slicing is simply obtaining a subset of data from a string. You may have also heard this called string extraction. You do this in Python by specifying the index position where you want to begin and where you want to end. Everything from the starting point up until the end point will be extracted. For example, this code would print out "Jo": name = 'John' print name[0:2] ◉ + Answer: concatenate or add
Answer: assignment ◉ * Answer: multiply ◉ - Answer: subtract ◉ / Answer: divide ◉ % Answer: Modulos, does division and returns the remainder ◉ What does the * operator do when applied to string data? Answer: It writes out the string data multiple times. For example, print '!' * 12 would output !!!!!!!!!!!! (12 exclamation points). ◉ What does a procedure do?
◉ How do you define outputs for a function? Answer: Using the return keyword you can define what data will be returned or output when the procedure or function runs. You can only access data from within a function if you return that specific data to be used outside of the function. ◉ How is a while loop constructed in Python? What is its purpose? Answer: executes any number of times, continuing as long as the test expression is True while :
◉ How is an if else statement constructed in Python? What is its purpose? Answer: provides a way to control what code executes based on the result of a test expression if :
else:
◉ How are compound mathematical expressions evaluated in Python?
Answer: First perform calculations within parentheses. Next work left to right and perform all multiplication and division. Finally, work left to right and perform all addition and subtraction ◉ What is the function of parentheses, (), in programming expressions? Answer: When we are working with an expression, they group items within that expressions. Items within parentheses are evaluated first. For example: (5 + 3) * 8 = 64 because we do the addition first, then multiplication 5 + 3 * 8 = 29 because we do the multiplication first, then the addition. We also use parentheses in procedures to define the inputs to that procedure, which is a very different idea than when working within an expression.. ◉ < Answer: less than ◉ > Answer: greater than
◉ What is mutation? Do lists support mutation? Answer: This is the ability to change the value of something. Lists support mutation, allowing you to change the overall length as well as individual elements within the list. ◉ How is a for loop constructed in Python? What is its purpose? Answer: A for loop provides a way to execute a block once for each element of a list. The syntax is this: for in :
◉ How do you select a sub-sequence of a list with Python? Answer: You specify the index position to begin the selection and the index position by which to stop the selection. For example, the following code would print red and yellow because they are at position 0 and 1.The value of 2 tells us to stop the selection at position 2, but not to include it. myColors = ["red","yellow","blue","orange","green"] print myColors[0:2] ◉ What does the pop method do to a list in Python?
Answer: By default it removes the last element from a list. It can also be used with an index number to remove a specific element that is not in last place. For example, the following code would print red, yellow, blue, and orange because pop removed green from the end of the list. myColors = ["red","yellow","blue","orange","green"] myColors.pop() print myColors ◉ How would you remove a specific element from a list? Answer: Using the pop method and specifying that specific element's index position. For example, the following code would print red, blue, orange, green because pop removes the color yellow. myColors = ["red","yellow","blue","orange","green"] myColors.pop(1) print myColors ◉ How do you update a list item with Python? Answer: By specifying the element that you want to update and then assigning a new value. For example, the following code would change the second element in list, from yellow to purple.
Answer: Something that has its own identity and characteristics, separate from other objects. ◉ What three things describe an object in object-oriented programming languages? Answer: identity, attributes, and behavior ◉ What is a class? How do you define a class in Python? Answer: A class describes what an object will be, but it isn't the object itself. A class is a blueprint, a detailed description, a definition of an object. The syntax for creating a class in Python is: class ():
◉ Why would we create a class? Answer: To create a blueprint upon which to build multiple objects that share attributes and behaviors ◉ What is the difference in an object and a class? Answer: An object is something that has its own identify and characteristics, separate from other objects. A class describes that object will be, but it isn't the object itself. For example, a house is an
object and the blueprints used to create it would be considered the class. ◉ How do you use dot notation to access an attribute of a class? Answer: You list the individual object's name that is an instance of the class, a dot, and then the attribute name. For example myClass.color would access the color associated with the object myClass. ◉ What is instantiation? Answer: Creating instances of a class ◉ What is abstraction? Answer: Focus on the essential qualities of something rather than one specific example. For example, if I say a table you have an idea of what I mean even though I didn't say if it was wood/glass or big/small. This is the essential idea behind creating classes. ◉ What is encapsulation? Answer: Surrounding something, not just to keep the contents together, but also to protect those contents. Restricts access to the inner workings of a class or any objects based on that class; this is referred to as information hiding or data hiding.
A hashed search is much like looking at the index in the back of a book; if you are looking for "pineapples" you don't have to start at the beginning and read each entry A-P, you can jump to the words that begin with P and start looking there. In this example the letter P would be the bucket that the entry pineapple is placed in. ◉ How are buckets used in a hash table? What effect do they have on lookup speed? Answer: Entries in a hash table are mapped to a number, which is the position in the index where you should look for the entry. A hash table has numbered bucket slots that hold entries. The entries are organized in the buckets based on their assigned keyword number. When you run a search using a hash table the keyword assigned will be used to determine which bucket the entry should be located in and begin the search there. Because the search knows where to begin looking it is much quicker to look up items. ◉ Which storage method covered in this course ensures the fastest access to data? Answer: A hash table, or dictionary ◉ What is an algorithm? Answer: A well-defined sequence of steps (known as a procedure) that will always finish and produce the right results. The algorithm must finish in order for us to analyze efficiency.
◉ What is the difference in a procedure and an algorithm? Answer: A procedure and algorithm are both a set of instructions that will be executed in order. The difference is that an algorithm must return a value. A procedure, or function, that does not return a value may not be considered an algorithm. ◉ What are circular definitions? Answer: A definition that constantly calls itself. Because it lacks a base case it has no way to stop. It is stuck in a loop with a reference pointing to another reference that never resolves. These types of definitions are largely helpful in mathematical application. ◉ What is a recursive definition? Answer: When a function calls itself, it is recursion. If a function is calling itself, it would be stuck in a loop forever unless we have a condition that would allow the recursion to stop. A recursive definition needs to have two parts: the recursive case and the base case. The base case must be something that you already know the answer for and not need to do anything to work it out. This is what allows us to eventually stop running the definition. The recursive case is when the function is calling itself to run again. The recursive case is defined in terms of itself, but in terms of a smaller version of itself, as progress must be made towards the base case. ◉ When would you use recursion?
◉ What are the two most important factors that affect the cost of an algorithm? Answer: Time and memory. Time is the more important factor. ◉ How do you prioritize case (best case, worst case, average case) when analyzing algorithms? Answer: You would look at them in this order: Worst case, average case, best case. The worst case is the most important because this will give you a better understanding of why the time scales as it does. ◉ What is time.clock used for? Answer: To check when an algorithm begins and when it ends so that we can determine the run time. This performs benchmarking, which is simply assessing the relative performance of an object. ◉ What is UML? Answer: Unified Modeling Language. This is a graphical notation specifically for drawing diagrams of an object-oriented system. ◉ What are the 5 steps in the UML design process? In which steps do use case, use case diagrams, and class diagrams take place? Answer: 1.Gather Requirements