SlideShare a Scribd company logo
1 of 43
UNIT I
INTRODUCTION AND SYNTAX
OF PYTHON PROGRAM
Mrs. AISHWARYA B. BOLEGAVE
Agenda
 What is Python?….
 History of Python
 Features
 Uses of Python in industry
 Python Building Blocks
 Python environment setup
 Simple Python program
 PyCharm IDE installtion
 Python Data Types
What is Python
 Python is a high-level, general-purpose and a very
popular programming language.
 Python is an interpreted, interactive and object
oriented language.
History of Python
 The idea of Python started in late 1980S
 Real implementation of Python was started in
December 1989
 Finally published in February 1990(Netherland) by
Guido van Rossum , and released.
 Picked ‘Python’ name- comedy show(Monty Python’s
flying circus).
Features
 Following are features of Python –
 Interactive
 Object -oriented
 Interpreted
 Platform independent
 Automatic memory management
 free and open source
 readability
 dynamically typed
Uses of Python in industry
 Python uses in Central Intelligence Agency (CIA)
 Google's first search engine
 Facebook (in their production engineering)
 NASA uses Workflow Automation Tool which is written in
python
 Nokia uses python for its platform s60
 The entire stack of dropbox was written in python
Dropbox.
 Quora is social commenting site which is written in
python.
 Instagram (uses python for front end).
 YouTube
Python Building Blocks
 Python Identifiers:
All the variables, class, object, functions, lists,
dictionaries etc. in Python are known as Identifiers.
 Rules for giving identifier:
1. Case sensitive.(num and Num both are different
functions)
2. Name should not be keyword.
3. Name can begin with letter or underscore(_) only
4. contains both numbers and letters along with
underscores (A-z, 0-9, and _ ).
Python Building Blocks
 Variable: A variable is nothing but a reserved memory
location to store values.
 Rules for variable names same as identifiers.
 Ex. valid invalid
name 1name
Full_name Full name
_4(meaningless) 123name
_string break
Var_123 @city
 Variables
Do not require explicit declaration.
other programming language Python language
int a=20; a=20
Allows to assign value to multiple variables
a1=a2=a3=a4=30
Allows to assign sequence of values to sequence of
variables
s1,s2,s3=10,20,30
 Keywords:
1. The keywords are special words reserved for some
purpose.
2. The names of keywords can be not be used as
variable name.
 Keywords are as follows:
 Indentation
 refers to the spaces at the beginning of a code line.
Python uses indentation to indicate a block of code.
 For example –
age = 1
if age <= 2:
print(' true')
Output: True
indent
 Comments
Comments can be used to explain Python code.
In Python, we use the hash (#) symbol to start writing
a comment.
ex. A=12 #value 12 assign to variable a
Python Interpreter ignores comment.
For multiple line comments uses three single quotes (‘’’
……..‘’’) three double quotes (””” ……“””).
Python Environmental Setup
1. First, download the latest version of Python from the
official website. I have downloaded python 3.10.2
version. For that purpose open the web site
https://www.python.org
Download this version
2. Now Select the file based on processor of your PC. For Windows
it can be 32 bit or 64 bit. If it is 64 bit then select the file as
follows
3. Downloaded in my pc
4. Just check the Add path checkbox and
click on customize installation
5.Check features and click on next button
Click on next
Click on install for all users and install
button
Click on
Finally you will get successful
installation message.
Go to command propmt
6. click on Python or IDLE to get the shell
prompt. I use Python IDLE. The shell prompt appears as
follows —
7. The python shell will be displayed and >>>
prompt will be displayed
Write a simple first program
Modes of Working in Python
 1) Interactive mode- gives immediate feedback for
each statement. Fed statements are stored in active
memory.
 2) Script mode- python commands are stored in a file
and the file is saved using the extension .py
For new file
Creating new file and save as test.py
test.py
Output(test.py)
Program for practice
1. Running Simple Python program to Display multiple
lines Message(script mode)
2. Running Simple Python to Display 'welcome'
Message(interactive mode)
Download PyCharm IDE also
Download
community
PyCharm community setup
Click on next button and installing
pycharm
Check this
checkbox
Creating new project
Python Data Types
 Data types are used to define type of variable.
Data types
numeric Strings Tuples Lists Dictionary
Python Data Types
1) Numeric/Numbers:
 Number stores numeric values.
 The integer, long, float, and complex values belong to a Python
