2. Google Colab as our working
environment
https://colab.research.google.com/
3. What is Python?
Python is a high-level, general purpose
programming language. It was created by
Guido van Rossum, and released in 1990.
It was named after a British comedy troupe
Monty Python.
This cool guy is Guido
4. 1.Open source, general-purpose language
2.Highly readable, reusable, easy to maintain
3.English-like syntax
4.Interpreted language
5.Dynamically-typed
6.A large set of libraries and packages
7.Portable
8.Cross-platform
Python features
6. public class Main {
public static void main(String[]
args) {
System.out.println(“Hello
World”);
}
}
#include <stdio.h>
#include <stdlib.h>
int main() {
printf(“Hello world”);
return 0;
}
JAVA C
>>> print(“Hello world!”)
PYTHON
Hello world!
7. A comment is a piece of text within a program that is not
executed. It provides additional information to help us
understand the code.
The # character is used to start a comment and it continues until the end
of line.
Comments
8. Variables
my_variable = 5
The equal sign = is used to assign a value to a variable.
After the initial assignment is made, the value of a variable can be updated
to new values as needed.
Notice: We don't need to tell Python what type of value my_variable is referring to.
A variable is used to store data that will be used by the
program. This data can be a number, a string, a Boolean, a
list or some other data type.
9. Values in Python
-5 # Integer type
23.1 # Float type
“Some words” # String
True # Boolean
10. ● + for addition
● - for subtraction
● * for multiplication
● / for division
● % modulus (returns the remainder)
● ** for exponentiation
● // floor division (or known integer division)
Arithmetic Operators
The primary arithmetic operators are:
13. Strings
Like many other popular programming languages,
strings in Python are arrays of bytes
representing unicode characters.
They are either surrounded by either single quotation
marks or double.
‘Hello’ is the same as “Hello”
Multiple line strings can be surrounded by three
double quotes or three single quotes
16. In Python, lists are ordered collections of items that
allow for easy use of a set of data
List values are placed in between square brackets [ ] ,
separated by commas.
My_list = [1, 12, 7, 3, 3]
Lists
17. Python Lists: Data types
In Python, lists are a versatile data type that can
contain multiple different data types within the same
square brackets. The possible data types within a list
include numbers, strings, other objects, and even other
Lists.
numbers = [1, 2, 3, 4, 10]
names = ['Jenny', 'Sam', 'Alexis']
mixed = ['Jenny', 1, 2]
list_of_lists = [['a', 1], ['b', 2]]
Learn more about lists in the notebook
18. Tuples
Tuples are used to store multiple items in a single
variable.
A tuple is a collection which is ordered and unchangeable.
Tuples are written with round brackets.
My_tuple = (2, 3.5, “Hello”)
19. thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
Dictionaries
Dictionaries are used to store data values in key:value
pairs.
A dictionary is a collection which is ordered, changeable
and do not allow duplicates.
20. Functions
Some tasks need to be performed multiple
times within a program. Rather than rewrite
the same code in multiple places, a function
may be defined using the def keyword.
Function definitions may include parameters,
providing data input to the function.
Functions may return a value using the return
keyword followed by the value to return.
21. Sets
A set is an unordered collection of distinct
of elements.
A set itself may be modified, but the elements
contained in the set must be of immutable
type.Set items are unordered, unchangeable,
and do not allow duplicate values.
position_set = {‘ceo’,’manager’,
‘financier’}
22. Classes
Classes are user-defined blueprint or prototype
from which objects are created
Creating a new class creates a new type of
object, allowing new instances of that type to
be made.
class Student:
def __init__(self,name):
self.name = name
def say_hello(self):
print(“Hello there, my name is”, self.name)
student = Student(“Albin”)
student.say_hello()
23. Methods
Unlike a function, methods are called on an
object. A method can operate on the data(instance
variables) that is contained by the corresponding
class.
User-defined method:
class DevClub:
def method_example(self):
print(“You are the members of Google DSC” )
ref = DevClub()
ref.method_example()
Inbuilt method:
floor_value = math.floor(17.35)
25. ● Calculate statistics and answer questions about the data, like:
■ What's the average, median, max, or min of each column?
■ Does column A correlate with column B?
■ What does the distribution of data in column C look like?
● Clean the data by doing things like removing missing values and filtering
rows or columns by some criteria
● Visualize the data with help from Matplotlib. Plot bars, lines, histograms,
bubbles, and more.
● Store the cleaned, transformed data back into a CSV, other file or
database
What's Pandas for?