Python Flashcards

1
Q

Name the main Pandas features (5)

A

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.

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

What is matplotlib?

A

Matplotlib is a Python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms.

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

What is scikit-learn?

A

Scikit-learn is a free software maching learning library. It features various classification, regression and clustering algorithms.

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

What is the OS module for?

A

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.

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

What is the sys module ?

A

The sys module provides functions and variables used to manipulate different parts of the Python runtime environment.

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

What is the math module?

A

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.

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

What is the statistic module ? What are the function included ?

A

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

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

What is a module in python?

A

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.

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

What is the random module ?

A

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.

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

What is a package ?

A

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

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

What are the types of errors in python?

A

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

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

Which keyword python use to handle exception ?

A

statements in try block

Python uses try and except keywords to handle exceptions.

try :

except :

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

What do we mean by object oriented programming?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do we define a class in python ?

A

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)

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

What are the components (4) of a class in python?

A

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.

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

What are the 3 type of access modifier?

A

Public: The members of a class which are declared public are easily accessible from any part of the program. All data members and member functions of a class are public by default.

Protected: The members of a class which are declared protected are only accessible to a class derived from it. Data members of a class are declared protected by adding a single underscore ‘_’ symbol before the data member of that class.

Private: The members of a class which are declared private are accessible within the class only, private access modifier is the most secure access modifier. Data members of a class are declared private by adding a double underscore ‘__’ symbol before the data member of that class.

17
Q
A