Numbers data-type.
 type() function to know the data-type of the variable.
 isinstance() function is used to check an object belongs to a
particular class.
num=10
a=54.3 #float number
B=0o2345 #octal number
Bin=0b10101 #bin number
hex=0x4325 #hex. number
X+yj=3+6j #complex
Numeric values(integer, float, complex) assigned to
variables
Output
2) String :
 String is a collection of characters.
 uses single quote(‘…’), double quote (“….”)or triple quote
(”””…..”””)to define a string.
 We can use three operators along with the string is slicing
operator[] or[:],concatenate operator(+), repetition operator *.
ex. >>> strl="My"
>>> str2="Python“
>>> print (str2[0]) #slicing operator
output: P
>>> print (str2)
>>>Python
>>> print (strl+str2) # concatenate operator
output: MyPython
>>> print (str2*3) # repetition operator
output: PythonPythonPython
‘”””Python””””
3) List :
 similar to array in C or C++ but it can simultaneously
hold different types of data in list.
 It is basically an ordered sequence of some data
written using square brackets([]) and commas(,).
 Ex. -
>>> #List of only strings
>>> b=["Sun", "Mon”, “Tue", "Wed“]
>>> print (b)
output: ['Sun', 'Mon', 'Tue', 'Wed']
Like string Same
operators use in list-
slicing operator[] or [:],
concatenate
operator(+), repetition
operator(*)
4) Tuple :
 collection of elements and it is similar to the List.
 But the items of the tuple are separated by comma(,)
and the elements are enclosed in ( ) parenthesis.
 Tuples are immutable.(can not change value)
 Ex.->>> #Tuple of both integers and strings
>>> b=(“one”,1, 2, "two", "three", 3)
>>> print (b)
output: ('one', 1, 2, ‘two', 'three',3)
>>> print (b[3]) # slicing operator
output: two
Like string Same
operators use in list-
slicing operator[] or [:],
concatenate
operator(+), repetition
operator(*)
5) Dictionary
 collection of elements in the form of key:value pair.
for example-{1:’Red’, 2:’black’}
 dictionaries are like a hash-table that has pair of
index(key) and element(value).
 present in the curly brackets.
 Ex. – dict={1:’red’,2:’blue’,3:’green’}
>>>print(dict)
output:{1:’red’,2:’blue’,3:’green’}
>>>print(dict.keys())
output: dict_keys([1,2,3])
>>>print(dict.values())
output: dict_values([red,blue,green])
Input through keyboard
 Here, python have built-in function input() to read
input value.
Ex. print(“enter your name”)
name=input()
 The default of read value is string only.
 Type casting is nothing but it convert one data type
(string) into other another data type.
Ex. print(“enter your age”)
name=int(input())

More Related Content

Similar to unit (1)INTRODUCTION TO PYTHON course.pptx

Python Course Basic
Python Course BasicPython Course Basic
Python Course BasicNaiyan Noor
 
Introduction to python.pptx
Introduction to python.pptxIntroduction to python.pptx
Introduction to python.pptxpcjoshi02
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in PythonSumit Satam
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonMaheshPandit16
 
Python Programming | JNTUK | UNIT 1 | Lecture 3
Python Programming | JNTUK | UNIT 1 | Lecture 3Python Programming | JNTUK | UNIT 1 | Lecture 3
Python Programming | JNTUK | UNIT 1 | Lecture 3FabMinds
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| FundamentalsMohd Sajjad
 
Python PPT by Sushil Sir.pptx
Python PPT by Sushil Sir.pptxPython PPT by Sushil Sir.pptx
Python PPT by Sushil Sir.pptxsushil155005
 
James Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on PythonJames Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on PythonCP-Union
 
Hands on Session on Python
Hands on Session on PythonHands on Session on Python
Hands on Session on PythonSumit Raj
 
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
 
Chapter 1 Class 12 Computer Science Unit 1
Chapter 1 Class 12 Computer Science Unit 1Chapter 1 Class 12 Computer Science Unit 1
Chapter 1 Class 12 Computer Science Unit 1ssusera7a08a
 

Similar to unit (1)INTRODUCTION TO PYTHON course.pptx (20)

Python Course Basic
Python Course BasicPython Course Basic
Python Course Basic
 
