112 Final Study Guide Chapters 8-13 Flashcards

1
Q

What are the four collection data types in python?

A

List (ordered and mutable)

Tuple (unordered and immutable)

Dictonary (stores key:value pairs)

Set (unordered and unindexed)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do tuples function?

A

Tuples store multiple values.

They are made up of multiple ordered and indexed elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do tuples differ from lists?

A

Tuples are immutable (elements are unchangeable)

They are more secure than lists, and are used in situations where security matters.

Tuples also process faster than lists, making them suitable for larger chunks of data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How are tuples created?

A

Tuples are created using parentheses, or by seperating values with commas.

You can create empty tuples with an empty pair of parentheses

tuple_1 = (1, 2, 3, 4, 5)

tuple_2 = 1., .5, .25, .125

tuple_3 = ()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What do you need to include when creating a single element tuple?

A

If you are creating a single element tuple, you must include a comma with the element.

tuple = (1,)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Name some functions, operators, and methods 1you can use on tuples.

A

len(), max(), min(), sum() functions can all be used on tuples.

+, *, in and not in operators can be used on tuples.

count() and index() methods can be used on tuples.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do dictionaries work?

A

Dictionaries store data values in key:value pairs.

The word to you look for is called a key

The word you get back from the dictionary is a value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you create dictionaries?

A

You write dictonaries using curly brackets {}.

key:value pairs are written side by side, each key and value surrounded with quotation marks, and seperated by colons.

dict1 = {“cat” : “aaaaaa”, “dog” : “AAAAAA”, “fish” : “ooooooo”}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are some rules you must follow when creating keys and values?

A

Keys must be uniquie, but may be a number or a string.

Keys are case sensitive.

Values can be any data type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How is the dict() function used?

A

The dict() function can be used instead of braces to create a dictionary.

x = dict()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How is the items() method used on dictionaries?

A

You can use the items() method to loop through dictionaries.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Name some methods used on dictionaries.

A

items () loops through dictionary

update() can add / edit keys and values in a dictionary

keys() get all keys from a dictionary

values() get all values from a dictionary

len(), in and not in can all be used on dictionaries as well.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are sets?

A

Sets are an uordered and unindexed collection. Sets contain no duplicate elements, and are written with curly brackets {}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What functions or operations can be used on sets?

A

len() in, not in are all used on sets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How can the del keyword be used?

A

The del keyword can be used to delete elements from collection data types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How is the copy () method used?

A

The copy() method creates copies of collection data types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What are the data type conversion functions?

A
  • int() - converts string, floating point to integer
  • float() - converts string, integer to floating point number
  • str() - converts integer, float, list, tuple, dict into string
  • list() - converts data types into a list
  • tuple () - converts data types into a tuple
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What are functions?

A

Functions are blocks of organized, reusable code that together performs a specific task.

Functions only run when called.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Why are functions needed?

A

Reusability

Functions allow you to define the code a single time, and reuse it as many times as the code needs.

Modularity

Functions allow you to break up long strings of code into smaller steps, allowing you code to be easy to read and maintain.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What 3 groups are functions called from?

A

Built in Python functions

Functinos imported from modules.

User-defined functions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How are functions created?

A

Functions are freated b defining and adding parameters.

def is always put before the function name

The name is followed by a pair of empty brackets () and then a colon :

After this, the body of the function is added on the next line.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

When do functions run?

A

Functions only run when they are called.

Functions are called by writing the name of the function into the code.

def message(): # message is the function name

print(“Enter a value: “) #function body

message()

a = int(input())

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Define function parameters and arguments.

A

Paramaters are the variables listed inside the parentheses next to the function name when defining a function.

Arguments are the values sent to the function when it’s called.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What are the two methods of passing arguments to functions?

A

Positional argument passing- this commonly used way of passing arguments follows the positions of the paramaterrs and arguments and passes them based on their positions.

Keyword (named) argument passing. The more flexable way of passing arguments. Arguments are passed based on their names.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What are arbitrary arguments?

A

Arbitrary arguments occur when the number of arguments sent to a function are variable.

Also known as variable length arguments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Define returning values through functions.

A

Many functions can have results and return values. You can achieve this using the return keyword either

With an expression causing immediate termination of the functions execution.

Without an expression which immediately terminates the functions execution and returns to the point of invocation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

What are Called and Calling functions?

A

Called functions are functions which are called from other functions.

The function that calls the called function is called the Calling function.

im sorry guys this shit is so hard to read im trying to make something legible

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

Define scopes and their role with functions.

A

