SlideShare ist ein Scribd-Unternehmen logo
1 von 39
 Introduction-
 What is Python?
 Python History
 Features of Python
 Applications of Python
 Architecture and Working of Python
 Python Constructs
 Python vs Java vs C++
 Python is a General Purpose object-oriented
programming language, which means that it
can model real-world entities. It is also
dynamically-typed because it carries out
type-checking at runtime.
 Python is an interpreted language.
 Guido van Rossum named it after the comedy
group Monty Python
 Python was developed in the late 1980s and was
named after the BBC TV show Monty Python’s
Flying Circus.
 Guido van Rossum started implementing Python
at CWI in the Netherlands in December of 1989.
 This was a successor to the ABC programming
language which was capable of exception
handling and interfacing with the Amoeba
operating system.
 On October 16 of 2000, Python 2.0 released with
many new features.
 Then Python 3.0 released on December 3, 2008
 Python is the “most powerful language you
can still read”, Says Paul Dubois
 Python is one of the richest Programming
languages.
 Going by the TIOBE Index, it is the Second
Most Popular Programming Language in the
world.
 Easy
When writing code in Python, you need fewer
lines of code compared to languages like
Java.
 Interpreted
It is interpreted(executed) line by line. This
makes it easy to test and debug.
 Object-Oriented
The Python programming language supports
classes and objects and hence it is object-
oriented.
 Free and Open Source
The language and its source code are available to the
public for free; there is no need to buy a costly license.
 Portable
Since Python is open-source, you can run it on Windows,
Mac, Linux or any other platform. Your programs will work
without any need to change it for every machine.
 GUI Programming
You can use it to develop a GUI (Graphical User Interface).
One way to do this is through Tkinter.
 Large Python Library
Python provides you with a large standard library.
You can use it to implement a variety of functions without
the need to reinvent the wheel every time. Just pick the
code you need and continue
 Build a website using Python
 Develop a game in Python
 Perform Computer Vision (Facilities like face-
detection and color-detection)
 Implement Machine Learning (Give a computer
the ability to learn)
 Enable Robotics with Python
 Perform Web Scraping (Harvest data from
websites)
 Perform Data Analysis using Python
 Automate a web browser
 Perform Scripting in Python
 Build Artificial Intelligence
 Parser
It uses the source code to generate an
abstract syntax tree.
 Compiler
It turns the abstract syntax tree into Python
bytecode.
 Interpreter