Python programming
Python programmingPython programming
Python programming
 
Introduction to python.pptx
Introduction to python.pptxIntroduction to python.pptx
Introduction to python.pptx
 
Python unit1
Python unit1Python unit1
Python unit1
 
Python Session - 2
Python Session - 2Python Session - 2
Python Session - 2
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in Python
 
Core Python.doc
Core Python.docCore Python.doc
Core Python.doc
 
Python for Beginners(v1)
Python for Beginners(v1)Python for Beginners(v1)
Python for Beginners(v1)
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python
PythonPython
Python
 
Python Programming | JNTUK | UNIT 1 | Lecture 3
Python Programming | JNTUK | UNIT 1 | Lecture 3Python Programming | JNTUK | UNIT 1 | Lecture 3
Python Programming | JNTUK | UNIT 1 | Lecture 3
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| Fundamentals
 
Python PPT by Sushil Sir.pptx
Python PPT by Sushil Sir.pptxPython PPT by Sushil Sir.pptx
Python PPT by Sushil Sir.pptx
 
James Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on PythonJames Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on Python
 
Python Course.docx
Python Course.docxPython Course.docx
Python Course.docx
 
Hands on Session on Python
Hands on Session on PythonHands on Session on Python
Hands on Session on Python
 
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...
 
Chapter 1 Class 12 Computer Science Unit 1
Chapter 1 Class 12 Computer Science Unit 1Chapter 1 Class 12 Computer Science Unit 1
Chapter 1 Class 12 Computer Science Unit 1
 

Recently uploaded

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
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
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
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
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
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
 

Recently uploaded (20)

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
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
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
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
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
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
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 

