SlideShare una empresa de Scribd logo
1 de 62
in
CLOUD
• What is Python?
• Features of Python
• Who uses Python?
• Applications
• How to download python
• Working with interactive prompt
• Dynamic
• Identifiers
• Keywords
• Python Syntax
CONTENTS (Day1)
• Python is a general purpose, dynamic, high-level, and
interpreted programming language.
• Created by Guido Van Rossum in 1989.
What is Python
1) Easy to Learn and Use
2) Expressive Language
3) Interpreted Language
4) Cross-platform Language
5) Free and Open Source-https://www.python.org/
6) Object-Oriented Language
7) Extensible
8) Large Standard Library
9) GUI Programming Support
10) Integrated
Python Features
Top Companies
Applications
How to download Python
Interactive interpreter prompt
Interactive interpreter prompt
Interactive interpreter prompt
• When assigning to a variable, we do not need to
declare the data type of the values it will hold. This is
decided by the interpreter at runtime.
• We do not declare a variable, we directly assign to it.
Python is Dynamically-Typed
• A variable name is called an identifier and has to
follow some rules:
• Variables can have letters (A-Z and a-z), digits(0-9)
and underscores.
• It cannot begin with an underscore (_) or a digit.
• It cannot have whitespace and signs like + and -,
!, @, $, #, %.
• It cannot be a reserved keyword for Python.
• Variable names are case sensitive.
Identifiers
• These are 33 reserved words.
• You cannot use a word from this list as a name for
your variable or function.
• Python variable names are case-sensitive. The
variable ‘name’ is different than the variable ‘Name’
Reserved Keywords
• The term syntax is referred to a set of rules and
principles that describes the structure of a language.
Python Syntax
A Python program comprises logical lines. A NEWLINE token
follows each of those. The interpreter ignores blank lines.
The following line causes an error.
>>> print("Hi
How are you?")
Output:
SyntaxError: EOL while scanning string literal
Python Line Structure
• This one is an important Python syntax.
• We saw that Python does not mandate semicolons.
• A new line means a new statement. But sometimes, you may
want to split a statement over two or more lines.
Python Multiline Statements
• A docstring is a documentation string.
• As a comment, this Python Syntax is used to explain code.
• But unlike comments, they are more specific. Also, they are
retained at runtime. This way, the programmer can inspect
them at runtime.
"""
This function prints out a greeting
"""
print("Hi")
Python Docstrings
• Python doesn’t use curly braces to delimit blocks of code, this
Python Syntax is mandatory.
• You can indent code under a function, loop, or class.
• >>> if 2>1:
print("2 is the bigger person");
print("But 1 is worthy too");
Python Indentation
You can also fit in more than one statement on one line.
Do this by separating them with a semicolon.
>>> a=7;print(a);
Python Multiple Statements in One
Line
Python supports the single quote and the double quote for string
literals.
But if you begin a string with a single quote, you must end it with
a single quote. The same goes for double-quotes.
• >>> print('We need a break');
• >>> print("We need a ‘break'");
Python Quotations
• You can use the % operator to format a string to contain text
as well as values of identifiers.
• Use %s where you want a value to appear. After the string,
put a % operator and mention the identifiers in parameters.
Python String Formatters
I just printed 10 pages to the printer HP
Python String Formatters
• You can use the % operator to format a string to contain text
as well as values of identifiers.
• Use %s where you want a value to appear. After the string,
put a % operator and mention the identifiers in parameters.
Python String Formatters
I just printed 10 pages to the printer HP
Python Syntax ‘Comments’ let you store tags at the
right places in the code. You can use them to explain
complex sections of code. The interpreter ignores
comments. Declare a comment using an Hash(#).
>>>#this is a comment line
Python Comments
• Python allows us to assign a value to multiple
variables in a single statement which is also known as
multiple assignment.
• We can apply multiple assignments in two ways
either by assigning a single value to multiple
variables
or
• assigning multiple values to multiple variables.
Multiple Assignment
Multiple Assignment
Multiple Assignment
Anaconda
Anaconda Navigator
SPYDER
SPYDER
Python Data Types
• Variables can hold values of different data types.
• Python is a dynamically typed language hence we
need not define the type of the variable while
declaring it.
• The interpreter implicitly binds the value with its
type.
Python Data Types
• python enables us to check the type of the variable used in the program.
• Python provides us the type() function which returns the type of the
variable passed.
Python Data Types
Python data types are categorized into two as follows:
Mutable Data Types: Data types in python where the value
assigned to a variable can be changed
Immutable Data Types: Data types in python where the
value assigned to a variable cannot be changed
Python Data Types
Python-Numbers
• Number data types store numeric values.
• They are immutable data types, means that changing
the value of a number data type is not possible.
• For example −
• var1 = 1 var2 = 10
• You can also delete the reference to a number object
by using the del statement.
• Del var1
Python-Numbers
• Python supports four different numerical types −
• int (signed integers) − They are often called just integers or ints,
are positive or negative whole numbers with no decimal point.
• Long (long integers ) − Also called longs, they are integers of
unlimited size, written like integers and followed by an uppercase
or lowercase L.
• float (floating point real values) − Also called floats, they
represent real numbers and are written with a decimal point
dividing the integer and fractional parts.
• complex (complex numbers) − are of the form a + bJ, where a and
b are floats and J (or j) represents the square root of -1 (which is an
imaginary number).
Number Type Conversion
• But sometimes, you need to convert a number explicitly from
one type to another to satisfy the requirements of an
operator or function parameter.
• Type int(x) to convert x to a plain integer.
• Type long(x) to convert x to a long integer.
• Type float(x) to convert x to a floating-point number.
• Type complex(x) to convert x to a complex number with real
part x and imaginary part zero.
• Type complex(x, y) to convert x and y to a complex number
with real part x and imaginary part y. x and y are numeric
expressions
Number Type Conversion
Strings
• Strings are amongst the most popular types in
Python.
• We can create them simply by enclosing characters in
quotes. Python treats single quotes the same as
double quotes.
• var1 = 'Hello World!‘
• var2 = "Python Programming"
Accessing Values in Strings
• Python does not support a character type; these are treated
as strings of length one, thus also considered a substring.
• To access substrings, use the square brackets for slicing along
with the index or indices to obtain your substring.
Updating Strings
• You can "update" an existing string by (re)assigning a variable
to another string. The new value can be related to its previous
value or to a completely different string altogether.
String Special Operators
Strings
Python Lists
• Lists are the most versatile of Python's compound
data types.
• A list contains items separated by commas and
enclosed within square brackets ([]).
• To some extent, lists are similar to arrays in C.
• One difference between them is that all the items
belonging to a list can be of different data type.
Python Lists
Python Tuples
• A tuple is another sequence data type that is similar to
the list.
• A tuple consists of a number of values separated by
commas.
• Unlike lists, however, tuples are enclosed within
parentheses.
• The main differences between lists and tuples are: Lists
are enclosed in brackets ( [ ] ) and their elements and size
can be changed,
• while tuples are enclosed in parentheses ( ( ) ) and
cannot be updated.
• Tuples can be thought of as read-only lists.
Python Tuples
Python Dictionary
• A Python dictionary is a mapping of unique keys to
values. Dictionaries are mutable, which means they
can be changed.
• Dictionaries are enclosed by curly braces ({ }) and
values can be assigned and accessed using square
braces ([]).
Python Dictionary
dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}
Print( "dict['Name']: ", dict['Name'])
print ("dict['Age']: ", dict['Age'])
Dictionary Functions
• Len-The method len() gives the total length of the
dictionary.
• dict = {'Name': 'Zara', 'Age': 7};
• print (len(dict))
• Copy-The method copy() returns a shallow copy of the
dictionary.
• dict1 = {'Name': 'Zara', 'Age': 7};
• dict2 = dict1.copy()
• print "New Dictionary : %s" % str(dict2)
• Keys-The method keys() returns a list of all the
available keys in the dictionary.
• my_dict = {'name':'Jack', 'age': 26}
• print "Value : %s" % dict.keys()
• Values-The method values() returns a list of all
the values available in a given dictionary.
• print "Value : %s" % dict.values()
Set in Python
• A set is an unordered collection of items.
• Every element is unique (no duplicates) and
must be immutable (which cannot be
changed).
• my_set = {1, 2, 3}
• print(my_set)
Change a set in Python
• Sets are mutable. But since they are unordered,
indexing have no meaning.
• We can add single element using
the add() method and multiple elements using
the update() method.
• The update() method can take tuples,
lists, strings or other sets as its argument. In all
cases, duplicates are avoided.
Remove elements from a set
• A particular item can be removed from set using
methods, discard() and remove().
• The only difference between the two is that,
while using discard() if the item does not exist in
the set, it remains unchanged.
• But remove() will raise an error in such condition.
• my_set.discard(4)
• print(my_set)
• my_set.remove(4)
Thank you

Más contenido relacionado

La actualidad más candente

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
 
Python Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | EdurekaPython Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | EdurekaEdureka!
 
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | EdurekaPython Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | EdurekaEdureka!
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in pythoneShikshak
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonAgung Wahyudi
 
Introduction To Python | Edureka
Introduction To Python | EdurekaIntroduction To Python | Edureka
Introduction To Python | EdurekaEdureka!
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming LanguageTahani Al-Manie
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to PythonNowell Strite
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-pythonAakashdata
 
programming with python ppt
programming with python pptprogramming with python ppt
programming with python pptPriyanka Pradhan
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python ProgrammingKamal Acharya
 
Python presentation by Monu Sharma
Python presentation by Monu SharmaPython presentation by Monu Sharma
Python presentation by Monu SharmaMayank Sharma
 

La actualidad más candente (20)

Python Basics.pdf
Python Basics.pdfPython Basics.pdf
Python Basics.pdf
 
Python basics
Python basicsPython basics
Python basics
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
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)
 