The scope of a name is the part of a code where the name is available / recognizable.

the scope of a function’s parameters and the functions variables is the function itself. They are local to the function (inaccessible from outside the function)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What are global variables?

A

Global variables exist outside of functions, but have a scope inside of a function’s body. This means that the function can use the global variable, but if the same variable name is re-assigned INSIDE the function, they become two different variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

How does the global keyword function?

A

The global keyword is used inside a function to change the value of a variable created outside the function.

This will skip creating a local variable, and will use the global variable instead. If the global variable doesnt exist, it will be created.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

What is a recursive function?

A

A recursive function calls upon itself. This technique is called recursion.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

How do you prevent infinite recursion?

A

If you do not provide a condition, recursion will condinue indefinitely.

if-else statements can be used to prevent this, where one branch makes the recursive call and the other branch doesn’t.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

What are the advantages and disadvantages of recursion?

A

Advantages:

It makes the code shorter and cleaner

It is required in problems with data structures and advanced algorithms.

Disadvantages

It uses more memory, and processor time compared to iteration.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

What is the maximum filename length on Windows and Linux?

A

Windows, 256 characters

Linux, 255 Characters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

Name some text file types in Python.

A
  • Web standards
  • Source code
  • Documents
  • Tabular data
  • Config files
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

Name some binary file types in python.

A
  • Document files
  • Image files
  • Video files
  • Audio files
  • Database files
  • Archive files
  • Executable files
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

What are file paths?

A

A file path is the description of where the file can be found in in the folder structure, and how to access it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

Which slash direction is used for Windows? Which for linux?

A

For windows the back slash is used

For Linux the forward slash is used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

What basic file operations can be done in Python?

A

Basic File operations include:

  • Open
  • Close
  • Read
  • Write
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

What mode paramaters are used for opening files?

A
  • r - open a file for reading only (the default open setting)
  • w - open for writing, truncating the file first
  • x - open file for exclusively for creation, fails if the file already exists.
  • b - opens in binary mode
  • t - opens in text mode (default mode)
        • open for updating (both reading and writing)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

Name some combined access modes.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

What methods are used for reading a file’s contents?

A

read () and readline() are both used.

By default read() returns the entire text of the file, however you can specify how many characters the method will return.

readline() returns the file contents line by line.

readlines() returns a list of each line in the file as a list item.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

How does looping through read files work?

A

If you loop through the lines of a file, you can read the entire file line by line.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

How can the open() method create a new file?

A

The open() method creates files using one of 3 parameters:

“w” - Opens a new file for writing, Overwrites a file with the same name if it exists.

“a” - opens a file for appending, if the file doesn’t exist it will create a new file.

“x” - open a file for exclusive creation, returns an error if the file already exists.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

How can you add to a newly created file?

A

Using the write() and writelines() methods, we can add text to a newly created file.

write () will add text to a file

writelines() will add a list into a file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

How does the with statement interact with files?

A

The with statement automatically closes the file after a block of code has been resolved.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

list of file methods

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

What are modules?

A

A module is a file containing Python definitions of functions, variables, and classes.

The file name for modules have the suffix .py

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

How are modules used?

A

Modules break down larger programs into small manageable and organized files.

Modules provide reusability of code, and a large number of modules exist and can be used in new code.

50
Q

What are 3 sources of modules?

A

Sources of modules include:

  • Standard modules, they are built into Python when accessed for the first time
  • User-Defined Modules are created by users.
    • PyPi is a database where you and others can upload and share their own modules. An installer (pip for example) can be used to download and install these modules.
      *
51
Q

What document contains information about standard modules?

A

The Python Library reference, also known as the standard library is an extensive list, offering a wide range of modules.

These include, mathematical modules, OSs, data types, networking, GUI, multimedia, runtime, language options, markup, ect.

52
Q

How do you import modules?

A

You use the import statement.

Import is a python keyword letting you import your modules into a Python script.

53
Q

How is the from keyword used on Modules?

A

The from keyword is used to point out specific entities in a module and import them.

54
Q

How do you import all entities inside a module?

A

If you put * at the end of your import statement, all entities will be imported.

Example:

from math import *

55
Q

How is the dir() function used on modules?

A

dir() used on a module will list all functions and other entities inside a module.

Must be used after a module has already been imported.

56
Q

What are the functions of the math module?

A

The math module includes:

Trigonometric functions

Power and logarithmic functions

Constants

And more

57
Q

What is the random module used for?

A

The ranod module generates pseudorandom numbers.

It takes a seed and treates it as an input value, then calculates the random number using a chosen algorithm.