unit (1)INTRODUCTION TO PYTHON course.pptx

  • 1. UNIT I INTRODUCTION AND SYNTAX OF PYTHON PROGRAM Mrs. AISHWARYA B. BOLEGAVE
  • 2. Agenda  What is Python?….  History of Python  Features  Uses of Python in industry  Python Building Blocks  Python environment setup  Simple Python program  PyCharm IDE installtion  Python Data Types
  • 3. What is Python  Python is a high-level, general-purpose and a very popular programming language.  Python is an interpreted, interactive and object oriented language.
  • 4. History of Python  The idea of Python started in late 1980S  Real implementation of Python was started in December 1989  Finally published in February 1990(Netherland) by Guido van Rossum , and released.  Picked ‘Python’ name- comedy show(Monty Python’s flying circus).
  • 5. Features  Following are features of Python –  Interactive  Object -oriented  Interpreted  Platform independent  Automatic memory management  free and open source  readability  dynamically typed
  • 6. Uses of Python in industry  Python uses in Central Intelligence Agency (CIA)  Google's first search engine  Facebook (in their production engineering)  NASA uses Workflow Automation Tool which is written in python  Nokia uses python for its platform s60  The entire stack of dropbox was written in python Dropbox.  Quora is social commenting site which is written in python.  Instagram (uses python for front end).  YouTube
  • 7. Python Building Blocks  Python Identifiers: All the variables, class, object, functions, lists, dictionaries etc. in Python are known as Identifiers.  Rules for giving identifier: 1. Case sensitive.(num and Num both are different functions) 2. Name should not be keyword. 3. Name can begin with letter or underscore(_) only 4. contains both numbers and letters along with underscores (A-z, 0-9, and _ ).
  • 8. Python Building Blocks  Variable: A variable is nothing but a reserved memory location to store values.  Rules for variable names same as identifiers.  Ex. valid invalid name 1name Full_name Full name _4(meaningless) 123name _string break Var_123 @city
  • 9.  Variables Do not require explicit declaration. other programming language Python language int a=20; a=20 Allows to assign value to multiple variables a1=a2=a3=a4=30 Allows to assign sequence of values to sequence of variables s1,s2,s3=10,20,30
  • 10.  Keywords: 1. The keywords are special words reserved for some purpose. 2. The names of keywords can be not be used as variable name.
  • 11.  Keywords are as follows:
  • 12.  Indentation  refers to the spaces at the beginning of a code line. Python uses indentation to indicate a block of code.  For example – age = 1 if age <= 2: print(' true') Output: True indent
  • 13.  Comments Comments can be used to explain Python code. In Python, we use the hash (#) symbol to start writing a comment. ex. A=12 #value 12 assign to variable a Python Interpreter ignores comment. For multiple line comments uses three single quotes (‘’’ ……..‘’’) three double quotes (””” ……“””).
  • 14. Python Environmental Setup 1. First, download the latest version of Python from the official website. I have downloaded python 3.10.2 version. For that purpose open the web site https://www.python.org
  • 16. 2. Now Select the file based on processor of your PC. For Windows it can be 32 bit or 64 bit. If it is 64 bit then select the file as follows
  • 18. 4. Just check the Add path checkbox and click on customize installation
  • 19. 5.Check features and click on next button Click on next
  • 20. Click on install for all users and install button Click on
  • 21. Finally you will get successful installation message.
  • 22. Go to command propmt
  • 23. 6. click on Python or IDLE to get the shell prompt. I use Python IDLE. The shell prompt appears as follows —
  • 24. 7. The python shell will be displayed and >>> prompt will be displayed
  • 25. Write a simple first program
  • 26. Modes of Working in Python  1) Interactive mode- gives immediate feedback for each statement. Fed statements are stored in active memory.  2) Script mode- python commands are stored in a file and the file is saved using the extension .py
  • 28. Creating new file and save as test.py test.py
  • 30. Program for practice 1. Running Simple Python program to Display multiple lines Message(script mode) 2. Running Simple Python to Display 'welcome' Message(interactive mode)
  • 31. Download PyCharm IDE also Download community
  • 33. Click on next button and installing pycharm Check this checkbox
  • 35. Python Data Types  Data types are used to define type of variable. Data types numeric Strings Tuples Lists Dictionary
  • 36. Python Data Types 1) Numeric/Numbers:  Number stores numeric values.  The integer, long, float, and complex values belong to a Python Numbers data-type.  type() function to know the data-type of the variable.  isinstance() function is used to check an object belongs to a particular class. num=10 a=54.3 #float number B=0o2345 #octal number Bin=0b10101 #bin number hex=0x4325 #hex. number X+yj=3+6j #complex
  • 37. Numeric values(integer, float, complex) assigned to variables
  • 39. 2) String :  String is a collection of characters.  uses single quote(‘…’), double quote (“….”)or triple quote (”””…..”””)to define a string.  We can use three operators along with the string is slicing operator[] or[:],concatenate operator(+), repetition operator *. ex. >>> strl="My" >>> str2="Python“ >>> print (str2[0]) #slicing operator output: P >>> print (str2) >>>Python >>> print (strl+str2) # concatenate operator output: MyPython >>> print (str2*3) # repetition operator output: PythonPythonPython ‘”””Python””””
  • 40. 3) List :  similar to array in C or C++ but it can simultaneously hold different types of data in list.  It is basically an ordered sequence of some data written using square brackets([]) and commas(,).  Ex. - >>> #List of only strings >>> b=["Sun", "Mon”, “Tue", "Wed“] >>> print (b) output: ['Sun', 'Mon', 'Tue', 'Wed'] Like string Same operators use in list- slicing operator[] or [:], concatenate operator(+), repetition operator(*)
  • 41. 4) Tuple :  collection of elements and it is similar to the List.  But the items of the tuple are separated by comma(,) and the elements are enclosed in ( ) parenthesis.  Tuples are immutable.(can not change value)  Ex.->>> #Tuple of both integers and strings >>> b=(“one”,1, 2, "two", "three", 3) >>> print (b) output: ('one', 1, 2, ‘two', 'three',3) >>> print (b[3]) # slicing operator output: two Like string Same operators use in list- slicing operator[] or [:], concatenate operator(+), repetition operator(*)
  • 42. 5) Dictionary  collection of elements in the form of key:value pair. for example-{1:’Red’, 2:’black’}  dictionaries are like a hash-table that has pair of index(key) and element(value).  present in the curly brackets.  Ex. – dict={1:’red’,2:’blue’,3:’green’} >>>print(dict) output:{1:’red’,2:’blue’,3:’green’} >>>print(dict.keys()) output: dict_keys([1,2,3]) >>>print(dict.values()) output: dict_values([red,blue,green])
  • 43. Input through keyboard  Here, python have built-in function input() to read input value. Ex. print(“enter your name”) name=input()  The default of read value is string only.  Type casting is nothing but it convert one data type (string) into other another data type. Ex. print(“enter your age”) name=int(input())