Python+for+Non Programmers

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 64

Best Jobs for Programmers

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Best Jobs?
Cyber-Security
DevOps
Full Stack
Cloud Architect
Machine Learning
Data Scientist

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Applications of Programming Languages

Gaming Banking Machine Learning

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
What is Data?

13.4
My Name is Sam
287

(a+b)2 0 1

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
How to Store Data?

“John”

123

TRUE

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Need of Variables

Data/Values can be stored in temporary storage spaces called variables

Student

“John”

0x1098ab

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Example of Variable

a+b

10 a
a-b

Multiple operations on the variables


20 b a*b

a/b

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Decision Making Statements

If
else
It’s raining:
Go out and Play Football
Sit inside

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Decision Making Statements

If
else
Marks > 70:
Give Practice Test
Get Ice-cream

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
if…else Pseudo Code

If(condition){
Statements to be executed….
}

else{
Statements to be executed….
}

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Looping Statements

Looping statements are used to repeat a task multiple times

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Looping Statements

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Looping Statements

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
While Loop Pseudo Code

while(TRUE){
Keep executing statements….
}

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Functions in Real Life

Eating Running Cycling

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Functions in Programming World

Function is a block of code which performs a specific task

Deposit Function to deposit money

Withdraw Function to withdraw money

Balance Function to check balance

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Object Oriented Programming

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Classes

Class is a template/blue-print for real-world entities

Properties Behavior

• Color • Make Calls


• Cost • Watch Videos
• Battery Life • Play Games

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Objects

Objects are specific instances of a class

Apple Motorola Samsung

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
How do you solve a problem?

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Step by Step Approach

1 Check if you have all the ingredients

2 Take lemon and cut into two halves

3 Squeeze lemon into a glass of water

4 Add sugar and stir it well

5 Serve it cold with ice cubes

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
What is an Algorithm?

Step by step approach to solve a problem is known as algorithm

Input Steps to be followed Output

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Algorithm to find if number is even/odd

Start

Take Number

If number
Even Number Odd Number
% 2 == 0

End

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Introduction to Python

Cross-Platform
Compatible

Free & Open Source Large Standard Library

Object Oriented

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Installing Python

This is the site to install Python -> https://www.python.org/downloads/

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Installing PyCharm

This is the site to install PyCharm -> https://www.jetbrains.com/pycharm/

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Installing Anaconda

This is the site to install Anaconda -> https://www.anaconda.com/

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Intro to Jupyter Notebook

Jupyter Notebook is a browser-based interpreter that allows us to interactively


work with Python

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Variables in Python

“John”

“Sam”

“Matt”

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Variables in Python

Data/Values can be stored in temporary storage spaces called variables

Student

“John”

0x1098ab

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Variables in Python

Data/Values can be stored in temporary storage spaces called variables

“John” “Sam” “Matt”

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
DataTypes in Python

Every variable is associated with a data-type

10, 500 3.14, 15.97 TRUE, FALSE “Sam”, “Matt”

int float Boolean String

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Operators in Python

Arithmetic Operators

Relational Operators Logical Operators

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Python Tokens

Smallest meaningful Component in a Program

Keywords

Identifiers

Literals

Operators

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Data-Structures in Python

Tuple List

Dictionary Set

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Tuple in Python

Tuple is an ordered collection of elements enclosed within ()

tup1=(1,’a’,True)

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Extracting Individual Elements

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Modifying a Tuple

You cannot modify a tuple because it is immutable

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Tuple Basic Operations

Finding Length of Tuple

Concatenating Tuples

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
List in Python

List is an ordered collection of elements enclosed within []

l1=[1,’a’,True]

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Extracting Individual Elements

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
List Basic Operations

Concatenating Lists

Repeating elements

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Dictionary in Python

Dictionary is an unordered collection of key-value pairs enclosed with {}

Fruit={"Apple":10,"Orange":20}

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Extracting Keys and Values

Extracting Keys

Extracting Values

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Modifying a Dictionary

Adding a new element

Changing an existing element

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Set in Python

Set is an unordered and unindexed collection of elements enclosed with {}

s1={1,"a",True}

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Set Operations

Update one dictionary’s elements with another Removing an element

Updating multiple elements

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Set Functions

Union of two sets

Intersection of two sets

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
If Statement

If
else
It’s raining:
Go out and Play Football
Sit inside

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
If Statement

If
else
Marks > 70:
Give Practice Test
Get Ice-cream

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
if…else Pseudo Code

If(condition){
Statements to be executed….
}

else{
Statements to be executed….
}

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Looping Statements

Looping statements are used to repeat a task multiple times

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
While Loop

Syntax:
Enter While loop

while condition:
Test Execute Statements
Expression

Exit While loop


True

Body of While

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
For Loop

For Loop is used to iterate over a sequence(tuple, list, dictionary..)

for val in sequence:


Body of for

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Functions in Real Life

Eating Running Cycling

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Python Functions

Function is a block of code which performs a specific task

Deposit Function to deposit money

Withdraw Function to withdraw money

Balance Function to check balance

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Python Object Oriented Programming

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Classes

Class is a template/blue-print for real-world entities

Properties Behavior

• Color • Make Calls


• Cost • Watch Videos
• Battery Life • Play Games

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Attributes and Methods

color
Attributes
cost

Play Game
Methods
Make Call

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Objects

Objects are specific instances of a class

Apple Motorola Samsung

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Objects in Python

Specific instances of Mobile data type

Apple Motorola Samsung

a = 10 b = 20 c = 30

Specific instances of integer data type

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Creating the first Class

Creating the ‘Phone’ class

Instantiating the ‘p1’ object

Invoking methods through object

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Inheritance in Python

With inheritance one class can derive the properties of another class

Man inheriting
features from his
father

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Libraries in Python

Python library is a collection of functions and methods that allows you to perform many actions without writing your code

NumPy

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited

You might also like