It executes the code line by line in a REPL
(Read-Evaluate-Print-Loop) fashion.
 Functions in Python
 Classes in Python
 Module Packages in Python
 Packages in Python
 List in Python
 Tuple in Python
 Dictionary in Python
 Comments and Docstrings in Python(#, ’’ ’’ “)
 How does Python get its name?
 What are the Features of Python that make it
so popular?
 Define Modules in Python?
 What is the difference between List and Tuple
in Python?
 Compare Python with Java
 A variable is a container for a value. It can be
assigned a name, you can use it to refer to it
later in the program.
 Based on the value assigned, the interpreter
decides its data type.
 x=45 type =integer
 Name=“seed” type = string
 List1=[1,22,33] type = list
 A variable can have a short name (like x and
y) or a more descriptive name (age, carname,
total_volume).
 Rules for Python variables:
1. A variable name must start with a letter or the
underscore character
2. A variable name cannot start with a number
3. A variable name can only contain alpha-numeric
characters and underscores (A-z, 0-9, and _ )
4. Variable names are case-sensitive (age, Age and
AGE are three different variables)
Valid Variable Names Invalid Variable Names
 myval = “Krushna"
my_val = “krushna"
_my_val = “krushna"
myVal = ’krushna’
MYVAL = “krushna"
myval2 = “Krushna“
 Roll_no =23
 rollno1 = 45
 Inavlid Variable Names:
 2myval = “hello"
my-var = “hello"
my var = “hello“
 roll&no = 45
 assign a value to Python variables, you don’t
need to declare its type
 type the value after the equal sign(=).
 You cannot use Python variables before
assigning it a value.
 You can’t put the identifier on the right-hand
side of the equal sign, though. The following
code causes an error.
 You can’t assign Python variables to a
keyword.
 You can assign values to multiple Python variables in one
statement.
1. pin, city=11,‘Pune'
print(pin , city)
2. a,b,c = 11,22,33
print(a)
print(b)
print(c)
 you can assign the same value to multiple Python
variables.
 a=b=7
print(a,b)
 You can also delete Python variables using
the keyword ‘del’.
a='red'
del a
 Python has five standard data types −
Numbers
String
List
Tuple
Dictionary
 Number data types store numeric values.
Number objects are created when you assign
a value to them.
For example −
var1 = 1 var2 = 70
 Python supports four different numerical
types −
1. int (signed integers)
2. float (floating point real values)
3. complex (complex numbers)
x = 11 # int
y = 2.85 # float
z = 4+1j # complex
Float can also be scientific numbers with an
"e" to indicate the power of 10.
x = 35e3 # float
y = 12E4 # float
z = -87.7e100 #float
You can convert from one type to another with the int(), float(),
and complex() methods:
x = 1 # int
y = 2.8 # float
z = 1j # complex
#convert from int to float:
a = float(x)
#convert from float to int:
b = int(y)
#convert from int to complex:
c = complex(x)
 Note: You cannot convert complex numbers into another
number type.
x = str("s1") # x will be 's1‘
y = str(2) # y will be '2‘
z = str(3.0) # z will be '3.0'
 isinstance() function to tell if Python
variables belong to a particular class. It takes
two parameters- the variable/value, and the
class.
 >>> print(isinstance(a,complex))
 2. Strings
A string is a sequence of characters. Python
does not have a char data type, unlike C++
or Java. You can delimit a string using single
quotes or double-quotes.
 >>> city='Ahmednagar'
 >>> city
 What do you mean by scope?
 What are the types of variable scope?
 What is scope of variable with example?
 What are python variables?
 How do you declare a variable in Python 3?
Operator Name Example
+ Addition a+b
- Subtraction a-y
* Multiplication a*y
/ Division a / b
% Modulus a % b
** Exponentiation a ** b
// Floor division a //b
Operator Example Same As
= x = 5 x = 5
+= x += 3 x = x + 3
-= x -= 3 x = x - 3
*= x *= 3 x = x * 3
/= x /= 3 x = x / 3
%= x %= 3 x = x % 3
//= x //= 3 x = x // 3
**= x **= 3 x = x ** 3
|= x |= 3 x = x | 3
Operator Name Example
== Equal x == y
!= Not equal x != y
> Greater than x > y
< Less than x < y
>= Greater than or equal
to
x >= y
<= Less than or equal to x <= y
Operator Description Example
and Returns True if both
statements are true
x < 5 and x < 10
or Returns True if one of
the statements is true
x < 5 or x < 4
not Reverse the result,
returns False if the
result is true
not(x < 5 and x < 10)
 Identity operators are used to compare the
objects, not if they are equal, but if they are
actually the same object, with the same
memory location:
Operator Description Example
is Returns True if both
variables are the same
object
x is y
is not Returns True if both
variables are not the
same object
x is not y
 Membership operators are used to test if a
sequence is presented in an object
Operator Description Example
in Returns True if a sequence
with the specified value is
present in the object
x in y
not in Returns True if a sequence
with the specified value is
not present in the object
x not in y
 Bitwise operators are used to compare
(binary) numbers:

Operator Name Description
& Binary AND Sets each bit to 1 if both bits are 1
| Binary OR Sets each bit to 1 if one of two bits is 1
^ Binary XOR Sets each bit to 1 if only one of two bits is
1
~ Binary NOT Inverts all the bits
<< Zero fill left shift Shift left by pushing zeros in from the
right and let the leftmost bits fall off
1. 5 & 2 => 0101 & 0010 =>0000
2. 5 | 2 => 0101 & 0010 =>0101
3. 5 ^ 3 => 0101 & 0011 =>0110
4. ~5 => ~ 0101 => 1010
5. 10<<1 => 1010<<1 => 10100
6. 10>>1 => 1010 >>1 => 00101
 Strings in Python are identified as a contiguous
set of characters represented in the quotation
marks.
 strings in Python are arrays of bytes representing
unicode characters.
 Python allows for either pairs of single or double
quotes
print("Hello")
print(‘Hello’)
 Assign String to a Variable
a = "Hello"
print(a)
 You can assign a multiline string to a variable
by using three single or double quotes:
 Example
◦ Name = “ ” ” Hello,I am an Interpreter “ “ “
◦ print(Name)
◦ Name = ‘ ‘ ‘ Hello,I am an Interpreter ’ ’ ’
◦ print(Name)
 str = 'Hello World!'
 print (str) # Prints complete string
 print str * 2 # Prints string two times
 print str + "TEST" # Prints concatenated string
 You can return a range of characters by using the slice
 Specify the start index and the end index, separated by a
colon, to return a part of the string.
To display only a part of a string ,use the slicing operator
[].
 print(str[0]) # Prints first character of the string at 0th
index or position
 print str[2:5] # Prints characters starting from 2nd to 4th
character
 print str[2:] # Prints string starting from 2nd character
 Note: The first character has index 0.
 print(b[:5]) # print the characters from the
start to position 5 (not included)
 print(b[2:]) # print the characters from
position 2, and to the end
 Use negative indexes to start the slice from the end of the
string
 print(b[-5:-2]) #
H E L L O 7
[0] [1] [2] [3] [4] [5] Positive
index
[-6] [-5] [-4] [-3] [-2] [-1] Negative
index
 Python Strings can join using the
concatenation operator +.
 a='Do you see this, '
 b='$$?'
a+b
 a='10'
print(2*a)

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to Python - Part Two
Introduction to Python - Part TwoIntroduction to Python - Part Two
Introduction to Python - Part Twoamiable_indian
 
An Introduction : Python
An Introduction : PythonAn Introduction : Python
An Introduction : PythonRaghu Kumar
 
Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Pedro Rodrigues
 
Introduction to Python - Part Three
Introduction to Python - Part ThreeIntroduction to Python - Part Three
Introduction to Python - Part Threeamiable_indian
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python ProgrammingKamal Acharya
 
Python-04| Fundamental data types vs immutability
Python-04| Fundamental data types vs immutabilityPython-04| Fundamental data types vs immutability
Python-04| Fundamental data types vs immutabilityMohd Sajjad
 
Introduction To Programming with Python
Introduction To Programming with PythonIntroduction To Programming with Python
Introduction To Programming with PythonSushant Mane
 
Python for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.comPython for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.comShwetaAggarwal56
 
Learn Python The Hard Way Presentation
Learn Python The Hard Way PresentationLearn Python The Hard Way Presentation
Learn Python The Hard Way PresentationAmira ElSharkawy
 
Let’s Learn Python An introduction to Python
Let’s Learn Python An introduction to Python Let’s Learn Python An introduction to Python
Let’s Learn Python An introduction to Python Jaganadh Gopinadhan
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming LanguageDipankar Achinta
 

Was ist angesagt? (19)

Introduction to Python - Part Two
Introduction to Python - Part TwoIntroduction to Python - Part Two
Introduction to Python - Part Two
 
Python ppt
Python pptPython ppt
Python ppt
 
Python second ppt
Python second pptPython second ppt
Python second ppt
 
An Introduction : Python
An Introduction : PythonAn Introduction : Python
An Introduction : Python
 
Python Basics
Python BasicsPython Basics
Python Basics
 
Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)
 