58
Q

What does the os module do?

A

The OS module allows you to perform operating system taasks through python.

59
Q

What is the platform module used for?

A

The platform module retreives information about the platform the program is currently being executed on.

60
Q

What is the datetime module used for?

A

The datetime module works with dates and times.

61
Q

What is the tutle module used for?

A

The tutle module is an educational framework for simple graphics applications.

62
Q

How are modules created?

A

Write a code and save it as a file with a .py extention.

Write a program to import the module and call upon the functions inside of the file.

63
Q

What can be contained inside a user generated module?

A

Functions, and any type of variable.

64
Q

What are packages?

A

Packages are collections of modules. They are groups of modules all put in the same directory, allowing for hierarchical structuring of the module.

65
Q

What is required to be inside of a directory in order for Python to recognize it as a package?

A

A special file known asthe __init__.py file. Can be left empty but this is generally where the initialization code for the package is in the file.

66
Q

What is PyPi?

A

PyPi (Python Package Index) is a repository of packages from python.

PyPI helps you find and install packages that have been developed by the Python community.

67
Q

What does OOP stand for?

A

Object Oriented Programming.

68
Q

Define Object Oriented Programming

A

OOP is a programming paradigm based on the concept of “Objects” which may contain both data, commonly referred to as attributes, and code, commonly referred to as procedures or methods.

69
Q

Define Procedural Programming.

A

Procedural Programming is a programming paradigm based on the concept of procedures. A procedure is a sequence of instructions. Procedural Programming treats data and procedures as two differe entities.

70
Q

Name some common Procedural Programming languages.

A

C, Fortran, Pascal. COBOL, ALGOL

71
Q

Name some common OOP languages.

A

Most modern languages are OOP and support procedural programming.

C++, C#, JAVA, Python, PHP, RUBY

72
Q

What makes OOP stand out?

A

OOP languages are more flexible, modular, structural, and reusable.

73
Q

What language is Python?

A

Python supports both Procedural and OOP, but it is an OOP language.

74
Q

How does OOP use classes and objects?

A

Software objects are used to to represent real world objects inside of a code.

Classes are a type of object, and they provide a means of bundling data and functionality together.

Creating new classes creates a new type of object.

75
Q

What are some features of classes?

A

A class can have attributes / properties as well as the abilities to perform specific activities.

Objects are instances of classes.

They are created from a class in a process called instantiation.

76
Q

How do you define classes in Python?

A

You define classes using the class keyword.

Normally the function definition would be inside the class.

77
Q

How do you create a class instance (object)

A

Creating an object uses a notation similar to creating a function.

To creat a new instance of a class, assign it to a variable.

x = ClassName()

78
Q

What is the first parameter of each method in a class?

A

self is always the first parameter of class methods.

79
Q

How does self function when creating class methods?

A

self is different from normal functions and it represents the instance of the class.

In other words, self points out the current object.

Using self allows you to access the attributes and methods for the specific current object.

You do NOT have to include self when calling the method, becuase Python will add it for you.

80
Q

What is the constructor method used in classes?

A

__init__ is known as the constructor or the init method.

81
Q

What is the __init__ method used for?

A

The method is called automatically to initialize the media attributes during class instantation.

__init__ is obliged to have the self parameter.

Could have more parameters than just self but doesn’t need them.

Can’t return a value.

82
Q

What are the two types of variables in class definitions?

A

Class Variables and Instance Variables.

Instance Variables are for data unique to each instance.

Class variables are for attributes and methods shared by all instances of the class.

83
Q

What are docstrings?

A

docstrings are string literals enclosed using triple quote signs. They explain the purpose of the class definition.

To display docstring contents, use the __doc__ attribute.

Functions, Modules and Classes all can have docstrings.

84
Q

What are the 4 features / characteristics of OOP?

Hint: A-PIE

A

Abstraction

Polymorphism (If kevin asks for only 3 for whatever reason leave this one out)

Inheritance

Encapsulation

85
Q

Define OOP Encapsulation

A

A class encapsulates data attributes and methods that operate the data together.

86
Q

Define OOP Inheritance.

A

In OOP, you have the ability to creat new classes from existing ones (Parent classes, Child classes)

Allows you the opportunity to reuse the functionality of your code and implement your code faster.

Very important.

87
Q

Define OOP Abstraction.

A

An object oriented program can use abstract classes. Abstract classes are classes that contain one or more abstract methods.

Abstract methods are methods that are declared but contain no implementation.

The implementation of abstract methods are in the derived classes.

88
Q

Define OOP Polymorphism.

