Operators: Boolean
Operators: Boolean
Operators: Boolean
Operators
Boolean
A Boolean data type represents one of two values: _True_ or _False_. The first letter (T) for True and (F) for False
should be capital.
Operators
Python language supports several types of operators. In this section, we will focus on few of them.
Assignment Operators
Assignment operators are used to assign values to variables. Let us take = as an example. Equal sign in mathematics
shows that two values are equal, however in Python it means we are storing a value in a certain variable and we call
it assignment or a assigning value to a variable. The table below shows the different types of python assignment
operators, taken from [w3school](https://www.w3schools.com/python/python_operators.asp).
Arithmetic Operators:
- Addition(+): a + b
- Subtraction(-): a - b
- Multiplication(*): a * b
- Division(/): a / b
- Modulus(%): a % b
- Floor division(//): a // b
- Exponentiation(**): a ** b
Example: Integers
GitHub Course Summary
Example: Floats
Let's declare a variable and assign a number data type. I am going to use single character variable but remember do
not develop a habit of declaring such types of variables. Variable names should be all the time mnemonic.
Pandas
Pandas is an open-source, high-performance, easy-to-use data structure, and data analysis tool for the Python
programming language.
Pandas add data structures and tools designed to work with table-like data which is *Series* and *Data
Frames*.
- reshaping
- merging
- sorting
- slicing
- aggregation
- imputation.
Installing Pandas
For Mac: For Windows:
pip install conda pip install conda
conda install pandas pip install pandas
Importing Pandas
import pandas as pd
p = [1, 2, 3, 4, 5]
s = pd.Series(p)
print(s)
Numbering
GitHub Course Summary
Data Frames(df)
Pandas data frames can be created in different ways.
Creating a Class
To create a class, we need the key word **class** followed by the name and colon. Class name should be
**CamelCase**.
Syntax
Example
Creating an Object
We can create an object by calling the class.
Class Constructor
In the examples above, we have created an object from the Person class. However, a class without a constructor is
not useful in real applications. Let us use constructor function to make our class more useful. Like the constructor
function in Java or JavaScript, Python has also a built-in init() constructor function. The init constructor
function has self parameter which is a reference to the current instance of the class.
Example
Object Methods
Objects can have methods. The methods are functions which belong to the object.
Inheritance
Using inheritance we can reuse parent class code. Inheritance allows us to define a class that inherits all the methods
and properties from parent class. The parent class or super or base class is the class which gives all the methods and
properties. Child class is the class that inherits from another or parent class.