Python Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | EdurekaPython Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | Edureka
 
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | EdurekaPython Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Python basics
Python basicsPython basics
Python basics
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Introduction To Python | Edureka
Introduction To Python | EdurekaIntroduction To Python | Edureka
Introduction To Python | Edureka
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming Language
 
Python
PythonPython
Python
 
Python ppt
Python pptPython ppt
Python ppt
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Python Data-Types
Python Data-TypesPython Data-Types
Python Data-Types
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-python
 
programming with python ppt
programming with python pptprogramming with python ppt
programming with python ppt
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
Python presentation by Monu Sharma
Python presentation by Monu SharmaPython presentation by Monu Sharma
Python presentation by Monu Sharma
 

Similar a Introduction to python

1. python programming
1. python programming1. python programming
1. python programmingsreeLekha51
 
introduction to python
 introduction to python introduction to python
introduction to pythonJincy Nelson
 
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdfPy-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdfshetoooelshitany74
 
Chapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptxChapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptxlemonchoos
 
Python for katana
Python for katanaPython for katana
Python for katanakedar nath
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdfsamiwaris2
 
Learn Python The Hard Way Presentation
Learn Python The Hard Way PresentationLearn Python The Hard Way Presentation
Learn Python The Hard Way PresentationAmira ElSharkawy
 
Engineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptxEngineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptxhardii0991
 
presentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptxpresentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptxansariparveen06
 

Similar a Introduction to python (20)

Python-Basics.pptx
Python-Basics.pptxPython-Basics.pptx
Python-Basics.pptx
 
Python Programming 1.pptx
Python Programming 1.pptxPython Programming 1.pptx
Python Programming 1.pptx
 
1. python programming
1. python programming1. python programming
1. python programming
 
introduction to python
 introduction to python introduction to python
introduction to python
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdfPy-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
 
Chapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptxChapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptx
 
Python 01.pptx
Python 01.pptxPython 01.pptx
Python 01.pptx
 
intro to python.pptx
intro to python.pptxintro to python.pptx
intro to python.pptx
 
Python for katana
Python for katanaPython for katana
Python for katana
 
unit1 python.pptx
unit1 python.pptxunit1 python.pptx
unit1 python.pptx
 
Python Demo.pptx
Python Demo.pptxPython Demo.pptx
Python Demo.pptx
 
Unit-I-PPT-1.ppt
Unit-I-PPT-1.pptUnit-I-PPT-1.ppt
Unit-I-PPT-1.ppt
 
Python Demo.pptx
Python Demo.pptxPython Demo.pptx
Python Demo.pptx
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdf
 
17575602.ppt
17575602.ppt17575602.ppt
17575602.ppt
 
Learn Python The Hard Way Presentation
Learn Python The Hard Way PresentationLearn Python The Hard Way Presentation
Learn Python The Hard Way Presentation
 
Engineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptxEngineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptx
 
presentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptxpresentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptx
 