A

Polymorphism in OOP menas the same function / method / name can be used for many different purposes.

89
Q

How does inheritence work in OOP?

A

Inheritance defines a class that inherits methods and data attributres from other another existing class.

Inheritance produces two classes. The base class, which is the class the new class is being derived from

The derived class is the class inheriting from the base class.

90
Q

Define derived class functions.

A

Derived classes can add their own data attributes and methods.

They are also allowed to override base class methods.

91
Q

Define multiple inheritance.

A

Multiple inheritance occurs when a derived class has two or more base classes.

Example

The minivan class is derived from the car class, and the truck class.

92
Q

What is the difference between exceptions and syntax errors?

A

A syntax error occurs when there is something wrong with the syntax. The interpreter doesn’t understand the code that has been fed to it, and stops the code from running.

Exceptions are erros that may occur even though the code is syntactically correct. Every time your code does something weird, it will raise an exception.

93
Q

What happens after an exception has been raised?

A

THe raised exception expects to be noticed and processed.

If the exception is not noticed or processed, the code will terminate and an error message will display.

If the exception is handled properly, the program can finish execution.

94
Q

What are import errors?

A

ImportErros are raised when an imported module is not found.

95
Q

What are IndexErrors?

A

IndexErros are exceptions raised when the index of a sequence is out of range.

96
Q

What are KeyErrors?

A

KeyErrors are exceptions raised when a key is missing from a dictionary.

97
Q

What are KeyboardInterrupt errors?

A

KeyboardInterrupt exceptions are raised when the user hits the interrupt key stroke.

98
Q

What are MemoryErrors?

A

MemoryErrors are exceptions raised when a poeration runs out of memory.

99
Q

What are NameErrors?

A

NameErrors are exceptions raised when a variable is not found in local or global scope.

100
Q

What are OSErrors?

A

OSError is an exception raised when system operation causes a system related error.

101
Q

What are OverflowErrors?

A

OverflowError is an exception raised when the result of an arithmetic operation is too large to be represented.

102
Q

What are ReferenceErrors?

A

ReferenceErrors are exceptions raised when a weak reference proxy is used to access a garbage collected referent

103
Q

What are RuntimeErrors?

A

RuntimeErrors are exceptions raised when an error does not fall under any other category.

104
Q

What are SystemErrors?

A

SystemErrors are exceptions raised when the interpreter detects internal error.

105
Q

What are IndentationErrors.

A

IndentationErrors are raised when there is incorrect indentation in your code.

106
Q

What are ValueErrors?

A

ValueErrors are exceptions raised when a function gets an argument of correct type, but incorrect value.

107
Q

What are ZeroDivisionErrors?

A

ZeroDivisionErrors are exceptions raised when the second operand of division or modulo operation is zero.

108
Q

How do Python progrmas handle exceptions?

A

When exceptions are raised, try and except statements are used to try and solve the issue.

If you have sussy code that may raise an exception, you can defend your program by using a try block.

After the try block, include an except statement followed by a block of code which is written to handle the problem properly.

109
Q

What is the function of the finally statement?

A

A finally statement can be used with a try statement block.

The finally statement will be executed no matter if the try bock raises an error or not.

This can be useful to close objects and clean up resources.

110
Q

What are user defined exceptions?

A

User defined exceptions are exception classes created and named by the program.

Typically derived from the Exception class.

raise statements are used to force a specified exception to occur.

111
Q

What is SDLC?

A

SDLC stands for Software Development Life Cycle.

Its a process used in the industry for developing software.

112
Q

What are the phases of software development?

A

Planning

Requirements Analysis

Design

Implementation

Testing

Deployment

Maintenance

113
Q

What is the Waterfall SDLC model?

A

The waterfall model is named after an SDLC method which performs tasks sequentially.

114
Q

What is the V SDLC model?

A

The V model is an improvement on the waterfall model.

Testing is involved at every stage.

115
Q

What is Agile Software Development?

A

Agile software development is centered around the idea of iterative development

Requirements and solutions evolve through collaboration between self-organizing teams.

116
Q

What is the Scrum methodology?

A

Scrum is a project managment and development methodology that relies in incremental development.

Daily Scrum is a short stand up meeting even for Scrum team developers.

117
Q

What are some Agile methodologies?

A

Scrum

XP

Kanban

Lean

Crystal

118
Q

How long does a scrum sprint usually last?

A

A sprint usually lasts 2 to 4 weeks.

119
Q

Name the Roles in Scrum.

A

Product Owner

Dev Team

Scrum Master

120
Q
A