SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
Python
Keep calm it’s python
Below are some facts about Python.
> Python is a widely used general-purpose, high
level programming language.
> Python allows programming in Object Oriented
and Procedural paradigms.
> Python programs generally are smaller than other
programming languages like Java.
> Programmers have to type relatively less and
identation requirement of the language, makes them
readable all the time.
The biggest strength of the Python is large
libarary which can be used for the following
• Machine Learning
• GUI Applications
• Web frameworks like Django (used by YouTube)
• Multimedia
• Image processing
• Test frameworks
• Web scraping
• Scientific computing
• Text processing and many more..
Python Language Introduction
• Python is a widely used general-purpose, high level
programming language. It was initially designed by Guido
van Rossum in 1991 and developed by Python Software
Foundation. It was mainly developed for emphasis on code
readability, and its syntax allows programmers to express
concepts in fewer lines of code.
There are two major Python versions- Python 2
and Python 3. Both are quite different.
• 1) Finding an Interpreter:
• Before we start Python programming, we need to have an interpreter
to interpret and run our programs. There are certain online
interpreters like http://ideone.com/ or http://codepad.org/ that can
be used to start Python without installing an interpreter
• Windows: There are many interpreters available freely to run Python
scripts like IDLE ( Integrated Development Environment ) which is
installed when you install the python software
from http://python.org/
• Linux: For Linux, Python comes bundled with the linux.
Writing first program:
• print(“Hello world my name is piyush rai”)
• We can comment python using #
DATA STRUCTURE AND PYTHON
• In other programming languages like C, C++ and Java,
you will need to declare the type of variables but in
Python you don’t need to do that.
• Just type in the variable and when values will be
given to it, then it will automatically know whether
the value given would be a int, float or char or even a
String.
LIST
• Is the most basic Data Structure in python. List is
mutable data structure i.e items can be added to list
later after the list creation.
• Its like you are going to shop at local market and
made a list of some items and later on you can add
more and more items to the list.
Input and Output
•Now, we will learn how to take input from
the user and hence manipulate it or simply
display it.
•input() function is used to take input from
the user.
Selection
• Selection in Python is made using the two keywords ‘if’
• and
• ‘elif’ and
• else (elseif)
Functions
•You can think of functions like a bunch of
code that is intended to do a particular task
in the whole Python script.
• Python used the keyword ‘def’ to define a
function.
• Now as we know any program starts from a ‘main’
function…lets create a main function like in many other
programming languages.
Iteration Looping
•As the name suggests it calls repeating
things again and again. We will use the most
popular ‘for’ loop here.
Modules
• Python has a very rich module library that has several
functions to do many tasks. You can read more about
Python’s standard library on python.org
• ‘import’ keyword is used to import a particular
module into your python code. For instance consider
the following program.
Python vs Java
Python Java
Dynamically Typed1.No need to declare
anything. An assignment statement binds a
name to an object, and the object can be of
any type.2.No type casting required when
using container objects
Statically Typed 1.All variable names (along
with their types) must be explicitly declared.
Attempting to assign an object of the wrong
type to a variable name triggers a type
exception.2.Type casting is required when
using container objects.
Concise Express much in limited
words
Verbose Contains more words
Compact Less Compact
Uses Indentation for structuring code Uses braces for structuring code
Important differences between Python 2.x
and Python 3.x with examples
• Division operator
• print function
• Unicode
• xrange
• Error Handling
• _future_ module
Keywords in Python
• Python Keywords – Introduction
• This article aims at providing a detailed insight to these
keywords.
• 1. True : This keyword is used to represent a boolean
true. If a statement is true, “True” is printed.
• 2. False : This keyword is used to represent a boolean
false. If a statement is false, “False” is printed.
True and False in python are same as 1 and 0.
Example:
3. None : This is a special constant used to denote a null
value or a void. Its important to remember, 0, any empty
container(e.g empty list) do not compute to None.
It is an object of its own datatype – NoneType. It is not
possible to create multiple None objects and can assign it to
variables.
4. and : This a logical operator in python. “and” Return the
first false value .if not found return last. The truth table for
“and” is depicted below.
5. or : This a logical operator in python. “or” Return
the first True value.if not found return last.The truth
table for “or” is depicted below
6. not : This logical operator inverts the truth
value. The truth table for “not” is depicted
below.
More About input in python
• We can also type cast this input to integer, float or string by
specifying the input() function inside the type.
• Typecasting the input to Integer: There might be conditions
when you might require integer input from user/Console,
the following code takes two input(integer/float) from
console and typecasts them to integer then prints the sum.
• Typecasting the input to Float: To convert the input to float
the following code will work out.
• Typecasting the input to String: All kind of input can be
converted to string type whether they are float or integer.
We make use of keyword str for typecasting.
Taking multiple inputs from user
in Python

