SlideShare una empresa de Scribd logo
1 de 18
Descargar para leer sin conexión
BASICS OF PYTHON
PROGRAMMING
Prepared by
Mrs. Deepa S.Rengade
Asstt. Prof.
python
• Simple
– Python is a simple and minimalistic language in nature
– Reading a good python program should be like reading
English
– Its Pseudo-code nature allows one to concentrate on the
problem rather than the language
• Easy to Learn
• Free & Open source
– Freely distributed and Open source
– Maintained by the Python community
• High Level Language –memory management
• Portable – *runs on anything c code will
10/18/19 Programming and problem solving 2
python
• Interpreted
– You run the program straight from the source code.
– Python program Bytecode a platforms native language
– You can just copy over your code to another system and it will
auto-magically work! *with python platform
• Object-Oriented
– Simple and additionally supports procedural programming
• Extensible – easily import other code
• Embeddable –easily place your code in non-python programs
• Extensive libraries
– (i.e. reg. expressions, doc generation, CGI, ftp, web browsers,
ZIP, WAV, cryptography, etc...) (wxPython, Twisted, Python
Imaging library)
10/18/19 Programming and problem solving 3
python Timeline/History
• Python was conceived in the late 1980s.
– Guido van Rossum, Benevolent Dictator For Life
– Rossum is Dutch, born in Netherlands, Christmas break
bored, big fan of Monty python’s Flying Circus
– Descendant of ABC, he wrote glob() func in UNIX
– M.D. @ U of Amsterdam, worked for CWI, NIST, CNRI, Google
– Also, helped develop the ABC programming language
• In 1991 python 0.9.0 was published and reached the
masses through alt.sources
• In January of 1994 python 1.0 was released
– Functional programming tools like lambda, map, filter, and
reduce
– comp.lang.python formed, greatly increasing python’s
userbase
10/18/19 Programming and problem solving 4
python Timeline/History
• In 1995, python 1.2 was released.
• By version 1.4 python had several new features
– Keyword arguments (similar to those of common lisp)
– Built-in support for complex numbers
– Basic form of data-hiding through name mangling
(easily bypassed however)
• Computer Programming for Everybody (CP4E) initiative
– Make programming accessible to more people, with basic “literacy”
similar to those required for English and math skills for some jobs.
– Project was funded by DARPA
– CP4E was inactive as of 2007, not so much a concern to get
employees programming “literate”
10/18/19 Programming and problem solving 5
python Timeline/History
• In 2000, Python 2.0 was released.
– Introduced list comprehensions similar to Haskells
– Introduced garbage collection
• In 2001, Python 2.2 was released.
– Included unification of types and classes into one
hierarchy, making pythons object model purely
Object-oriented
– Generators were added(function-like iterator
behavior)
• Standards
– http://www.python.org/dev/peps/pep-0008/
10/18/19 Programming and problem solving 6
Future of Python
• One of the fastest growing language
• Huge user base and constantly growing
• Stable language that is going to stay for long
• Most preferred language of companies such
as Nokia, Youtube,Google,NASA for its easy
syntax
• High speed dynamic language
• Supports for multiple programming
paradigms.
• Has bright future ahead of it supported by
huge community of OS developers
10/18/19 Programming and problem solving 7
Writing& Executing first Python
Program
• Download Python from www.python.org
• Once installed, Python console can be
accessed through
– Command line and running python interpreter
– GUI Software comes with python called IDLE
• Writing program:
– Open an Editor
– write instructions
– save it with extension.py
– Run the interpreter with the commend
python program_name.py
10/18/19 Programming and problem solving 8
Literal Constants
• Value of literal constant directly used in program
• E.g. 7,3,9,’a’,”hello” are literal constant
• They represents itself and nothing else
• Its value cannot be changed
• Numbers:integers,long integers,floating
points,complex numbers
• String:a groupof characters,immutable
• Escape sequences
• E.g a=rings bell, f=prints form feed
character,n=newline,t=prints tab,o=octal
value,x=hex value,=backslash,’=single
quote,”=doublequote
10/18/19 Programming and problem solving 9
Variables and identifiers
• Variables are reserved memory locations that
stores values.
• Each variable is given appropriate name.
• variables are example of identifiers
• Identifiers are names given to identify something.
• So it can be a variable, function, class, modules
etc.
• Valid identifiers: sum,_myvar,num1,var_20,a etc.
• Invalid identifiers:1num,my-var,%check,basic
sal .
• Python is a case sensitive language.
10/18/19 Programming and problem solving 10
Datatypes
• Variables can hold values of different types
called datatypes.
• Numbers, strings, list, tuple, dictionary
• Initializing values to variables e.g.
a=7,code=‘a’,amt=123.45 etc.
• Multiple assignment e.g. a=b=flag=0
• Assign different values to multiple variables
simultaneously e.g. sum,a,b,msg=0,3,5,”rest”
• Multiple statements on a single line usingsemi
colon.
• Boolean: datatype in python and can have
one of two values-True or False.
10/18/19 Programming and problem solving 11
Input Operation and
Comments
• Input() fuction= to take input from user
• It always take input as a string
• E.g. name=input(“what is your name?”)
• E.g age=input(“enter your age:”)
• Comments are non executable statements
• Added to describe staatements of program
• Characters following the# and upto end of
line are part of comment
• E.g. print(“hello”) #to display hello
• Output: hello
10/18/19 Programming and problem solving 12
Reserved words
• In every programming language there are
certain words which have predefined
meaning called keywords or reserved words
cannot be used for naming identifiers.
• E.g.break,class,if,else,elif,for,from,print,retu
rn
• All the python keywords contain lowercase
letters only.
• 33 keywords in python 3.7.
10/18/19 Programming and problem solving 13
Indentation
• Indentation is used to define a block of
code
• Block of code begins with indentation and
ends with the first unindented line.
• Usually four white spaces are referred for
indentation.
• E.g
no=10
If(no==10):
print(“no is 10”)
Output : no is 10
10/18/19 Programming and problem solving 14
Operators and Expressions
• Arithmetic operators: +,-,*,/,%,**,//
• Assignment operators : =,+=,-=,*=,/=,
%=,//=, **=,&=,|=, ^=,>>=, <<=
• Comparison operators: ==,!
=,>,<,>=,<=
• Logical operators:
and –returns true if both statements are true
or- returns true if one of the statement is true
not-returns false if the result is true
10/18/19 Programming and problem solving 15
Operators and Expressions
• Identity operators:
is – returns true if both variables are the same object
Is not – returns true if both variables are not the same object
• Membership operators:
In – returns true if a sequence with the specified value is
present in the object
Not in-– returns true if a sequence with the specified value is
not present in the object
• Bitwise operators:
• & AND
• | OR
• ^ XOR
• ~ NOT
• << left shift
• >> right shift
10/18/19 Programming and problem solving 16
Expressions in Python
• An expression is combination of
value, variables and operators.
• Expression appear on the right hand
side of assignment operator.
• E.g. add=a+b
• Sub=a-b
10/18/19 Programming and problem solving 17
THANK YOU
10/18/19 Programming and problem solving 18

