









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!










◉ How does the OR operator evaluate two operands? Answer: If has a True value, the result is True and is not evaluated (so even if it would produce an error it does not matter). If has a False value, the result of the or is the value of . ◉ How does the AND operator evaluate two operands? Answer: If has a False value, the result is False and is not evaluated (so even if it would produce an error it does not matter). If has a True value, the result of the and is the value of . ◉ How are elements in a list indexed? Answer: List elements are assigned an index number starting with 0. ◉ 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.
◉ If your Python list contains multiple lists, how do you locate a specific value? Answer: By specifying the elements using index positions to first select the sub-list, then the element within the sub-list. For example, the following code would select the value red: favColors= [['jessica','red'], ['grace','yellow'], ['john','blue']] print favColors[0][1] ◉ What does the append operator do to a list? Answer: Mutates a list by adding elements to the end of the list. The following code would print out the list of red, yellow, blue, orange, green, and purple. myColors = ["red","yellow","blue","orange","green"] myColors.append("purple") print myColors ◉ What is an object? 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
◉ What is polymorphism? How does polymorphism apply to working with classes? Answer: Means many forms. It lets us automatically do the correct behavior even if what we're working with could take one of many different forms. The + is a great example. If we're adding two variables together with the plus sign, and these variables are integers, it will numerically add them. But if they are two strings it will concatenate them. With classes this allows us to work with objects created from different classes. ◉ What are the differences in a hashed search and a linear search? Answer: A linear search goes through each entry one at a time to see if the search word matches the word you are looking for. With a large index and lots of queries this will be a very slow process. A hashed search maps those entries to a number, or keyword, and places those into buckets. This way you know which bucket to start looking at for a particular entry instead of looking through all of the entries. 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.
ancestors. Your parents have parents, but those are still your ancestors. Your grandparents had parents, and so on. A very simple definition can execute with multiple layers and a much more complex value. ◉ What three rules must a recursive algorithm obey? Answer: It must have a base case which allows it to eventually end. It must change its state and move towards the base case. It must call itself recursively. ◉ What do we mean when we talk about the cost of an algorithm? Answer: An algorithm's cost is related to the resources that it requires to execute. The primary way cost is discussed is related to the size of the input. Larger inputs usually mean more resources, so this is the main factor that determines the speed. Ultimately this determines the amount of time it takes the algorithm to execute and the amount of memory required to run it. The process of calculating this is called algorithm analysis. ◉ 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
◉ What does a use case diagram provide? What is the purpose of creating a case diagram? Answer: The use case diagram allows you to look more broadly at the requirements of an application by visualizing several use cases and multiple actors at the same time. ◉ What does a class diagram provide? What is the purpose of creating a class diagram? Answer: A class diagram is a visual representation of classes needed. Its most basic structure defines the class name, attributes that it will have, and operations, or methods. This is also where you define inheritance and polymorphism. It allows you to plan out the classes that you will create and their basic structure so that when you translate this to code you know what is needed. ◉ What is a programming library? Why are libraries useful? Answer: A programming library is simply code that is already written, already tested, and ready for you to link to and use. These can greatly reduce the amount of time to write code. ◉ What is a compiled programming language? Answer: You write your source code and then a compiler goes through the code and creates a separate file that contains the machine code. This separate file is an executable file because the computer can directly execute it. All of the code is converted at once and the new compiled file is no longer editable.
◉ What is an interpreted programming language? Answer: An interpreted language does the conversion from source code to machine code on-the-fly. There is no separate machine code file. The computer executes each line when it is needed. This means that all of the code is saved in a format that is editable programming language. ◉ What is the main difference in compiled and interpreted code? Answer: The main difference is when the code is converted to machine language. A compiled language converts all of the code at one time, before the code is run by the machine, and saves this into a new file. That new file is now machine code, and is not editable. An interpreted language still needs to convert to machine language in order for the computer to understand it, but it does this at the time that the code is executed. The original programming language is preserved, so it is editable. ◉ What does it mean if a programming language is object oriented? Answer: An object oriented programming language that is organized around objects or classes, rather than "actions". Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. ◉ Which of these programs is object-oriented:
Answer: cross-platform language, used for desktop applications and android mobile applications ◉ What are each of these programming languages best used for: C Answer: games, utilities, embedded systems, operating systems