SlideShare a Scribd company logo
What is Python?
Python is a general-purpose high-level programming language
and is widely used among the developers’ community.
What is Python?
Python is a general-purpose high-level programming language
and is widely used among the developers’ community.
General Purpose means it can be used for multiple application
such as Data Science, Scripts, Machine Learning, Desktop
Application, Web Application, etc.
High Level Programming Language means human
understandable language (with strong abstraction from the details
of the computer.)
What is Python?
Python was developed by Guido van Rossum in the late eighties
and early nineties at the National Research Institute for
Mathematics and Computer Science in the Netherlands.
Why is it called Python?
When Guido van Rossum began implementing Python, was also
reading the published scripts from “Monty Python’s Flying Circus”,
a BBC comedy series from the 1970s. Van Rossum thought he
needed a name that was short, unique, and slightly mysterious, so
he decided to call the language Python.
Python version
Python 1.0 (1994 Jan)
Python 2.0 (2000 Oct)
Python 3.0 (2000 Dec)
Python 3.11.4 (6 June 2023)
Python does not support backward compatibility as feature in 3.0
were not available in Python 2.0
What is Python?
Python has many reasons for being popular and in demand. A few
of the reasons are mentioned below.
• Emphasis on code readability, shorter codes, ease of
writing.
• Programmers can express logical concepts intarted with
Python fewer lines of code in comparison to languages such
as C++ or Java.
• Python supports multiple programming paradigms, like
object-oriented, imperative and functional programming or
procedural.
• It provides extensive support libraries (Django for web
development, Pandas for data analytics etc.)
• Dynamically typed language(Data type is based on value
assigned)
What is Python?
The core philosophy of Python is summarized in the document
The Zen of Python (PEP 20), which includes aphorisms such as:
• Beautiful is better than ugly.
• Explicit is better than implicit.
• Simple is better than complex.
• Complex is better than complicated.
• Readability counts.
https://peps.python.org/pep-0020
Reasons to learn Python
1. Simplicity
Python is one of the easiest languages to start your journey. Also,
its simplicity does not limit your functional possibilities.
• Python is a free and open-source language
• Easy-to-learn − Python has few keywords, simple structure,
and a clearly defined syntax. This allows the student to pick up the
language quickly.
• Easy-to-read − Python code is more clearly defined and visible
to the eyes.
• Python is interpreted
• Dynamically typed
Reasons to learn Python
1. Simplicity
• Python is interpreted
It has internal compiler. First interpreter will interpret the code if
error any will notify if not it will execute.
• There are no separate compilation and execution steps like C
and C++.
• Directly run the program from the source code.
• Internally, Python converts the source code into an intermediate
form called bytecodes which is then translated into native
language of specific computer to run it.
• No need to worry about linking and loading with libraries, etc.
Reasons to learn Python
1. Simplicity
• Dynamically typed
We do not need to specify the type of the variable while
declaration.
It will implicitly decide what type of values is this and thus will
assign the type at the run time.
1. Simplicity
Reasons to learn Python
Reasons to learn Python
2. Scalability
Python is a programming language that scales very fast. Among
all available languages, Python is a leader in scaling. That means
that Python has more and more possibilities.
Saying that Python provides the best options for newbies because
there are many ways to decide the same issue.
Even if you have a team of non-Python programmers, who knows
C+ +design patterns, Python will be better for them in terms of
time needed to develop and verify code correctness.
It happens fast because you don`t spend your time to find memory
leaks, work for compilation or segmentation faults.
Reasons to learn Python
3. Libraries and Frameworks
Due to its popularity, Python has hundreds of different libraries
and frameworks which is a great addition to your development
process. They save a lot of manual time and can easily replace
the whole solution.
As a geo-scientist, you will find that many of these libraries will be
focused on data visualization, data analytics, Machine Learning,
etc.
Reasons to learn Python
4. Huge Community
Python has a powerful community. You might think that it shouldn`t
be one of the main reasons why you need to select Python. But
the truth is vice versa.
If you don`t get support from other specialists, your learning path
can be difficult. That`s why you should know that this won`t
happen with your Python learning journey.
Reasons to learn Python
5. Jobs and Salary
…
Application Areas
Getting started
Finding an Interpreter
Before we start Python programming, we need to have an
interpreter to interpret and run our programs.
• There are many interpreters available freely to run Python
scripts like IDLE (Integrated Development Environment) that
comes bundled with the Python software downloaded from
http://python.org.
Examples: Spyder, Pycharm, Jupyter Notebook, etc.
• Online interpreters like https://ide.geeksforgeeks.org that can
be used to run Python programs without installing an
interpreter.
• Anaconda (https://www.anaconda.com) – a distribution of the
Python and R programming languages for scientific computing,
that aims to simplify package management and deployment.
Getting started
Writing our first program:
Just type in the following code after you start the interpreter.
print(“Hello World")
Fundamentals of Python
Python Comments
Comments are useful information that the developers provide to
make the reader understand the source code. It explains the logic
or a part of it used in the code. There are two types of comment in
Python:
• Single line comments: Python single line comment starts with
hashtag symbol with no white spaces.
# This is Comment
Fundamentals of Python
Python Comments
Comments are useful information that the developers provide to
make the reader understand the source code. It explains the logic
or a part of it used in the code. There are two types of comment in
Python:
• Multi-line string as comment:
Python multi-line comment is a piece of text enclosed in a
delimiter (“””) on each end of the comment.
“””
This would be a multiline comment
in Python that
spans several lines,
Hanji
“””
Fundamentals of Python
Built-in types
There are many kinds of information that a computer can process,
like numbers and characters. In Python (and other programming
languages), the kinds of information the language is able to
handle are known as types. Many common types are built into
Python – for example integers, floating-point numbers and strings.
Fundamentals of Python
Built-in types
There are many kinds of information that a computer can process,
like numbers and characters. In Python (and other programming
languages), the kinds of information the language is able to
handle are known as types. Many common types are built into
Python – for example integers, floating-point numbers and strings.
Integers
An integer (int type) is a whole number such as 1, 5, 1350 or -34.
1.5 is not an integer because it has a decimal point. Numbers with
decimal points are floating-point numbers. Even 1.0 is a floating-
point number and not an integer.
Fundamentals of Python
Built-in types
There are many kinds of information that a computer can process,
like numbers and characters. In Python (and other programming
languages), the kinds of information the language is able to
handle are known as types. Many common types are built into
Python – for example integers, floating-point numbers and strings.
Floating-point numbers
Floating-point numbers (float type) are numbers with a decimal
point or an exponent (or both). Examples are 5.0, 10.24, 0.0, 12.
and .3
Fundamentals of Python
Built-in types
There are many kinds of information that a computer can process,
like numbers and characters. In Python (and other programming
languages), the kinds of information the language is able to
handle are known as types. Many common types are built into
Python – for example integers, floating-point numbers and strings.
Strings
A string (type str) is a sequence of characters.
Strings in python are surrounded by either single quotation marks,
or double quotation marks.
print("Hello")
print('Hello')
Fundamentals of Python
Exercise
Which of the following numbers are valid Python integers?
110, 1.0, 17.5, -39, -2.3, “-1”, 11.0
Fundamentals of Python
Variables
Variable is a label for a location in memory.
It can be used to hold a value.
To define a new variable in Python, we simply assign a value to a
label. For example, this is how we create a variable called count,
which contains an integer value of zero:
# define variable count
count = 0
Fundamentals of Python
Variables
Variable is a label for a location in memory.
It can be used to hold a value.
To define a new variable in Python, we simply assign a value to a
label. For example, this is how we create a variable called count,
which contains an integer value of zero:
# define variable count
count = 0
# redefine variable count
count = 2
Fundamentals of Python
Variables
Variable is a label for a location in memory.
It can be used to hold a value.
Python has some rules that you must follow when forming an
identifier:
• it may only contain letters (uppercase or lowercase), numbers
or the underscore character (_) (no spaces!).
• it may not start with a number.
• it may not be a keyword.
Fundamentals of Python
Variables
Variables in Python are not “statically typed”. We do not need to
declare variables before using them or declare their type. A
variable is created the moment we first assign a value to it.
# An integer assignment
age = 45
# A floating point
salary = 1456.8
# A string
name = "John"
print(age)
print(salary)
print(name)
Fundamentals of Python
Operators
Operators are the main building block of any programming
language. Operators allow the programmer to perform different
kinds of operations on operands. These operators can be
categorized based upon their different functionality.
Fundamentals of Python
Operators
• Arithmetic operators:
Arithmetic operators are used
to perform mathematical
operations like addition,
subtraction, multiplication and
division.
# Examples of Arithmetic Operator
a = 9
b = 4
# Addition of numbers
add = a + b
# Subtraction of numbers
sub = a - b
# Multiplication of number
mul = a * b
# Division(float) of number
div1 = a / b
# Division(floor) of number
div2 = a // b
# Modulus (remainder)
mod = a % b
# Exponent (power)
pwr = a ** b
Fundamentals of Python
Operators
• Arithmetic operators
Operator precedence
• Python has a specific and predictable way to
determine the order in which it performs
operations. For integer operations, the
system will first handle brackets (), then **,
then *, // and %, and finally + and -.
• If an expression contains multiple operations
which are at the same level of precedence,
like *, // and %, they will be performed in
order, either from left to right (for left-
associative operators) or from right to left
(for right-associative operators).
All these arithmetic operators are left-
associative, except for **, which is right-
associative.
# Examples of Arithmetic Operator
a = 9
b = 4
# Addition of numbers
add = a + b
# Subtraction of numbers
sub = a - b
# Multiplication of number
mul = a * b
# Division(float) of number
div1 = a / b
# Division(floor) of number
div2 = a // b
# Modulus (remainder)
mod = a % b
# Exponent (power)
pwr = a ** b
Fundamentals of Python
Operators
• Relational Operators:
Relational operators compares
the values. It either returns
True or False according to the
condition.
• == equal to
• != not equal to
• > greater than
• < less than
• >= greater than or equal to
• <= less than or equal to
# Examples of Relational Operators
a = 13
b = 33
# a > b is False
print(a > b)
# a < b is True
print(a < b)
# a == b is False
print(a == b)
# a != b is True
print(a != b)
# a >= b is False
print(a >= b)
# a <= b is True
print(a <= b)
Fundamentals of Python
Operators
• Logical Operators:
Logical operators perform
Logical AND, Logical OR and
Logical NOT operations.
# Examples of Logical Operator
a = True
b = False
# Print a and b is False
print(a and b)
# Print a or b is True
print(a or b)
# Print not a is False
print(not a)
Fundamentals of Python
Exercise
What are the results of the following operations and explain why:
15 + 20 * 3 = ?
13 // 2 + 3 = ?
31 + 10 // 3 = ?
20 % 7 // 3 = ?
Fundamentals of Python
Basics of data Input
• input(): This function first
takes the input from the user
and then evaluates the
expression, which means
Python automatically identifies
whether the user entered a
string or a number or list.
# input() example
name = input(“Enter your name:”)
print(name)
Fundamentals of Python
Python Indentation
Python uses indentation to highlight the blocks of code.
Whitespace is used for indentation in Python. All statements with
the same distance to the right belong to the same block of code. If
a block has to be more deeply nested, it is simply indented further
to the right. You can understand it better by looking at the
following lines of code.
# Python program showing
# indentation
university = ‘NEHU'
if university == ‘NEHU’:
print(‘Hi, NEHU student!')
else:
print(‘The university is not NEHU')
print('All set !')
Fundamentals of Python
Selection
Selection in Python is made using the two keywords ‘if’ and ‘elif’
and else (elseif)
# Python program to illustrate
# selection statement
mark = 34
if mark >= 80:
print(“Grade is A”)
elif mark >= 65:
print(“Grade is B”)
elif mark >= 50:
print(“Grade is C”)
else:
print(“Grade is D”)
Fundamentals of Python
Selection
Selection in Python is made using the two keywords ‘if’ and ‘elif’
and else (elseif)
# Python program to illustrate
# selection statement
mark = 34
if mark >= 80:
print(“Grade is A”)
elif mark >= 65:
print(“Grade is B”)
else:
if mark >= 50:
print(“Grade is C”)
else:
print(“Grade is D”)
Fundamentals of Python
Selection
Selection in Python is made using the two keywords ‘if’ and ‘elif’
and else (elseif)
# Python program to illustrate
# selection statement
mark = 34
if mark >= 80:
print(“Grade is A”)
elif mark >= 65:
print(“Grade is B”)
else:
if mark >= 50:
print(“Grade is C”)
else:
print(“Grade is D”)
Python basics

More Related Content

What's hot

Python programming
Python programmingPython programming
Python programming
Megha V
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An Introduction
Swarit Wadhe
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
primeteacher32
 
What's new in Python 3.11
What's new in Python 3.11What's new in Python 3.11
What's new in Python 3.11
Henry Schreiner
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Agung Wahyudi
 
Time complexity.ppt
Time complexity.pptTime complexity.ppt
Time complexity.ppt
YekoyeTigabuYeko
 
Python | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python TutorialPython | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python Tutorial
QA TrainingHub
 
Data Representation
Data RepresentationData Representation
Data Representation
Dilum Bandara
 
Algorithm - Introduction
Algorithm - IntroductionAlgorithm - Introduction
Algorithm - Introduction
Madhu Bala
 
Python
PythonPython
Python and its Applications
Python and its ApplicationsPython and its Applications
Python and its Applications
Abhijeet Singh
 
Python Basics
Python BasicsPython Basics
Python Basics
Pooja B S
 
Introduction to python
 Introduction to python Introduction to python
Introduction to python
Learnbay Datascience
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
Dr.YNM
 
Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming
KrishnaMildain
 
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Edureka!
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Ahmed Salama
 
Boolean algebra And Logic Gates
Boolean algebra And Logic GatesBoolean algebra And Logic Gates
Boolean algebra And Logic GatesKumar
 
Python Workshop
Python WorkshopPython Workshop
Python Workshop
Saket Choudhary
 
Introduction to Python Basics Programming
Introduction to Python Basics ProgrammingIntroduction to Python Basics Programming
Introduction to Python Basics Programming
Collaboration Technologies
 

What's hot (20)

Python programming
Python programmingPython programming
Python programming
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An Introduction
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
What's new in Python 3.11
What's new in Python 3.11What's new in Python 3.11
What's new in Python 3.11
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Time complexity.ppt
Time complexity.pptTime complexity.ppt
Time complexity.ppt
 
Python | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python TutorialPython | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python Tutorial
 
Data Representation
Data RepresentationData Representation
Data Representation
 
Algorithm - Introduction
Algorithm - IntroductionAlgorithm - Introduction
Algorithm - Introduction
 
Python
PythonPython
Python
 
Python and its Applications
Python and its ApplicationsPython and its Applications
Python and its Applications
 
Python Basics
Python BasicsPython Basics
Python Basics
 
Introduction to python
 Introduction to python Introduction to python
Introduction to python
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
 
Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming
 
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Boolean algebra And Logic Gates
Boolean algebra And Logic GatesBoolean algebra And Logic Gates
Boolean algebra And Logic Gates
 
Python Workshop
Python WorkshopPython Workshop
Python Workshop
 
Introduction to Python Basics Programming
Introduction to Python Basics ProgrammingIntroduction to Python Basics Programming
Introduction to Python Basics Programming
 

Similar to Python basics

Introduction to Python Unit -1 Part .pdf
Introduction to Python Unit -1 Part .pdfIntroduction to Python Unit -1 Part .pdf
Introduction to Python Unit -1 Part .pdf
VaibhavKumarSinghkal
 
Python Programming Part 1.pdf
Python Programming Part 1.pdfPython Programming Part 1.pdf
Python Programming Part 1.pdf
percivalfernandez2
 
Python Programming Part 1.pdf
Python Programming Part 1.pdfPython Programming Part 1.pdf
Python Programming Part 1.pdf
percivalfernandez2
 
Python Programming Part 1.pdf
Python Programming Part 1.pdfPython Programming Part 1.pdf
Python Programming Part 1.pdf
percivalfernandez2
 
Learn Python Python Introduction for Beginners.pdf
Learn Python  Python Introduction for Beginners.pdfLearn Python  Python Introduction for Beginners.pdf
Learn Python Python Introduction for Beginners.pdf
SudhanshiBakre1
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
SudhanshiBakre1
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
MuhammadBakri13
 
python classes in thane
python classes in thanepython classes in thane
python classes in thane
faizrashid1995
 
Python Programming
Python ProgrammingPython Programming
Python Programming
shahid sultan
 
Python Programming-1.pptx of python by computer
Python Programming-1.pptx of python by computerPython Programming-1.pptx of python by computer
Python Programming-1.pptx of python by computer
sharanyarashmir5
 
Python_Introduction&DataType.pptx
Python_Introduction&DataType.pptxPython_Introduction&DataType.pptx
Python_Introduction&DataType.pptx
HaythamBarakeh1
 
4_Introduction to Python Programming.pptx
4_Introduction to Python Programming.pptx4_Introduction to Python Programming.pptx
4_Introduction to Python Programming.pptx
Gnanesh12
 
Features of Python.pdf
Features of Python.pdfFeatures of Python.pdf
Features of Python.pdf
SudhanshiBakre1
 
Python Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docxPython Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docx
Manohar k
 
python-ppt.ppt
python-ppt.pptpython-ppt.ppt
python-ppt.ppt
MohammadSamiuddin10
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
ApxicTechnologies1
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
DrMohammed Qassim
 
Fundamentals of python
Fundamentals of pythonFundamentals of python
Fundamentals of python
BijuAugustian
 
Basic Python Introduction Lecture 1.pptx
Basic Python Introduction Lecture 1.pptxBasic Python Introduction Lecture 1.pptx
Basic Python Introduction Lecture 1.pptx
Aditya Patel
 

Similar to Python basics (20)

Introduction to Python Unit -1 Part .pdf
Introduction to Python Unit -1 Part .pdfIntroduction to Python Unit -1 Part .pdf
Introduction to Python Unit -1 Part .pdf
 
Python Programming Part 1.pdf
Python Programming Part 1.pdfPython Programming Part 1.pdf
Python Programming Part 1.pdf
 
Python Programming Part 1.pdf
Python Programming Part 1.pdfPython Programming Part 1.pdf
Python Programming Part 1.pdf
 
Python Programming Part 1.pdf
Python Programming Part 1.pdfPython Programming Part 1.pdf
Python Programming Part 1.pdf
 
Learn Python Python Introduction for Beginners.pdf
Learn Python  Python Introduction for Beginners.pdfLearn Python  Python Introduction for Beginners.pdf
Learn Python Python Introduction for Beginners.pdf
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
python classes in thane
python classes in thanepython classes in thane
python classes in thane
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
Python Programming-1.pptx of python by computer
Python Programming-1.pptx of python by computerPython Programming-1.pptx of python by computer
Python Programming-1.pptx of python by computer
 
Python_Introduction&DataType.pptx
Python_Introduction&DataType.pptxPython_Introduction&DataType.pptx
Python_Introduction&DataType.pptx
 
4_Introduction to Python Programming.pptx
4_Introduction to Python Programming.pptx4_Introduction to Python Programming.pptx
4_Introduction to Python Programming.pptx
 
Features of Python.pdf
Features of Python.pdfFeatures of Python.pdf
Features of Python.pdf
 
Python Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docxPython Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docx
 
python-ppt.ppt
python-ppt.pptpython-ppt.ppt
python-ppt.ppt
 
python-ppt.ppt
python-ppt.pptpython-ppt.ppt
python-ppt.ppt
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Fundamentals of python
Fundamentals of pythonFundamentals of python
Fundamentals of python
 
Basic Python Introduction Lecture 1.pptx
Basic Python Introduction Lecture 1.pptxBasic Python Introduction Lecture 1.pptx
Basic Python Introduction Lecture 1.pptx
 

Recently uploaded

Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 

Recently uploaded (20)

Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 

Python basics

  • 1.
  • 2. What is Python? Python is a general-purpose high-level programming language and is widely used among the developers’ community.
  • 3. What is Python? Python is a general-purpose high-level programming language and is widely used among the developers’ community. General Purpose means it can be used for multiple application such as Data Science, Scripts, Machine Learning, Desktop Application, Web Application, etc. High Level Programming Language means human understandable language (with strong abstraction from the details of the computer.)
  • 4. What is Python? Python was developed by Guido van Rossum in the late eighties and early nineties at the National Research Institute for Mathematics and Computer Science in the Netherlands. Why is it called Python? When Guido van Rossum began implementing Python, was also reading the published scripts from “Monty Python’s Flying Circus”, a BBC comedy series from the 1970s. Van Rossum thought he needed a name that was short, unique, and slightly mysterious, so he decided to call the language Python.
  • 5. Python version Python 1.0 (1994 Jan) Python 2.0 (2000 Oct) Python 3.0 (2000 Dec) Python 3.11.4 (6 June 2023) Python does not support backward compatibility as feature in 3.0 were not available in Python 2.0
  • 6. What is Python? Python has many reasons for being popular and in demand. A few of the reasons are mentioned below. • Emphasis on code readability, shorter codes, ease of writing. • Programmers can express logical concepts intarted with Python fewer lines of code in comparison to languages such as C++ or Java. • Python supports multiple programming paradigms, like object-oriented, imperative and functional programming or procedural. • It provides extensive support libraries (Django for web development, Pandas for data analytics etc.) • Dynamically typed language(Data type is based on value assigned)
  • 7. What is Python? The core philosophy of Python is summarized in the document The Zen of Python (PEP 20), which includes aphorisms such as: • Beautiful is better than ugly. • Explicit is better than implicit. • Simple is better than complex. • Complex is better than complicated. • Readability counts. https://peps.python.org/pep-0020
  • 8. Reasons to learn Python 1. Simplicity Python is one of the easiest languages to start your journey. Also, its simplicity does not limit your functional possibilities. • Python is a free and open-source language • Easy-to-learn − Python has few keywords, simple structure, and a clearly defined syntax. This allows the student to pick up the language quickly. • Easy-to-read − Python code is more clearly defined and visible to the eyes. • Python is interpreted • Dynamically typed
  • 9. Reasons to learn Python 1. Simplicity • Python is interpreted It has internal compiler. First interpreter will interpret the code if error any will notify if not it will execute. • There are no separate compilation and execution steps like C and C++. • Directly run the program from the source code. • Internally, Python converts the source code into an intermediate form called bytecodes which is then translated into native language of specific computer to run it. • No need to worry about linking and loading with libraries, etc.
  • 10. Reasons to learn Python 1. Simplicity • Dynamically typed We do not need to specify the type of the variable while declaration. It will implicitly decide what type of values is this and thus will assign the type at the run time.
  • 11. 1. Simplicity Reasons to learn Python
  • 12. Reasons to learn Python 2. Scalability Python is a programming language that scales very fast. Among all available languages, Python is a leader in scaling. That means that Python has more and more possibilities. Saying that Python provides the best options for newbies because there are many ways to decide the same issue. Even if you have a team of non-Python programmers, who knows C+ +design patterns, Python will be better for them in terms of time needed to develop and verify code correctness. It happens fast because you don`t spend your time to find memory leaks, work for compilation or segmentation faults.
  • 13. Reasons to learn Python 3. Libraries and Frameworks Due to its popularity, Python has hundreds of different libraries and frameworks which is a great addition to your development process. They save a lot of manual time and can easily replace the whole solution. As a geo-scientist, you will find that many of these libraries will be focused on data visualization, data analytics, Machine Learning, etc.
  • 14. Reasons to learn Python 4. Huge Community Python has a powerful community. You might think that it shouldn`t be one of the main reasons why you need to select Python. But the truth is vice versa. If you don`t get support from other specialists, your learning path can be difficult. That`s why you should know that this won`t happen with your Python learning journey.
  • 15. Reasons to learn Python 5. Jobs and Salary …
  • 17. Getting started Finding an Interpreter Before we start Python programming, we need to have an interpreter to interpret and run our programs. • There are many interpreters available freely to run Python scripts like IDLE (Integrated Development Environment) that comes bundled with the Python software downloaded from http://python.org. Examples: Spyder, Pycharm, Jupyter Notebook, etc. • Online interpreters like https://ide.geeksforgeeks.org that can be used to run Python programs without installing an interpreter. • Anaconda (https://www.anaconda.com) – a distribution of the Python and R programming languages for scientific computing, that aims to simplify package management and deployment.
  • 18. Getting started Writing our first program: Just type in the following code after you start the interpreter. print(“Hello World")
  • 19. Fundamentals of Python Python Comments Comments are useful information that the developers provide to make the reader understand the source code. It explains the logic or a part of it used in the code. There are two types of comment in Python: • Single line comments: Python single line comment starts with hashtag symbol with no white spaces. # This is Comment
  • 20. Fundamentals of Python Python Comments Comments are useful information that the developers provide to make the reader understand the source code. It explains the logic or a part of it used in the code. There are two types of comment in Python: • Multi-line string as comment: Python multi-line comment is a piece of text enclosed in a delimiter (“””) on each end of the comment. “”” This would be a multiline comment in Python that spans several lines, Hanji “””
  • 21. Fundamentals of Python Built-in types There are many kinds of information that a computer can process, like numbers and characters. In Python (and other programming languages), the kinds of information the language is able to handle are known as types. Many common types are built into Python – for example integers, floating-point numbers and strings.
  • 22. Fundamentals of Python Built-in types There are many kinds of information that a computer can process, like numbers and characters. In Python (and other programming languages), the kinds of information the language is able to handle are known as types. Many common types are built into Python – for example integers, floating-point numbers and strings. Integers An integer (int type) is a whole number such as 1, 5, 1350 or -34. 1.5 is not an integer because it has a decimal point. Numbers with decimal points are floating-point numbers. Even 1.0 is a floating- point number and not an integer.
  • 23. Fundamentals of Python Built-in types There are many kinds of information that a computer can process, like numbers and characters. In Python (and other programming languages), the kinds of information the language is able to handle are known as types. Many common types are built into Python – for example integers, floating-point numbers and strings. Floating-point numbers Floating-point numbers (float type) are numbers with a decimal point or an exponent (or both). Examples are 5.0, 10.24, 0.0, 12. and .3
  • 24. Fundamentals of Python Built-in types There are many kinds of information that a computer can process, like numbers and characters. In Python (and other programming languages), the kinds of information the language is able to handle are known as types. Many common types are built into Python – for example integers, floating-point numbers and strings. Strings A string (type str) is a sequence of characters. Strings in python are surrounded by either single quotation marks, or double quotation marks. print("Hello") print('Hello')
  • 25. Fundamentals of Python Exercise Which of the following numbers are valid Python integers? 110, 1.0, 17.5, -39, -2.3, “-1”, 11.0
  • 26. Fundamentals of Python Variables Variable is a label for a location in memory. It can be used to hold a value. To define a new variable in Python, we simply assign a value to a label. For example, this is how we create a variable called count, which contains an integer value of zero: # define variable count count = 0
  • 27. Fundamentals of Python Variables Variable is a label for a location in memory. It can be used to hold a value. To define a new variable in Python, we simply assign a value to a label. For example, this is how we create a variable called count, which contains an integer value of zero: # define variable count count = 0 # redefine variable count count = 2
  • 28. Fundamentals of Python Variables Variable is a label for a location in memory. It can be used to hold a value. Python has some rules that you must follow when forming an identifier: • it may only contain letters (uppercase or lowercase), numbers or the underscore character (_) (no spaces!). • it may not start with a number. • it may not be a keyword.
  • 29. Fundamentals of Python Variables Variables in Python are not “statically typed”. We do not need to declare variables before using them or declare their type. A variable is created the moment we first assign a value to it. # An integer assignment age = 45 # A floating point salary = 1456.8 # A string name = "John" print(age) print(salary) print(name)
  • 30. Fundamentals of Python Operators Operators are the main building block of any programming language. Operators allow the programmer to perform different kinds of operations on operands. These operators can be categorized based upon their different functionality.
  • 31. Fundamentals of Python Operators • Arithmetic operators: Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication and division. # Examples of Arithmetic Operator a = 9 b = 4 # Addition of numbers add = a + b # Subtraction of numbers sub = a - b # Multiplication of number mul = a * b # Division(float) of number div1 = a / b # Division(floor) of number div2 = a // b # Modulus (remainder) mod = a % b # Exponent (power) pwr = a ** b
  • 32. Fundamentals of Python Operators • Arithmetic operators Operator precedence • Python has a specific and predictable way to determine the order in which it performs operations. For integer operations, the system will first handle brackets (), then **, then *, // and %, and finally + and -. • If an expression contains multiple operations which are at the same level of precedence, like *, // and %, they will be performed in order, either from left to right (for left- associative operators) or from right to left (for right-associative operators). All these arithmetic operators are left- associative, except for **, which is right- associative. # Examples of Arithmetic Operator a = 9 b = 4 # Addition of numbers add = a + b # Subtraction of numbers sub = a - b # Multiplication of number mul = a * b # Division(float) of number div1 = a / b # Division(floor) of number div2 = a // b # Modulus (remainder) mod = a % b # Exponent (power) pwr = a ** b
  • 33. Fundamentals of Python Operators • Relational Operators: Relational operators compares the values. It either returns True or False according to the condition. • == equal to • != not equal to • > greater than • < less than • >= greater than or equal to • <= less than or equal to # Examples of Relational Operators a = 13 b = 33 # a > b is False print(a > b) # a < b is True print(a < b) # a == b is False print(a == b) # a != b is True print(a != b) # a >= b is False print(a >= b) # a <= b is True print(a <= b)
  • 34. Fundamentals of Python Operators • Logical Operators: Logical operators perform Logical AND, Logical OR and Logical NOT operations. # Examples of Logical Operator a = True b = False # Print a and b is False print(a and b) # Print a or b is True print(a or b) # Print not a is False print(not a)
  • 35. Fundamentals of Python Exercise What are the results of the following operations and explain why: 15 + 20 * 3 = ? 13 // 2 + 3 = ? 31 + 10 // 3 = ? 20 % 7 // 3 = ?
  • 36. Fundamentals of Python Basics of data Input • input(): This function first takes the input from the user and then evaluates the expression, which means Python automatically identifies whether the user entered a string or a number or list. # input() example name = input(“Enter your name:”) print(name)
  • 37. Fundamentals of Python Python Indentation Python uses indentation to highlight the blocks of code. Whitespace is used for indentation in Python. All statements with the same distance to the right belong to the same block of code. If a block has to be more deeply nested, it is simply indented further to the right. You can understand it better by looking at the following lines of code. # Python program showing # indentation university = ‘NEHU' if university == ‘NEHU’: print(‘Hi, NEHU student!') else: print(‘The university is not NEHU') print('All set !')
  • 38. Fundamentals of Python Selection Selection in Python is made using the two keywords ‘if’ and ‘elif’ and else (elseif) # Python program to illustrate # selection statement mark = 34 if mark >= 80: print(“Grade is A”) elif mark >= 65: print(“Grade is B”) elif mark >= 50: print(“Grade is C”) else: print(“Grade is D”)
  • 39. Fundamentals of Python Selection Selection in Python is made using the two keywords ‘if’ and ‘elif’ and else (elseif) # Python program to illustrate # selection statement mark = 34 if mark >= 80: print(“Grade is A”) elif mark >= 65: print(“Grade is B”) else: if mark >= 50: print(“Grade is C”) else: print(“Grade is D”)
  • 40. Fundamentals of Python Selection Selection in Python is made using the two keywords ‘if’ and ‘elif’ and else (elseif) # Python program to illustrate # selection statement mark = 34 if mark >= 80: print(“Grade is A”) elif mark >= 65: print(“Grade is B”) else: if mark >= 50: print(“Grade is C”) else: print(“Grade is D”)