Introduction to Python - Part Three
Introduction to Python - Part ThreeIntroduction to Python - Part Three
Introduction to Python - Part Three
 
Chapter 9 python fundamentals
Chapter 9 python fundamentalsChapter 9 python fundamentals
Chapter 9 python fundamentals
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
Python programming
Python  programmingPython  programming
Python programming
 
Python Basics
Python Basics Python Basics
Python Basics
 
Python-04| Fundamental data types vs immutability
Python-04| Fundamental data types vs immutabilityPython-04| Fundamental data types vs immutability
Python-04| Fundamental data types vs immutability
 
Introduction To Programming with Python
Introduction To Programming with PythonIntroduction To Programming with Python
Introduction To Programming with Python
 
Python for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.comPython for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.com
 
Learn Python The Hard Way Presentation
Learn Python The Hard Way PresentationLearn Python The Hard Way Presentation
Learn Python The Hard Way Presentation
 
Let’s Learn Python An introduction to Python
Let’s Learn Python An introduction to Python Let’s Learn Python An introduction to Python
Let’s Learn Python An introduction to Python
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
 
Python basics
Python basicsPython basics
Python basics
 
Python numbers
Python numbersPython numbers
Python numbers
 

Ähnlich wie Python basics

Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizeIruolagbePius
 