Python programming
Python programmingPython programming
Python programming
 

Último

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Último (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Introduction to python

  • 2. • What is Python? • Features of Python • Who uses Python? • Applications • How to download python • Working with interactive prompt • Dynamic • Identifiers • Keywords • Python Syntax CONTENTS (Day1)
  • 3. • Python is a general purpose, dynamic, high-level, and interpreted programming language. • Created by Guido Van Rossum in 1989. What is Python
  • 4. 1) Easy to Learn and Use 2) Expressive Language 3) Interpreted Language 4) Cross-platform Language 5) Free and Open Source-https://www.python.org/ 6) Object-Oriented Language 7) Extensible 8) Large Standard Library 9) GUI Programming Support 10) Integrated Python Features
  • 8.
  • 9.
  • 13.
  • 14. • When assigning to a variable, we do not need to declare the data type of the values it will hold. This is decided by the interpreter at runtime. • We do not declare a variable, we directly assign to it. Python is Dynamically-Typed
  • 15. • A variable name is called an identifier and has to follow some rules: • Variables can have letters (A-Z and a-z), digits(0-9) and underscores. • It cannot begin with an underscore (_) or a digit. • It cannot have whitespace and signs like + and -, !, @, $, #, %. • It cannot be a reserved keyword for Python. • Variable names are case sensitive. Identifiers
  • 16. • These are 33 reserved words. • You cannot use a word from this list as a name for your variable or function. • Python variable names are case-sensitive. The variable ‘name’ is different than the variable ‘Name’ Reserved Keywords
  • 17. • The term syntax is referred to a set of rules and principles that describes the structure of a language. Python Syntax
  • 18. A Python program comprises logical lines. A NEWLINE token follows each of those. The interpreter ignores blank lines. The following line causes an error. >>> print("Hi How are you?") Output: SyntaxError: EOL while scanning string literal Python Line Structure
  • 19. • This one is an important Python syntax. • We saw that Python does not mandate semicolons. • A new line means a new statement. But sometimes, you may want to split a statement over two or more lines. Python Multiline Statements
  • 20. • A docstring is a documentation string. • As a comment, this Python Syntax is used to explain code. • But unlike comments, they are more specific. Also, they are retained at runtime. This way, the programmer can inspect them at runtime. """ This function prints out a greeting """ print("Hi") Python Docstrings
  • 21. • Python doesn’t use curly braces to delimit blocks of code, this Python Syntax is mandatory. • You can indent code under a function, loop, or class. • >>> if 2>1: print("2 is the bigger person"); print("But 1 is worthy too"); Python Indentation
  • 22. You can also fit in more than one statement on one line. Do this by separating them with a semicolon. >>> a=7;print(a); Python Multiple Statements in One Line
  • 23. Python supports the single quote and the double quote for string literals. But if you begin a string with a single quote, you must end it with a single quote. The same goes for double-quotes. • >>> print('We need a break'); • >>> print("We need a ‘break'"); Python Quotations
  • 24. • You can use the % operator to format a string to contain text as well as values of identifiers. • Use %s where you want a value to appear. After the string, put a % operator and mention the identifiers in parameters. Python String Formatters I just printed 10 pages to the printer HP
  • 26. • You can use the % operator to format a string to contain text as well as values of identifiers. • Use %s where you want a value to appear. After the string, put a % operator and mention the identifiers in parameters. Python String Formatters I just printed 10 pages to the printer HP
  • 27. Python Syntax ‘Comments’ let you store tags at the right places in the code. You can use them to explain complex sections of code. The interpreter ignores comments. Declare a comment using an Hash(#). >>>#this is a comment line Python Comments
  • 28. • Python allows us to assign a value to multiple variables in a single statement which is also known as multiple assignment. • We can apply multiple assignments in two ways either by assigning a single value to multiple variables or • assigning multiple values to multiple variables. Multiple Assignment
  • 35. Python Data Types • Variables can hold values of different data types. • Python is a dynamically typed language hence we need not define the type of the variable while declaring it. • The interpreter implicitly binds the value with its type.
  • 36. Python Data Types • python enables us to check the type of the variable used in the program. • Python provides us the type() function which returns the type of the variable passed.
  • 37. Python Data Types Python data types are categorized into two as follows: Mutable Data Types: Data types in python where the value assigned to a variable can be changed Immutable Data Types: Data types in python where the value assigned to a variable cannot be changed
  • 39. Python-Numbers • Number data types store numeric values. • They are immutable data types, means that changing the value of a number data type is not possible. • For example − • var1 = 1 var2 = 10 • You can also delete the reference to a number object by using the del statement. • Del var1
  • 40. Python-Numbers • Python supports four different numerical types − • int (signed integers) − They are often called just integers or ints, are positive or negative whole numbers with no decimal point. • Long (long integers ) − Also called longs, they are integers of unlimited size, written like integers and followed by an uppercase or lowercase L. • float (floating point real values) − Also called floats, they represent real numbers and are written with a decimal point dividing the integer and fractional parts. • complex (complex numbers) − are of the form a + bJ, where a and b are floats and J (or j) represents the square root of -1 (which is an imaginary number).
  • 41. Number Type Conversion • But sometimes, you need to convert a number explicitly from one type to another to satisfy the requirements of an operator or function parameter. • Type int(x) to convert x to a plain integer. • Type long(x) to convert x to a long integer. • Type float(x) to convert x to a floating-point number. • Type complex(x) to convert x to a complex number with real part x and imaginary part zero. • Type complex(x, y) to convert x and y to a complex number with real part x and imaginary part y. x and y are numeric expressions
  • 43. Strings • Strings are amongst the most popular types in Python. • We can create them simply by enclosing characters in quotes. Python treats single quotes the same as double quotes. • var1 = 'Hello World!‘ • var2 = "Python Programming"
  • 44. Accessing Values in Strings • Python does not support a character type; these are treated as strings of length one, thus also considered a substring. • To access substrings, use the square brackets for slicing along with the index or indices to obtain your substring.
  • 45. Updating Strings • You can "update" an existing string by (re)assigning a variable to another string. The new value can be related to its previous value or to a completely different string altogether.
  • 48. Python Lists • Lists are the most versatile of Python's compound data types. • A list contains items separated by commas and enclosed within square brackets ([]). • To some extent, lists are similar to arrays in C. • One difference between them is that all the items belonging to a list can be of different data type.
  • 50. Python Tuples • A tuple is another sequence data type that is similar to the list. • A tuple consists of a number of values separated by commas. • Unlike lists, however, tuples are enclosed within parentheses. • The main differences between lists and tuples are: Lists are enclosed in brackets ( [ ] ) and their elements and size can be changed, • while tuples are enclosed in parentheses ( ( ) ) and cannot be updated. • Tuples can be thought of as read-only lists.
  • 52. Python Dictionary • A Python dictionary is a mapping of unique keys to values. Dictionaries are mutable, which means they can be changed. • Dictionaries are enclosed by curly braces ({ }) and values can be assigned and accessed using square braces ([]).
  • 53. Python Dictionary dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'} Print( "dict['Name']: ", dict['Name']) print ("dict['Age']: ", dict['Age'])
  • 54. Dictionary Functions • Len-The method len() gives the total length of the dictionary. • dict = {'Name': 'Zara', 'Age': 7}; • print (len(dict)) • Copy-The method copy() returns a shallow copy of the dictionary. • dict1 = {'Name': 'Zara', 'Age': 7}; • dict2 = dict1.copy() • print "New Dictionary : %s" % str(dict2)
  • 55.
  • 56. • Keys-The method keys() returns a list of all the available keys in the dictionary. • my_dict = {'name':'Jack', 'age': 26} • print "Value : %s" % dict.keys() • Values-The method values() returns a list of all the values available in a given dictionary. • print "Value : %s" % dict.values()
  • 57.
  • 58. Set in Python • A set is an unordered collection of items. • Every element is unique (no duplicates) and must be immutable (which cannot be changed). • my_set = {1, 2, 3} • print(my_set)
  • 59. Change a set in Python • Sets are mutable. But since they are unordered, indexing have no meaning. • We can add single element using the add() method and multiple elements using the update() method. • The update() method can take tuples, lists, strings or other sets as its argument. In all cases, duplicates are avoided.
  • 60.
  • 61. Remove elements from a set • A particular item can be removed from set using methods, discard() and remove(). • The only difference between the two is that, while using discard() if the item does not exist in the set, it remains unchanged. • But remove() will raise an error in such condition. • my_set.discard(4) • print(my_set) • my_set.remove(4)