Contenu connexe

Tendances

Seminar report on python 3 course
Seminar report on python 3 courseSeminar report on python 3 course
Seminar report on python 3 courseHimanshuPanwar38
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-pythonAakashdata
 
Python quick guide1
Python quick guide1Python quick guide1
Python quick guide1Kanchilug
 
Seminar report On Python
Seminar report On PythonSeminar report On Python
Seminar report On PythonShivam Gupta
 
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEWPYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEWEditorIJAERD
 
Best Python Online Training with Live Project by Expert
Best Python Online Training with Live Project by Expert Best Python Online Training with Live Project by Expert
Best Python Online Training with Live Project by Expert QA TrainingHub
 
Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming pptismailmrribi
 
Intro to Python for Non-Programmers
Intro to Python for Non-ProgrammersIntro to Python for Non-Programmers
Intro to Python for Non-ProgrammersAhmad Alhour
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An IntroductionSwarit Wadhe
 
Python and its Applications
Python and its ApplicationsPython and its Applications
Python and its ApplicationsAbhijeet Singh
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on pythonShubham Yadav
 
Python Crash Course
Python Crash CoursePython Crash Course
Python Crash CourseHaim Michael
 

Tendances (20)

Programming
ProgrammingProgramming
Programming
 
Seminar report on python 3 course
Seminar report on python 3 courseSeminar report on python 3 course
Seminar report on python 3 course
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-python
 
Python quick guide1
Python quick guide1Python quick guide1
Python quick guide1
 
Seminar report On Python
Seminar report On PythonSeminar report On Python
Seminar report On Python
 
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEWPYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
 
Best Python Online Training with Live Project by Expert
Best Python Online Training with Live Project by Expert Best Python Online Training with Live Project by Expert
Best Python Online Training with Live Project by Expert
 
Python Intro
Python IntroPython Intro
Python Intro
 
Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
 
Intro to Python for Non-Programmers
Intro to Python for Non-ProgrammersIntro to Python for Non-Programmers
Intro to Python for Non-Programmers
 
Python Workshop
Python WorkshopPython Workshop
Python Workshop
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
 
Beginning Python Programming
Beginning Python ProgrammingBeginning Python Programming
Beginning Python Programming
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An Introduction
 
Python Tutorial Part 2
Python Tutorial Part 2Python Tutorial Part 2
Python Tutorial Part 2
 
Python and its Applications
Python and its ApplicationsPython and its Applications
Python and its Applications
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on python
 
Python Crash Course
Python Crash CoursePython Crash Course
Python Crash Course
 
Python final ppt
Python final pptPython final ppt
Python final ppt
 

Similaire à Python intro

Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1Ahmet Bulut
 
web programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Malothweb programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh MalothBhavsingh Maloth
 
Tutorial on-python-programming
Tutorial on-python-programmingTutorial on-python-programming
Tutorial on-python-programmingChetan Giridhar
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdfsamiwaris2
 
Fundamentals of python
Fundamentals of pythonFundamentals of python
Fundamentals of pythonBijuAugustian
 
Python for katana
Python for katanaPython for katana
Python for katanakedar nath
 
Python presentation of Government Engineering College Aurangabad, Bihar
Python presentation of Government Engineering College Aurangabad, BiharPython presentation of Government Engineering College Aurangabad, Bihar
Python presentation of Government Engineering College Aurangabad, BiharUttamKumar617567
 
Q-Step_WS_02102019_Practical_introduction_to_Python.pptx
Q-Step_WS_02102019_Practical_introduction_to_Python.pptxQ-Step_WS_02102019_Practical_introduction_to_Python.pptx
Q-Step_WS_02102019_Practical_introduction_to_Python.pptxnyomans1
 
Q-SPractical_introduction_to_Python.pptx
Q-SPractical_introduction_to_Python.pptxQ-SPractical_introduction_to_Python.pptx
Q-SPractical_introduction_to_Python.pptxJeromeTacata3
 
Introduction to Python Programing
Introduction to Python ProgramingIntroduction to Python Programing
Introduction to Python Programingsameer patil
 
Introduction to Python – Learn Python Programming.pptx
Introduction to Python – Learn Python Programming.pptxIntroduction to Python – Learn Python Programming.pptx
Introduction to Python – Learn Python Programming.pptxHassanShah396906
 
Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizeIruolagbePius
 