1. python programming
1. python programming1. python programming
1. python programmingsreeLekha51
 
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxCS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxfaithxdunce63732
 
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...manikamr074
 
An overview on python commands for solving the problems
An overview on python commands for solving the problemsAn overview on python commands for solving the problems
An overview on python commands for solving the problemsRavikiran708913
 
INTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptxINTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptxNimrahafzal1
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxKoteswari Kasireddy
 
FUNDAMENTALS OF PYTHON LANGUAGE
 FUNDAMENTALS OF PYTHON LANGUAGE  FUNDAMENTALS OF PYTHON LANGUAGE
FUNDAMENTALS OF PYTHON LANGUAGE Saraswathi Murugan
 
Python Basics by Akanksha Bali
Python Basics by Akanksha BaliPython Basics by Akanksha Bali
Python Basics by Akanksha BaliAkanksha Bali
 
1_Python Basics.pdf
1_Python Basics.pdf1_Python Basics.pdf
1_Python Basics.pdfMaheshGour5
 

Ähnlich wie Python basics (20)

Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualize
 
Python 3.pptx
Python 3.pptxPython 3.pptx
Python 3.pptx
 
Python slide.1
Python slide.1Python slide.1
Python slide.1
 
1. python programming
1. python programming1. python programming
1. python programming
 
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxCS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
 
MODULE. .pptx
MODULE.                              .pptxMODULE.                              .pptx
MODULE. .pptx
 
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
 
python
pythonpython
python
 
Python for Beginners(v1)
Python for Beginners(v1)Python for Beginners(v1)
Python for Beginners(v1)
 
An overview on python commands for solving the problems
An overview on python commands for solving the problemsAn overview on python commands for solving the problems
An overview on python commands for solving the problems
 
INTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptxINTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptx
 
Python
PythonPython
Python
 
Python
PythonPython
Python
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptx
 
Pythonppt28 11-18
Pythonppt28 11-18Pythonppt28 11-18
Pythonppt28 11-18
 
FUNDAMENTALS OF PYTHON LANGUAGE
 FUNDAMENTALS OF PYTHON LANGUAGE  FUNDAMENTALS OF PYTHON LANGUAGE
FUNDAMENTALS OF PYTHON LANGUAGE
 
Python Basics by Akanksha Bali
Python Basics by Akanksha BaliPython Basics by Akanksha Bali
Python Basics by Akanksha Bali
 
Introduction to Python
Introduction to Python  Introduction to Python
Introduction to Python
 
1_Python Basics.pdf
1_Python Basics.pdf1_Python Basics.pdf
1_Python Basics.pdf
 

Kürzlich hochgeladen

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 

Kürzlich hochgeladen (20)

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 