Más contenido relacionado

La actualidad más candente

Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1Ahmet Bulut
 
Python: The Programmer's Lingua Franca
Python: The Programmer's Lingua FrancaPython: The Programmer's Lingua Franca
Python: The Programmer's Lingua FrancaActiveState
 
Python quick guide1
Python quick guide1Python quick guide1
Python quick guide1Kanchilug
 
20120314 changa-python-workshop
20120314 changa-python-workshop20120314 changa-python-workshop
20120314 changa-python-workshopamptiny
 
Summer Training Project On Python Programming
Summer Training Project On Python ProgrammingSummer Training Project On Python Programming
Summer Training Project On Python ProgrammingKAUSHAL KUMAR JHA
 
Before Starting Python Programming Language
Before Starting Python Programming LanguageBefore Starting Python Programming Language
Before Starting Python Programming LanguageKishan Tongrao
 
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAChapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAMaulik Borsaniya
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming LanguageLaxman Puri
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An IntroductionSwarit Wadhe
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programmingSrinivas Narasegouda
 
Type hints in python & mypy
Type hints in python & mypyType hints in python & mypy
Type hints in python & mypyAnirudh
 
Python presentation
Python presentationPython presentation
Python presentationgaganapponix
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python ProgrammingAkhil Kaushik
 