Similaire à Python intro (20)

Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1
 
web programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Malothweb programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Maloth
 
Python PPT.pptx
Python PPT.pptxPython PPT.pptx
Python PPT.pptx
 
Python Demo.pptx
Python Demo.pptxPython Demo.pptx
Python Demo.pptx
 
Python Demo.pptx
Python Demo.pptxPython Demo.pptx
Python Demo.pptx
 
Tutorial on-python-programming
Tutorial on-python-programmingTutorial on-python-programming
Tutorial on-python-programming
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdf
 
Fundamentals of python
Fundamentals of pythonFundamentals of python
Fundamentals of python
 
Python 01.pptx
Python 01.pptxPython 01.pptx
Python 01.pptx
 
Python for katana
Python for katanaPython for katana
Python for katana
 
Python Module-1.1.pdf
Python Module-1.1.pdfPython Module-1.1.pdf
Python Module-1.1.pdf
 
Python presentation of Government Engineering College Aurangabad, Bihar
Python presentation of Government Engineering College Aurangabad, BiharPython presentation of Government Engineering College Aurangabad, Bihar
Python presentation of Government Engineering College Aurangabad, Bihar
 
Q-Step_WS_02102019_Practical_introduction_to_Python.pptx
Q-Step_WS_02102019_Practical_introduction_to_Python.pptxQ-Step_WS_02102019_Practical_introduction_to_Python.pptx
Q-Step_WS_02102019_Practical_introduction_to_Python.pptx
 
Q-SPractical_introduction_to_Python.pptx
Q-SPractical_introduction_to_Python.pptxQ-SPractical_introduction_to_Python.pptx
Q-SPractical_introduction_to_Python.pptx
 
Introduction to Python Programing
Introduction to Python ProgramingIntroduction to Python Programing
Introduction to Python Programing
 
Introduction to Python – Learn Python Programming.pptx
Introduction to Python – Learn Python Programming.pptxIntroduction to Python – Learn Python Programming.pptx
Introduction to Python – Learn Python Programming.pptx
 
Python Programming 1.pptx
Python Programming 1.pptxPython Programming 1.pptx
Python Programming 1.pptx
 
Python Programming.pptx
Python Programming.pptxPython Programming.pptx
Python Programming.pptx
 
Class_X_PYTHON_J.pdf
Class_X_PYTHON_J.pdfClass_X_PYTHON_J.pdf
Class_X_PYTHON_J.pdf
 
Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualize
 

Dernier

DBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfDBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfChristalin Nelson
 
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFEPART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFEMISSRITIMABIOLOGYEXP
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPCeline George
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroomSamsung Business USA
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxDhatriParmar
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfChristalin Nelson
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6Vanessa Camilleri
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Association for Project Management
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...Nguyen Thanh Tu Collection
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
How to Uninstall a Module in Odoo 17 Using Command Line
How to Uninstall a Module in Odoo 17 Using Command LineHow to Uninstall a Module in Odoo 17 Using Command Line
How to Uninstall a Module in Odoo 17 Using Command LineCeline George
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptxmary850239
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptxDhatriParmar
 

Dernier (20)

DBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfDBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdf
 
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFEPART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERP
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
 
Chi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical VariableChi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical Variable
 
Introduction to Research ,Need for research, Need for design of Experiments, ...
Introduction to Research ,Need for research, Need for design of Experiments, ...Introduction to Research ,Need for research, Need for design of Experiments, ...
Introduction to Research ,Need for research, Need for design of Experiments, ...
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdf
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
 
How to Uninstall a Module in Odoo 17 Using Command Line
How to Uninstall a Module in Odoo 17 Using Command LineHow to Uninstall a Module in Odoo 17 Using Command Line
How to Uninstall a Module in Odoo 17 Using Command Line
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx
 
CARNAVAL COM MAGIA E EUFORIA _
CARNAVAL COM MAGIA E EUFORIA            _CARNAVAL COM MAGIA E EUFORIA            _
CARNAVAL COM MAGIA E EUFORIA _
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
 
Spearman's correlation,Formula,Advantages,
Spearman's correlation,Formula,Advantages,Spearman's correlation,Formula,Advantages,
Spearman's correlation,Formula,Advantages,
 

