You are on page 1of 64

Python

2021-2022
What is Python?

Python is a popular programming language. It was created by Guido van Rossum, and released
in 1991.

It is used for:

•web development (server-side).

•software development.

•Mathematics.

•system scripting.

BEST FOR You 2


O R G A N I C S C O M P A N Y
What can Python do?

•Python can be used on a server to create web applications.

•Python can be used alongside software to create workflows.

•Python can connect to database systems. It can also read and modify files.

•Python can be used to handle big data and perform complex mathematics.

•Python can be used for rapid prototyping, or for production-ready software development.

BEST FOR You 3


O R G A N I C S C O M P A N Y
Why Python?

•Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).

•Python has a simple syntax similar to the English language.

•Python has syntax that allows developers to write programs with fewer lines than some other
programming languages.

•Python runs on an interpreter system, meaning that code can be executed as soon as it is
written. This means that prototyping can be very quick.

•Python can be treated in a procedural way, an object-oriented way or a functional way.

BEST FOR You 4


O R G A N I C S C O M P A N Y
Object-Oriented Programming Language

It is an object-oriented programming language which means it works on objects. So what is an object? For example, Tiger is
an object whose color and age are its attributes, and hunting and reproducing its behavior. So, as shown in the above
example, an object has two characteristics: attributes and behavior.
So, there are some basic principles of OOPs as given below:

•Inheritance: In this case, a child class can use the parent class’s behavior and attributes.

•Encapsulation: Hiding the private details of a class from other objects.

•Polymorphism: Using a common behavior/operation in different forms for different inputs.

BEST FOR You 5


O R G A N I C S C O M P A N Y
Python Syntax compared to other programming languages

•Python was designed for readability, and has some similarities to the English language with
influence from mathematics.

•Python uses new lines to complete a command, as opposed to other programming languages
which often use semicolons or parentheses.

•Python relies on indentation, using whitespace, to define scope; such as the scope of loops,
functions and classes. Other programming languages often use curly-brackets for this
purpose.

BEST FOR You 6


O R G A N I C S C O M P A N Y
Top Python Companies

BEST FOR You 7


O R G A N I C S C O M P A N Y
Objectives

• Numbers
• String basic
• String methods
• Lists
• Tuples
• Dictionaires
• Datatype casting
• If statements
• Functions
• Loops
• Methods
• Library

BEST FOR You 8


O R G A N I C S C O M P A N Y
Downloads

BEST FOR You 9


O R G A N I C S C O M P A N Y
Downloads

BEST FOR You 10


O R G A N I C S C O M P A N Y
Install

BEST FOR You 11


O R G A N I C S C O M P A N Y
Install

BEST FOR You 12


O R G A N I C S C O M P A N Y
Install

BEST FOR You 13


O R G A N I C S C O M P A N Y
Install

BEST FOR You 14


O R G A N I C S C O M P A N Y
Install

BEST FOR You 15


O R G A N I C S C O M P A N Y
What is IDE?

Whether you are an experienced player in the software development game or just a beginner, you need a quality
integrated development environment (IDE) as a workspace for your codes.
IDE itself is software, consisting of development tools used to develop software and test it. It provides a development
environment where all the tools are available in a single user-friendly Graphical User Interface (GUI).
An IDE mainly includes:
•Code editor to write software codes
•Local construction automation
•Debugger for programs
Apart from these, different IDEs have different features which together help developers in their development stages.

Code editors provide a platform where developers can write and modify codes, but they lack build and test
capabilities.
You can perform many other functions using an IDE such as running and executing your codes, compiling, interpreting,
debugging, version checks, file management and many more.

BEST FOR You 16


O R G A N I C S C O M P A N Y
Python IDE

• PyCharm
• Kdevelop
• SlickEdit
• Thonny
• Visual Studio
• Atom
• LiClipse
• Wing
• Google colab
• jupyter

BEST FOR You 17


O R G A N I C S C O M P A N Y
Command print

BEST FOR You 18


O R G A N I C S C O M P A N Y
Exercice

BEST FOR You 19


O R G A N I C S C O M P A N Y
Python Comments

• Python has commenting capability for the purpose of in_code documentation.


• Comments start with #, and Python will render the resr of the line as a comment.
• Comments can be used to explain Python code.
• Comments can be usded to make the code more readable.
• Comments can be used to prevent execution when testing code.

BEST FOR You 20


O R G A N I C S C O M P A N Y
Multi Line Comments

BEST FOR You 21


O R G A N I C S C O M P A N Y
Example

BEST FOR You 22


O R G A N I C S C O M P A N Y
Exercice comment

BEST FOR You 23