Introduction to Python Programing
Introduction to Python ProgramingIntroduction to Python Programing
Introduction to Python Programingsameer patil
 

La actualidad más candente (20)

Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
Python
PythonPython
Python
 
Python: The Programmer's Lingua Franca
Python: The Programmer's Lingua FrancaPython: The Programmer's Lingua Franca
Python: The Programmer's Lingua Franca
 
Python quick guide1
Python quick guide1Python quick guide1
Python quick guide1
 
20120314 changa-python-workshop
20120314 changa-python-workshop20120314 changa-python-workshop
20120314 changa-python-workshop
 
Summer Training Project On Python Programming
Summer Training Project On Python ProgrammingSummer Training Project On Python Programming
Summer Training Project On Python Programming
 
Before Starting Python Programming Language
Before Starting Python Programming LanguageBefore Starting Python Programming Language
Before Starting Python Programming Language
 
Python for All
Python for All Python for All
Python for All
 
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAChapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
 
Programming
ProgrammingProgramming
Programming
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An Introduction
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
Type hints in python & mypy
Type hints in python & mypyType hints in python & mypy
Type hints in python & mypy
 
Python presentation
Python presentationPython presentation
Python presentation
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Getting Started with Python
Getting Started with PythonGetting Started with Python
Getting Started with Python
 
Introduction to Python Programing
Introduction to Python ProgramingIntroduction to Python Programing
Introduction to Python Programing
 

Similar a Unit1 pps

Python Programming1.ppt
Python Programming1.pptPython Programming1.ppt
Python Programming1.pptRehnawilson1
 
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinalProf. Wim Van Criekinge
 
Python_Introduction&DataType.pptx
Python_Introduction&DataType.pptxPython_Introduction&DataType.pptx
Python_Introduction&DataType.pptxHaythamBarakeh1
 
pythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxpythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxRohitKumar639388
 
BASIC_INTRODUCTION_TO_PYTHON_PROGRAMMING.pdf
BASIC_INTRODUCTION_TO_PYTHON_PROGRAMMING.pdfBASIC_INTRODUCTION_TO_PYTHON_PROGRAMMING.pdf
BASIC_INTRODUCTION_TO_PYTHON_PROGRAMMING.pdfashaks17
 
2016 bioinformatics i_python_part_1_wim_vancriekinge
2016 bioinformatics i_python_part_1_wim_vancriekinge2016 bioinformatics i_python_part_1_wim_vancriekinge
2016 bioinformatics i_python_part_1_wim_vancriekingeProf. Wim Van Criekinge
 
4_Introduction to Python Programming.pptx
4_Introduction to Python Programming.pptx4_Introduction to Python Programming.pptx
4_Introduction to Python Programming.pptxGnanesh12
 
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
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonRanjith kumar
 
Python programming
Python programmingPython programming
Python programmingMegha V
 
Python programming language introduction unit
Python programming language introduction unitPython programming language introduction unit
Python programming language introduction unitmichaelaaron25322
 

Similar a Unit1 pps (20)

Plc part 1
Plc part 1Plc part 1
Plc part 1
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
Python Programming1.ppt
Python Programming1.pptPython Programming1.ppt
Python Programming1.ppt
 
Python Module-1.1.pdf
Python Module-1.1.pdfPython Module-1.1.pdf
Python Module-1.1.pdf
 
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
 
P1 2018 python
P1 2018 pythonP1 2018 python
P1 2018 python
 
Python_Introduction&DataType.pptx
Python_Introduction&DataType.pptxPython_Introduction&DataType.pptx
Python_Introduction&DataType.pptx
 
pythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxpythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptx
 
Python training
Python trainingPython training
Python training
 
P1 2017 python
P1 2017 pythonP1 2017 python
P1 2017 python
 