Python basics

  • 1.
  • 2.  Introduction-  What is Python?  Python History  Features of Python  Applications of Python  Architecture and Working of Python  Python Constructs  Python vs Java vs C++
  • 3.  Python is a General Purpose object-oriented programming language, which means that it can model real-world entities. It is also dynamically-typed because it carries out type-checking at runtime.  Python is an interpreted language.
  • 4.  Guido van Rossum named it after the comedy group Monty Python
  • 5.  Python was developed in the late 1980s and was named after the BBC TV show Monty Python’s Flying Circus.  Guido van Rossum started implementing Python at CWI in the Netherlands in December of 1989.  This was a successor to the ABC programming language which was capable of exception handling and interfacing with the Amoeba operating system.  On October 16 of 2000, Python 2.0 released with many new features.  Then Python 3.0 released on December 3, 2008
  • 6.  Python is the “most powerful language you can still read”, Says Paul Dubois  Python is one of the richest Programming languages.  Going by the TIOBE Index, it is the Second Most Popular Programming Language in the world.
  • 7.  Easy When writing code in Python, you need fewer lines of code compared to languages like Java.  Interpreted It is interpreted(executed) line by line. This makes it easy to test and debug.  Object-Oriented The Python programming language supports classes and objects and hence it is object- oriented.
  • 8.  Free and Open Source The language and its source code are available to the public for free; there is no need to buy a costly license.  Portable Since Python is open-source, you can run it on Windows, Mac, Linux or any other platform. Your programs will work without any need to change it for every machine.  GUI Programming You can use it to develop a GUI (Graphical User Interface). One way to do this is through Tkinter.  Large Python Library Python provides you with a large standard library. You can use it to implement a variety of functions without the need to reinvent the wheel every time. Just pick the code you need and continue
  • 9.  Build a website using Python  Develop a game in Python  Perform Computer Vision (Facilities like face- detection and color-detection)  Implement Machine Learning (Give a computer the ability to learn)  Enable Robotics with Python  Perform Web Scraping (Harvest data from websites)  Perform Data Analysis using Python  Automate a web browser  Perform Scripting in Python  Build Artificial Intelligence
  • 10.  Parser It uses the source code to generate an abstract syntax tree.  Compiler It turns the abstract syntax tree into Python bytecode.  Interpreter It executes the code line by line in a REPL (Read-Evaluate-Print-Loop) fashion.
  • 11.  Functions in Python  Classes in Python  Module Packages in Python  Packages in Python  List in Python  Tuple in Python  Dictionary in Python  Comments and Docstrings in Python(#, ’’ ’’ “)
  • 12.  How does Python get its name?  What are the Features of Python that make it so popular?  Define Modules in Python?  What is the difference between List and Tuple in Python?  Compare Python with Java
  • 13.  A variable is a container for a value. It can be assigned a name, you can use it to refer to it later in the program.  Based on the value assigned, the interpreter decides its data type.  x=45 type =integer  Name=“seed” type = string  List1=[1,22,33] type = list
  • 14.  A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume).  Rules for Python variables: 1. A variable name must start with a letter or the underscore character 2. A variable name cannot start with a number 3. A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) 4. Variable names are case-sensitive (age, Age and AGE are three different variables)
  • 15. Valid Variable Names Invalid Variable Names  myval = “Krushna" my_val = “krushna" _my_val = “krushna" myVal = ’krushna’ MYVAL = “krushna" myval2 = “Krushna“  Roll_no =23  rollno1 = 45  Inavlid Variable Names:  2myval = “hello" my-var = “hello" my var = “hello“  roll&no = 45
  • 16.  assign a value to Python variables, you don’t need to declare its type  type the value after the equal sign(=).  You cannot use Python variables before assigning it a value.  You can’t put the identifier on the right-hand side of the equal sign, though. The following code causes an error.  You can’t assign Python variables to a keyword.
  • 17.  You can assign values to multiple Python variables in one statement. 1. pin, city=11,‘Pune' print(pin , city) 2. a,b,c = 11,22,33 print(a) print(b) print(c)  you can assign the same value to multiple Python variables.  a=b=7 print(a,b)
  • 18.  You can also delete Python variables using the keyword ‘del’. a='red' del a
  • 19.  Python has five standard data types − Numbers String List Tuple Dictionary
  • 20.  Number data types store numeric values. Number objects are created when you assign a value to them. For example − var1 = 1 var2 = 70  Python supports four different numerical types − 1. int (signed integers) 2. float (floating point real values) 3. complex (complex numbers)
  • 21. x = 11 # int y = 2.85 # float z = 4+1j # complex Float can also be scientific numbers with an "e" to indicate the power of 10. x = 35e3 # float y = 12E4 # float z = -87.7e100 #float
  • 22. You can convert from one type to another with the int(), float(), and complex() methods: x = 1 # int y = 2.8 # float z = 1j # complex #convert from int to float: a = float(x) #convert from float to int: b = int(y) #convert from int to complex: c = complex(x)  Note: You cannot convert complex numbers into another number type. x = str("s1") # x will be 's1‘ y = str(2) # y will be '2‘ z = str(3.0) # z will be '3.0'
  • 23.  isinstance() function to tell if Python variables belong to a particular class. It takes two parameters- the variable/value, and the class.  >>> print(isinstance(a,complex))
  • 24.  2. Strings A string is a sequence of characters. Python does not have a char data type, unlike C++ or Java. You can delimit a string using single quotes or double-quotes.  >>> city='Ahmednagar'  >>> city
  • 25.  What do you mean by scope?  What are the types of variable scope?  What is scope of variable with example?  What are python variables?  How do you declare a variable in Python 3?
  • 26. Operator Name Example + Addition a+b - Subtraction a-y * Multiplication a*y / Division a / b % Modulus a % b ** Exponentiation a ** b // Floor division a //b
  • 27. Operator Example Same As = x = 5 x = 5 += x += 3 x = x + 3 -= x -= 3 x = x - 3 *= x *= 3 x = x * 3 /= x /= 3 x = x / 3 %= x %= 3 x = x % 3 //= x //= 3 x = x // 3 **= x **= 3 x = x ** 3 |= x |= 3 x = x | 3
  • 28. Operator Name Example == Equal x == y != Not equal x != y > Greater than x > y < Less than x < y >= Greater than or equal to x >= y <= Less than or equal to x <= y
  • 29. Operator Description Example and Returns True if both statements are true x < 5 and x < 10 or Returns True if one of the statements is true x < 5 or x < 4 not Reverse the result, returns False if the result is true not(x < 5 and x < 10)
  • 30.  Identity operators are used to compare the objects, not if they are equal, but if they are actually the same object, with the same memory location: Operator Description Example is Returns True if both variables are the same object x is y is not Returns True if both variables are not the same object x is not y
  • 31.  Membership operators are used to test if a sequence is presented in an object Operator Description Example in Returns True if a sequence with the specified value is present in the object x in y not in Returns True if a sequence with the specified value is not present in the object x not in y
  • 32.  Bitwise operators are used to compare (binary) numbers:  Operator Name Description & Binary AND Sets each bit to 1 if both bits are 1 | Binary OR Sets each bit to 1 if one of two bits is 1 ^ Binary XOR Sets each bit to 1 if only one of two bits is 1 ~ Binary NOT Inverts all the bits << Zero fill left shift Shift left by pushing zeros in from the right and let the leftmost bits fall off
  • 33. 1. 5 & 2 => 0101 & 0010 =>0000 2. 5 | 2 => 0101 & 0010 =>0101 3. 5 ^ 3 => 0101 & 0011 =>0110 4. ~5 => ~ 0101 => 1010 5. 10<<1 => 1010<<1 => 10100 6. 10>>1 => 1010 >>1 => 00101
  • 34.  Strings in Python are identified as a contiguous set of characters represented in the quotation marks.  strings in Python are arrays of bytes representing unicode characters.  Python allows for either pairs of single or double quotes print("Hello") print(‘Hello’)  Assign String to a Variable a = "Hello" print(a)
  • 35.  You can assign a multiline string to a variable by using three single or double quotes:  Example ◦ Name = “ ” ” Hello,I am an Interpreter “ “ “ ◦ print(Name) ◦ Name = ‘ ‘ ‘ Hello,I am an Interpreter ’ ’ ’ ◦ print(Name)
  • 36.  str = 'Hello World!'  print (str) # Prints complete string  print str * 2 # Prints string two times  print str + "TEST" # Prints concatenated string
  • 37.  You can return a range of characters by using the slice  Specify the start index and the end index, separated by a colon, to return a part of the string. To display only a part of a string ,use the slicing operator [].  print(str[0]) # Prints first character of the string at 0th index or position  print str[2:5] # Prints characters starting from 2nd to 4th character  print str[2:] # Prints string starting from 2nd character  Note: The first character has index 0.
  • 38.  print(b[:5]) # print the characters from the start to position 5 (not included)  print(b[2:]) # print the characters from position 2, and to the end  Use negative indexes to start the slice from the end of the string  print(b[-5:-2]) # H E L L O 7 [0] [1] [2] [3] [4] [5] Positive index [-6] [-5] [-4] [-3] [-2] [-1] Negative index
  • 39.  Python Strings can join using the concatenation operator +.  a='Do you see this, '  b='$$?' a+b  a='10' print(2*a)