Python intro

  • 2. Below are some facts about Python. > Python is a widely used general-purpose, high level programming language. > Python allows programming in Object Oriented and Procedural paradigms. > Python programs generally are smaller than other programming languages like Java. > Programmers have to type relatively less and identation requirement of the language, makes them readable all the time.
  • 3. The biggest strength of the Python is large libarary which can be used for the following • Machine Learning • GUI Applications • Web frameworks like Django (used by YouTube) • Multimedia • Image processing • Test frameworks • Web scraping • Scientific computing • Text processing and many more..
  • 4. Python Language Introduction • Python is a widely used general-purpose, high level programming language. It was initially designed by Guido van Rossum in 1991 and developed by Python Software Foundation. It was mainly developed for emphasis on code readability, and its syntax allows programmers to express concepts in fewer lines of code.
  • 5. There are two major Python versions- Python 2 and Python 3. Both are quite different. • 1) Finding an Interpreter: • Before we start Python programming, we need to have an interpreter to interpret and run our programs. There are certain online interpreters like http://ideone.com/ or http://codepad.org/ that can be used to start Python without installing an interpreter • Windows: There are many interpreters available freely to run Python scripts like IDLE ( Integrated Development Environment ) which is installed when you install the python software from http://python.org/ • Linux: For Linux, Python comes bundled with the linux.
  • 6. Writing first program: • print(“Hello world my name is piyush rai”) • We can comment python using #
  • 7. DATA STRUCTURE AND PYTHON • In other programming languages like C, C++ and Java, you will need to declare the type of variables but in Python you don’t need to do that. • Just type in the variable and when values will be given to it, then it will automatically know whether the value given would be a int, float or char or even a String.
  • 8. LIST • Is the most basic Data Structure in python. List is mutable data structure i.e items can be added to list later after the list creation. • Its like you are going to shop at local market and made a list of some items and later on you can add more and more items to the list.
  • 9. Input and Output •Now, we will learn how to take input from the user and hence manipulate it or simply display it. •input() function is used to take input from the user.
  • 10. Selection • Selection in Python is made using the two keywords ‘if’ • and • ‘elif’ and • else (elseif)
  • 11. Functions •You can think of functions like a bunch of code that is intended to do a particular task in the whole Python script. • Python used the keyword ‘def’ to define a function. • Now as we know any program starts from a ‘main’ function…lets create a main function like in many other programming languages.
  • 12. Iteration Looping •As the name suggests it calls repeating things again and again. We will use the most popular ‘for’ loop here.
  • 13. Modules • Python has a very rich module library that has several functions to do many tasks. You can read more about Python’s standard library on python.org • ‘import’ keyword is used to import a particular module into your python code. For instance consider the following program.
  • 14. Python vs Java Python Java Dynamically Typed1.No need to declare anything. An assignment statement binds a name to an object, and the object can be of any type.2.No type casting required when using container objects Statically Typed 1.All variable names (along with their types) must be explicitly declared. Attempting to assign an object of the wrong type to a variable name triggers a type exception.2.Type casting is required when using container objects. Concise Express much in limited words Verbose Contains more words Compact Less Compact Uses Indentation for structuring code Uses braces for structuring code
  • 15. Important differences between Python 2.x and Python 3.x with examples • Division operator • print function • Unicode • xrange • Error Handling • _future_ module
  • 16. Keywords in Python • Python Keywords – Introduction • This article aims at providing a detailed insight to these keywords. • 1. True : This keyword is used to represent a boolean true. If a statement is true, “True” is printed. • 2. False : This keyword is used to represent a boolean false. If a statement is false, “False” is printed. True and False in python are same as 1 and 0. Example:
  • 17. 3. None : This is a special constant used to denote a null value or a void. Its important to remember, 0, any empty container(e.g empty list) do not compute to None. It is an object of its own datatype – NoneType. It is not possible to create multiple None objects and can assign it to variables. 4. and : This a logical operator in python. “and” Return the first false value .if not found return last. The truth table for “and” is depicted below.
  • 18. 5. or : This a logical operator in python. “or” Return the first True value.if not found return last.The truth table for “or” is depicted below 6. not : This logical operator inverts the truth value. The truth table for “not” is depicted below.
  • 19. More About input in python • We can also type cast this input to integer, float or string by specifying the input() function inside the type. • Typecasting the input to Integer: There might be conditions when you might require integer input from user/Console, the following code takes two input(integer/float) from console and typecasts them to integer then prints the sum. • Typecasting the input to Float: To convert the input to float the following code will work out. • Typecasting the input to String: All kind of input can be converted to string type whether they are float or integer. We make use of keyword str for typecasting.
  • 20. Taking multiple inputs from user in Python