O R G A N I C S C O M P A N Y
Exercice comment

BEST FOR You 24


O R G A N I C S C O M P A N Y
Variables

In Python, variables are created when you assign a value to it:

BEST FOR You 25


O R G A N I C S C O M P A N Y
Variables

BEST FOR You 26


O R G A N I C S C O M P A N Y
Variables

BEST FOR You 27


O R G A N I C S C O M P A N Y
Variable Names

Variable name can only contain these characters:


• LowerCase letters (a through z)
• UpperCase letters (A through Z)
• Digits (0 through 9)
• Underscore(_)
Names Cannot begin with a digit. Also, Python treats names that begin with an underscore.
These are valid names:
• a
• a1
• a_b_c__95
• _abc
• _1a
Theses names, however, are not valid:
• 1
• 1a
• 1_
BEST FOR You 28
O R G A N I C S C O M P A N Y
Variable Names

BEST FOR You 29


O R G A N I C S C O M P A N Y
Multi Words Variable Names

Variable names with more than one word can be difficult to read.there are several techniques you can use to make them
more readable:

BEST FOR You 30


O R G A N I C S C O M P A N Y
Multi Words Variable Names

BEST FOR You 31


O R G A N I C S C O M P A N Y
Python Variables – Assign Multiple Values

❑ Many Values to Multiple Variables: Python allows you to assign values to multiple variables in one line

❑ One Value to Multiple Variables: you can assign the same value to multiple variables in one line.

BEST FOR You 32


O R G A N I C S C O M P A N Y
Python Variables – Assign Multiple Values

❑ Unpack a Collection: if you have a collection of values in a list, tuple etc. Python allows you to extract the values into
variables. This is called unpacking.

BEST FOR You 33


O R G A N I C S C O M P A N Y
Single or Double Quotes

String variables can be declared either by using single or double quotes:

BEST FOR You 34


O R G A N I C S C O M P A N Y
Exercice

BEST FOR You 35


O R G A N I C S C O M P A N Y
Exercice

BEST FOR You 36


O R G A N I C S C O M P A N Y
Exercice

BEST FOR You 37


O R G A N I C S C O M P A N Y
Exercice

BEST FOR You 38


O R G A N I C S C O M P A N Y
Exercice

BEST FOR You 39


O R G A N I C S C O M P A N Y
Exercice

BEST FOR You 40


O R G A N I C S C O M P A N Y
Exercice

BEST FOR You 41


O R G A N I C S C O M P A N Y
Exercice

BEST FOR You 42


O R G A N I C S C O M P A N Y
Types Variables

In Python, everythings booleans, integers, floats, strings, even large data structures functions and programs
is implemented as an object.

Boolean

Integers
Python

Floats

Strings
BEST FOR You 43
O R G A N I C S C O M P A N Y
Built-in Data Types

BEST FOR You 44


O R G A N I C S C O M P A N Y
Setting the Data Type

BEST FOR You 45


O R G A N I C S C O M P A N Y
Setting the Specific Data Type

BEST FOR You 46


O R G A N I C S C O M P A N Y
Getting the Data Type

BEST FOR You 47


O R G A N I C S C O M P A N Y
Getting the Data Type

BEST FOR You 48


O R G A N I C S C O M P A N Y
Python Casting

BEST FOR You 49


O R G A N I C S C O M P A N Y
Example

BEST FOR You 50


O R G A N I C S C O M P A N Y
Casting

If you want to specify the data type of a variable, this can be done with casting.

BEST FOR You 51


O R G A N I C S C O M P A N Y
Types Conversion

BEST FOR You 52


O R G A N I C S C O M P A N Y
Case Sensitive

Variable names are case-sensitive.

BEST FOR You 53


O R G A N I C S C O M P A N Y
BEST FOR You 54
O R G A N I C S C O M P A N Y
BEST FOR You 55
O R G A N I C S C O M P A N Y
BEST FOR You 56
O R G A N I C S C O M P A N Y
BEST FOR You 57
O R G A N I C S C O M P A N Y
Output Variables

BEST FOR You 58


O R G A N I C S C O M P A N Y
Output Variables

BEST FOR You 59


O R G A N I C S C O M P A N Y
Output Variables

BEST FOR You 60


O R G A N I C S C O M P A N Y
Global Variables

BEST FOR You 61


O R G A N I C S C O M P A N Y
Global Variables

BEST FOR You 62


O R G A N I C S C O M P A N Y
The global Keyword

BEST FOR You 63


O R G A N I C S C O M P A N Y
The global Keyword

BEST FOR You 64


O R G A N I C S C O M P A N Y

You might also like