Python Flashcards
Name the main Pandas features (5)
1) DataFrame object for data manipulation 2) Tools for reading and writing data. 3) time series-functionality 4) Provides data filtration 5) the library is highly optimized for performance with critical part written in cython or c.
What is matplotlib?
Matplotlib is a Python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms.
What is scikit-learn?
Scikit-learn is a free software maching learning library. It features various classification, regression and clustering algorithms.
What is the OS module for?
The OS module in python provides functions for interacting with the operating system. OS, comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality. The *os* and *os.path* modules include many functions to interact with the file system.
What is the sys module ?
The sys module provides functions and variables used to manipulate different parts of the Python runtime environment.
What is the math module?
Some of the most popular mathematical functions are defined in the math module. These include trigonometric functions, representation functions, logarithmic functions, angle conversion functions, etc. π and e are also defined.
What is the statistic module ? What are the function included ?
The statistics module provides functions to mathematical statistics of numeric data. The following popular statistical functions are defined in this module.
>>> import statistics
>>>statistics.mean([2,5,6,9])
5.5
>>>statistics.median([1,2,3,8,9])
3
>>>statistics.mode([2,5,3,2,8,3,9,4,2,5,6])
2
>>>statistics.stdev([1,1.5,2,2.5,3,3.5,4,4.5,5])
1.3693063937629153
What is a module in python?
Any text file with the .py extension containing Python code is basically a module. Different Python objects such as functions, classes, variables, constants, etc., defined in one module can be made available to an interpreter session or another Python script by using the import statement.
A module is described by its attributes. The attributes of a module perform some tasks or contain some information.
What is the random module ?
Functions in the random module depend on a pseudo-random number generator function random(), which generates a random float number between 0.0 and 1.0.
What is a package ?
Physically, a package is actually a folder containing one or more module files.
This is a good tutorial
https://www.tutorialsteacher.com/python/python-package
What are the types of errors in python?
This website contain a good list of more errors in python:
https://www.tutorialsteacher.com/python/error-types-in-python
1) Syntax error: When a certain statement is not in accordance with the prescribed usage.
2) Index error: is thrown when trying to access an item at an invalid index.
3) ModuleNotFoundError: is thrown when a module could not be found
4) KeyError: is thrown when a key is not found
5) ImportError: is thrown when a specified function can not be found
6) StopIteration: is thrown when the next() function goes beyond the iterator items.
7) TypeError: is thrown when an operation or function is applied to an object of an inappropriate type.
8) ValueError: is thrown when a function’s argument is of an inappropriate type
9) NameError: is thrown when an object could not be found.
10) ZeroDivisionError: is thrown when the second operator in the division is zero
Which keyword python use to handle exception ?
statements in try block
Python uses try and except keywords to handle exceptions.
try :
except :
What do we mean by object oriented programming?
Python is a completely object-oriented language. This approach towards programming seeks to treat data and functions as part of a single unit called object. The class defines attributes and the behaviour of the object, while the object, on the other hand, represents the class.
How do we define a class in python ?
Using the keyword class. For example:
class person:
count=0 #class attribute
def __init__(self): #constructor
self. name=”unknown” #instance attribute
self. age=0 #instance attribute
def displayInfo(self): #method
print(self.name, self.age)
What are the components (4) of a class in python?
1) Constructor: The constructor method is invoked automatically whenever a new object of a class is instantiated. The constructor must use __init__()
2) Instance Attributes: Attributes or properties attached to an instance of a class.
3) Class Attributes: An attribute whose value is the same for all instances of a class.
4) Methods: They are the function of the class.