BASIC_INTRODUCTION_TO_PYTHON_PROGRAMMING.pdf
BASIC_INTRODUCTION_TO_PYTHON_PROGRAMMING.pdfBASIC_INTRODUCTION_TO_PYTHON_PROGRAMMING.pdf
BASIC_INTRODUCTION_TO_PYTHON_PROGRAMMING.pdf
 
MODULE 1.pptx
MODULE 1.pptxMODULE 1.pptx
MODULE 1.pptx
 
Python basics
Python basicsPython basics
Python basics
 
2016 bioinformatics i_python_part_1_wim_vancriekinge
2016 bioinformatics i_python_part_1_wim_vancriekinge2016 bioinformatics i_python_part_1_wim_vancriekinge
2016 bioinformatics i_python_part_1_wim_vancriekinge
 
4_Introduction to Python Programming.pptx
4_Introduction to Python Programming.pptx4_Introduction to Python Programming.pptx
4_Introduction to Python Programming.pptx
 
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
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python programming
Python programmingPython programming
Python programming
 
Python programming language introduction unit
Python programming language introduction unitPython programming language introduction unit
Python programming language introduction unit
 

Último

Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spaintimesproduction05
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 

Último (20)

Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 

Unit1 pps

  • 1. BASICS OF PYTHON PROGRAMMING Prepared by Mrs. Deepa S.Rengade Asstt. Prof.
  • 2. python • Simple – Python is a simple and minimalistic language in nature – Reading a good python program should be like reading English – Its Pseudo-code nature allows one to concentrate on the problem rather than the language • Easy to Learn • Free & Open source – Freely distributed and Open source – Maintained by the Python community • High Level Language –memory management • Portable – *runs on anything c code will 10/18/19 Programming and problem solving 2
  • 3. python • Interpreted – You run the program straight from the source code. – Python program Bytecode a platforms native language – You can just copy over your code to another system and it will auto-magically work! *with python platform • Object-Oriented – Simple and additionally supports procedural programming • Extensible – easily import other code • Embeddable –easily place your code in non-python programs • Extensive libraries – (i.e. reg. expressions, doc generation, CGI, ftp, web browsers, ZIP, WAV, cryptography, etc...) (wxPython, Twisted, Python Imaging library) 10/18/19 Programming and problem solving 3
  • 4. python Timeline/History • Python was conceived in the late 1980s. – Guido van Rossum, Benevolent Dictator For Life – Rossum is Dutch, born in Netherlands, Christmas break bored, big fan of Monty python’s Flying Circus – Descendant of ABC, he wrote glob() func in UNIX – M.D. @ U of Amsterdam, worked for CWI, NIST, CNRI, Google – Also, helped develop the ABC programming language • In 1991 python 0.9.0 was published and reached the masses through alt.sources • In January of 1994 python 1.0 was released – Functional programming tools like lambda, map, filter, and reduce – comp.lang.python formed, greatly increasing python’s userbase 10/18/19 Programming and problem solving 4
  • 5. python Timeline/History • In 1995, python 1.2 was released. • By version 1.4 python had several new features – Keyword arguments (similar to those of common lisp) – Built-in support for complex numbers – Basic form of data-hiding through name mangling (easily bypassed however) • Computer Programming for Everybody (CP4E) initiative – Make programming accessible to more people, with basic “literacy” similar to those required for English and math skills for some jobs. – Project was funded by DARPA – CP4E was inactive as of 2007, not so much a concern to get employees programming “literate” 10/18/19 Programming and problem solving 5
  • 6. python Timeline/History • In 2000, Python 2.0 was released. – Introduced list comprehensions similar to Haskells – Introduced garbage collection • In 2001, Python 2.2 was released. – Included unification of types and classes into one hierarchy, making pythons object model purely Object-oriented – Generators were added(function-like iterator behavior) • Standards – http://www.python.org/dev/peps/pep-0008/ 10/18/19 Programming and problem solving 6
  • 7. Future of Python • One of the fastest growing language • Huge user base and constantly growing • Stable language that is going to stay for long • Most preferred language of companies such as Nokia, Youtube,Google,NASA for its easy syntax • High speed dynamic language • Supports for multiple programming paradigms. • Has bright future ahead of it supported by huge community of OS developers 10/18/19 Programming and problem solving 7
  • 8. Writing& Executing first Python Program • Download Python from www.python.org • Once installed, Python console can be accessed through – Command line and running python interpreter – GUI Software comes with python called IDLE • Writing program: – Open an Editor – write instructions – save it with extension.py – Run the interpreter with the commend python program_name.py 10/18/19 Programming and problem solving 8
  • 9. Literal Constants • Value of literal constant directly used in program • E.g. 7,3,9,’a’,”hello” are literal constant • They represents itself and nothing else • Its value cannot be changed • Numbers:integers,long integers,floating points,complex numbers • String:a groupof characters,immutable • Escape sequences • E.g a=rings bell, f=prints form feed character,n=newline,t=prints tab,o=octal value,x=hex value,=backslash,’=single quote,”=doublequote 10/18/19 Programming and problem solving 9
  • 10. Variables and identifiers • Variables are reserved memory locations that stores values. • Each variable is given appropriate name. • variables are example of identifiers • Identifiers are names given to identify something. • So it can be a variable, function, class, modules etc. • Valid identifiers: sum,_myvar,num1,var_20,a etc. • Invalid identifiers:1num,my-var,%check,basic sal . • Python is a case sensitive language. 10/18/19 Programming and problem solving 10
  • 11. Datatypes • Variables can hold values of different types called datatypes. • Numbers, strings, list, tuple, dictionary • Initializing values to variables e.g. a=7,code=‘a’,amt=123.45 etc. • Multiple assignment e.g. a=b=flag=0 • Assign different values to multiple variables simultaneously e.g. sum,a,b,msg=0,3,5,”rest” • Multiple statements on a single line usingsemi colon. • Boolean: datatype in python and can have one of two values-True or False. 10/18/19 Programming and problem solving 11
  • 12. Input Operation and Comments • Input() fuction= to take input from user • It always take input as a string • E.g. name=input(“what is your name?”) • E.g age=input(“enter your age:”) • Comments are non executable statements • Added to describe staatements of program • Characters following the# and upto end of line are part of comment • E.g. print(“hello”) #to display hello • Output: hello 10/18/19 Programming and problem solving 12
  • 13. Reserved words • In every programming language there are certain words which have predefined meaning called keywords or reserved words cannot be used for naming identifiers. • E.g.break,class,if,else,elif,for,from,print,retu rn • All the python keywords contain lowercase letters only. • 33 keywords in python 3.7. 10/18/19 Programming and problem solving 13
  • 14. Indentation • Indentation is used to define a block of code • Block of code begins with indentation and ends with the first unindented line. • Usually four white spaces are referred for indentation. • E.g no=10 If(no==10): print(“no is 10”) Output : no is 10 10/18/19 Programming and problem solving 14
  • 15. Operators and Expressions • Arithmetic operators: +,-,*,/,%,**,// • Assignment operators : =,+=,-=,*=,/=, %=,//=, **=,&=,|=, ^=,>>=, <<= • Comparison operators: ==,! =,>,<,>=,<= • Logical operators: and –returns true if both statements are true or- returns true if one of the statement is true not-returns false if the result is true 10/18/19 Programming and problem solving 15
  • 16. Operators and Expressions • Identity operators: is – returns true if both variables are the same object Is not – returns true if both variables are not the same object • Membership operators: In – returns true if a sequence with the specified value is present in the object Not in-– returns true if a sequence with the specified value is not present in the object • Bitwise operators: • & AND • | OR • ^ XOR • ~ NOT • << left shift • >> right shift 10/18/19 Programming and problem solving 16
  • 17. Expressions in Python • An expression is combination of value, variables and operators. • Expression appear on the right hand side of assignment operator. • E.g. add=a+b • Sub=a-b 10/18/19 Programming and problem solving 17
  • 18. THANK YOU 10/18/19 Programming and problem solving 18