SlideShare a Scribd company logo
1 of 38
PYTHON
Speaker Arpit tripathi.
KGI Kanpur
B tech second year student{CSE}
What We Give you?
• What is Python…?
• Differences between program and scripting language
• History of Python
• Scope of Python
• What can I do with python
• Who uses python today
• Why do people use Python?
• Installing Python IDE
• A Sample Code
• Python code execution
• Running Python
• Python Basic(Variable, Strings, Data types etc.)
What is Python…?
• Python is a general purpose programming language that is often
applied in scripting roles.
• So, Python is programming language as well as scripting language.
• Python is also called as Interpreted language
Differences between program and scripting
language
Program Scripting
• a program is executed (i.e a script is interpreted
the source is first compiled, A “script” is code written
and the result of that compi in a language A scripting
lation is expected) language is nothing but a
• A "program" in general, is type of programming langua
a sequence of instructions ge in which we can write c
written so that a computer ode to control another soft
can perform certain task. Ware application
History
• Invented in the Netherlands, early 90s by Guido van
Rossum
• Python was conceived in the late 1980s and its implementation was
started in December 1989
• Guido Van Rossum is fan of ‘Monty Python’s Flying Circus’, this is a
famous TV show in Netherlands
• Named after Monty Python
• Open sourced from the beginning
Python’s Benevolent Dictator For Life
• “Python is an experiment in how much free
• dom programmers need. Too much freedom and
• nobody can read another's code; too little and
• expressiveness is endangered. –
Guido van Rossum
Why was python created?
• "My original motivation for creating Python was the perceived need
for a higher level language in the Amoeba [Operating Systems]
project.
I realized that the development of system administration
utilities in C was taking too long. Moreover, doing these things in the
Bourne shell wouldn't work for a variety of reasons. ... So, there was a
need for a language that would bridge the gap between C and the
shell” - Guido Van Rossum
Scope of Python
• Science
- Bioinformatics
• System Administration
-Unix
-Web logic
-Web sphere
• Web Application Development
-CGI
-Jython – Servlets
Testing scripts
What can I do with Python?
• System programming
• Graphical User Interface Programming
• Internet Scripting
• Component Integration
• Database Programming
• Gaming, Images, XML , Robot and more
Who uses python today…
• Python is being applied in real revenue-generating products by real
companies. For instance:
• Google makes extensive use of Python in its web search system, and
employs Python’s creator.
• Intel, Cisco, Hewlett-Packard, Seagate, Qualcomm, and IBM use
Python for hardware testing.
• ESRI uses Python as an end-user customization tool for its popular GIS
mapping products.
• The YouTube video sharing service is largely written in python
Why do people use Python?
• The following primary factors cited by Python
users seem to be these:
• Python is object-oriented
Structure supports such concepts as polymorphism, operation
overloading, and multiple inheritance. .
• It's free (open source)
Downloading and installing Python is free and easy Source code is
easily accessible
• It's powerful
- Dynamic typing
- Built-in types and tools
- Library utilities
- Third party utilities (e.g. Numeric, NumPy, SciPy)
- Automatic memory management
• It's portable
- Python runs virtually every major platform used today
- As long as you have a compatible Python interpreter installed,
Python programs will run in exactly the same manner,
irrespective of platform
Installing Python
• Python is pre-installed on most Unix systems, including Linux and
MAC OS X
• But for in Windows Operating Systems , user can download from the
https://www.python.org/downloads/ - from the above link download
latest version of python IDE and install, recent version is 3.4.1 but most
of them uses version 3.9.1 only
Running Python
Once you're inside the Python interpreter, type in commands at will.
• Examples
: >>> print 'Hello world‘
Hello world
Python Code Execution
• Python’s traditional runtime execution model: source code you type is
to byte code, which is then run by the Python Virtual Machine. Your
code is automatically compiled, but then it is interpreted.
Source code extension is .py Byte code extension is .pyc
(compiled python code)
MATH(OPERATOR) IN PYTHON
Math
Try typing this into Code:
>>> print 3 + 12
15
>>> print 12 – 3
9
>>> print 9 + 5 – 15 + 12
11
Operators:
add: +
subtract: -
Note: don’t type the arrows >>> !
Math
Rule: If you want Python to answer in floats, you have to talk to it in floats
• More operators:
• divide: /
• multiply: *
• >>> print 3 * 12 36
• >>> print 12 / 3 4
• >>> print 11 / 3 3
• >>> print 12.0 / 3.0 4.0
• >>> print 11.0 / 3.0 3.66
Math
• Practice:
• >>> print 2 < 3 True
• >>> print 2 <= 2 False
• >>> print 3 > 2 True
• >>> print 2 != 3 True
• >>> print False < True True
STRINGS IN PYTHON
Strings
• Examples:
>>> “It’s a beautiful day!”
>>> “Goodbye, cruel world.”
Try typing one without quotes:
What’s the result >>Aggies
>>> “Aggies”
>>> “Rice fight,never
die!”
>>> “3 + 2”
Strings
• String operators:
concatenation: +
multiplication: *
Try concatenating: >>> print “Hello” +
Try multiplying: “ “ + “world!”
>>> print “HAHA” *
250
VARIABLES IN PYTHON
Variables
• Create a Variable:
>>>headmaster=“Dumbledore”
>>>print headmaster
‘Dumbledore’
Assigning a New Value:
>>>headmaster=“Hardcastle”
>>>print headmaster
‘Hardcastle
DATA TYPES IN PYTHON
Data Types:
• Python has many native data types. Here are the important ones:
• Booleans are either True or False.
• Numbers can be integers (1 and 2), floats (1.1 and 1.2), fractions (1/2 and 2/3), or even complex numbers.
• Strings are sequences of Unicode characters, e.g. an HTML document.
• Bytes and byte arrays, e.g. a JPEG image file.
• Lists are ordered sequences of values.
• Tuples are ordered, immutable sequences of values
• Sets are unordered bags of values.
Example:
• String “Whoop!”
• Integer 42
• Float 3.14159
• List [“John”, “Paul”, “George”, “Ringo”]
Python can tell us about types using the type() function:
>>> print type(“Whoop!”)
<type ‘str’>
LIST: DATA TYPE
List:
• The list is a most versatile Data type available in Python which can be
written as a list of comma-separated values (items) between square
brackets. Important thing about a list is that items in a list need not
be of the same type.
• Example:
• list1 = ['physics', 'chemistry', 1997, 2000];
• list2 = [1, 2, 3, 4, 5 ];
Sn Function with Description
1 cmp(list1, list2) Compares elements of both lists.
2 len(list) Gives the total length of the list.
3 max(list) Returns item from the list with max value.
4 min(list) Returns item from the list with min value.
5 list(seq) Converts a tuple into list.
Lists
• Index: Where an item is in the list
>>> Beatles = [“John”, “Paul”, “George”,
“Ringo”]
>>> Beatles[0]
‘John‘
[“John”, “Paul”, “George”, “Ringo”]
0 1 2 3
Python always starts at zero!
TUPLE: DATA TYPE
Tuples:
• A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists.
The differences between tuples and lists are, the tuples cannot be changed unlike lists
and tuples use parentheses, whereas lists use square brackets.
• Example:
• tup2 = (1, 2, 3, 4, 5 );
• tup3 = ("a", "b", "c", "d“);
• Accessing Values:
• print "tup2[1:5]: “
• Output:
• tup2[1:5]: [2, 3, 4, 5]
LOOPS & CONDITIONAL STATEMENTS
Loop Type Description
while loop Repeats a statement or group of statements while a given condition is TRUE.
It tests the condition before executing the loop body.
For loop Executes a sequence of statements multiple times and abbreviates the code
that manages the loop variable.
Nested loops You can use one or more loop inside any another while, for or do..while
loop.
Statement Description
If statements An if statement consists of a boolean expression followed by one or more statements.
If else statements An if statement can be followed by an optional else statement, which executes when the
boolean expression is FALSE.
nested if statements You can use one if or else if statement inside another if or else if statement(s).
I believe the trial has shown conclusively that it is both possible and desirable to use
Python as the principal teaching language
• It is Free (as in both cost and source code).
• It is trivial to install on a Windows PC allowing students to take their interest
further. For many the hurdle of installing a Pascal or C compiler on a Windows
machine is either too expensive or too complicated;
• It is a flexible tool that allows both the teaching of traditional procedural
programming and modern OOP; It can be used to teach a large number of
transferable skills;
• It is a real-world programming language that can be and is used in academia
and the commercial world;
• It appears to be quicker to learn and, in combination with its many libraries, this
offers the possibility of more rapid student development allowing the course to
be made more challenging and varied;
• and most importantly, its clean syntax offers increased understanding and
enjoyment for students;
Thank you!

More Related Content

What's hot

What's hot (20)

Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
intro.pptx (1).pdf
intro.pptx (1).pdfintro.pptx (1).pdf
intro.pptx (1).pdf
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Python Tutorial Part 2
Python Tutorial Part 2Python Tutorial Part 2
Python Tutorial Part 2
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-python
 
python presentation
python presentationpython presentation
python presentation
 
Python presentation
Python presentationPython presentation
Python presentation
 
Presentation on python
Presentation on pythonPresentation on python
Presentation on python
 
Python final ppt
Python final pptPython final ppt
Python final ppt
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Introduction python
Introduction pythonIntroduction python
Introduction python
 
Python basic
Python basicPython basic
Python basic
 
python-ppt.ppt
python-ppt.pptpython-ppt.ppt
python-ppt.ppt
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
Basics of python
Basics of pythonBasics of python
Basics of 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 Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019
 

Similar to python presntation 2.pptx

python-160403194316.pdf
python-160403194316.pdfpython-160403194316.pdf
python-160403194316.pdf
gmadhu8
 
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
HassanShah396906
 

Similar to python presntation 2.pptx (20)

python into.pptx
python into.pptxpython into.pptx
python into.pptx
 
python-160403194316.pdf
python-160403194316.pdfpython-160403194316.pdf
python-160403194316.pdf
 
Python
PythonPython
Python
 
Python Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPT
 
Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1
 
python-ppt.ppt
python-ppt.pptpython-ppt.ppt
python-ppt.ppt
 
Python programming language introduction unit
Python programming language introduction unitPython programming language introduction unit
Python programming language introduction unit
 
Python_slides.pdf
Python_slides.pdfPython_slides.pdf
Python_slides.pdf
 
Python Demo.pptx
Python Demo.pptxPython Demo.pptx
Python Demo.pptx
 
Python Demo.pptx
Python Demo.pptxPython Demo.pptx
Python Demo.pptx
 
MODULE 1.pptx
MODULE 1.pptxMODULE 1.pptx
MODULE 1.pptx
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
 
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_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptxPython_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptx
 
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
 
Introduction to python for Beginners
Introduction to python for Beginners Introduction to python for Beginners
Introduction to python for Beginners
 
REPORT ON AUDIT COURSE PYTHON BY SANA 2.pdf
REPORT ON AUDIT COURSE PYTHON BY SANA 2.pdfREPORT ON AUDIT COURSE PYTHON BY SANA 2.pdf
REPORT ON AUDIT COURSE PYTHON BY SANA 2.pdf
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
Phython Programming Language
Phython Programming LanguagePhython Programming Language
Phython Programming Language
 

Recently uploaded

Recently uploaded (20)

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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

python presntation 2.pptx

  • 1. PYTHON Speaker Arpit tripathi. KGI Kanpur B tech second year student{CSE}
  • 2. What We Give you? • What is Python…? • Differences between program and scripting language • History of Python • Scope of Python • What can I do with python • Who uses python today • Why do people use Python? • Installing Python IDE • A Sample Code • Python code execution • Running Python • Python Basic(Variable, Strings, Data types etc.)
  • 3. What is Python…? • Python is a general purpose programming language that is often applied in scripting roles. • So, Python is programming language as well as scripting language. • Python is also called as Interpreted language
  • 4. Differences between program and scripting language Program Scripting • a program is executed (i.e a script is interpreted the source is first compiled, A “script” is code written and the result of that compi in a language A scripting lation is expected) language is nothing but a • A "program" in general, is type of programming langua a sequence of instructions ge in which we can write c written so that a computer ode to control another soft can perform certain task. Ware application
  • 5. History • Invented in the Netherlands, early 90s by Guido van Rossum • Python was conceived in the late 1980s and its implementation was started in December 1989 • Guido Van Rossum is fan of ‘Monty Python’s Flying Circus’, this is a famous TV show in Netherlands • Named after Monty Python • Open sourced from the beginning
  • 6. Python’s Benevolent Dictator For Life • “Python is an experiment in how much free • dom programmers need. Too much freedom and • nobody can read another's code; too little and • expressiveness is endangered. – Guido van Rossum
  • 7. Why was python created? • "My original motivation for creating Python was the perceived need for a higher level language in the Amoeba [Operating Systems] project. I realized that the development of system administration utilities in C was taking too long. Moreover, doing these things in the Bourne shell wouldn't work for a variety of reasons. ... So, there was a need for a language that would bridge the gap between C and the shell” - Guido Van Rossum
  • 8. Scope of Python • Science - Bioinformatics • System Administration -Unix -Web logic -Web sphere • Web Application Development -CGI -Jython – Servlets Testing scripts
  • 9. What can I do with Python? • System programming • Graphical User Interface Programming • Internet Scripting • Component Integration • Database Programming • Gaming, Images, XML , Robot and more
  • 10. Who uses python today… • Python is being applied in real revenue-generating products by real companies. For instance: • Google makes extensive use of Python in its web search system, and employs Python’s creator. • Intel, Cisco, Hewlett-Packard, Seagate, Qualcomm, and IBM use Python for hardware testing. • ESRI uses Python as an end-user customization tool for its popular GIS mapping products. • The YouTube video sharing service is largely written in python
  • 11. Why do people use Python? • The following primary factors cited by Python users seem to be these: • Python is object-oriented Structure supports such concepts as polymorphism, operation overloading, and multiple inheritance. . • It's free (open source) Downloading and installing Python is free and easy Source code is easily accessible
  • 12. • It's powerful - Dynamic typing - Built-in types and tools - Library utilities - Third party utilities (e.g. Numeric, NumPy, SciPy) - Automatic memory management • It's portable - Python runs virtually every major platform used today - As long as you have a compatible Python interpreter installed, Python programs will run in exactly the same manner, irrespective of platform
  • 13. Installing Python • Python is pre-installed on most Unix systems, including Linux and MAC OS X • But for in Windows Operating Systems , user can download from the https://www.python.org/downloads/ - from the above link download latest version of python IDE and install, recent version is 3.4.1 but most of them uses version 3.9.1 only
  • 14. Running Python Once you're inside the Python interpreter, type in commands at will. • Examples : >>> print 'Hello world‘ Hello world
  • 15. Python Code Execution • Python’s traditional runtime execution model: source code you type is to byte code, which is then run by the Python Virtual Machine. Your code is automatically compiled, but then it is interpreted. Source code extension is .py Byte code extension is .pyc (compiled python code)
  • 17. Math Try typing this into Code: >>> print 3 + 12 15 >>> print 12 – 3 9 >>> print 9 + 5 – 15 + 12 11 Operators: add: + subtract: - Note: don’t type the arrows >>> !
  • 18. Math Rule: If you want Python to answer in floats, you have to talk to it in floats • More operators: • divide: / • multiply: * • >>> print 3 * 12 36 • >>> print 12 / 3 4 • >>> print 11 / 3 3 • >>> print 12.0 / 3.0 4.0 • >>> print 11.0 / 3.0 3.66
  • 19. Math • Practice: • >>> print 2 < 3 True • >>> print 2 <= 2 False • >>> print 3 > 2 True • >>> print 2 != 3 True • >>> print False < True True
  • 21. Strings • Examples: >>> “It’s a beautiful day!” >>> “Goodbye, cruel world.” Try typing one without quotes: What’s the result >>Aggies >>> “Aggies” >>> “Rice fight,never die!” >>> “3 + 2”
  • 22. Strings • String operators: concatenation: + multiplication: * Try concatenating: >>> print “Hello” + Try multiplying: “ “ + “world!” >>> print “HAHA” * 250
  • 24. Variables • Create a Variable: >>>headmaster=“Dumbledore” >>>print headmaster ‘Dumbledore’ Assigning a New Value: >>>headmaster=“Hardcastle” >>>print headmaster ‘Hardcastle
  • 25. DATA TYPES IN PYTHON
  • 26. Data Types: • Python has many native data types. Here are the important ones: • Booleans are either True or False. • Numbers can be integers (1 and 2), floats (1.1 and 1.2), fractions (1/2 and 2/3), or even complex numbers. • Strings are sequences of Unicode characters, e.g. an HTML document. • Bytes and byte arrays, e.g. a JPEG image file. • Lists are ordered sequences of values. • Tuples are ordered, immutable sequences of values • Sets are unordered bags of values.
  • 27. Example: • String “Whoop!” • Integer 42 • Float 3.14159 • List [“John”, “Paul”, “George”, “Ringo”] Python can tell us about types using the type() function: >>> print type(“Whoop!”) <type ‘str’>
  • 29. List: • The list is a most versatile Data type available in Python which can be written as a list of comma-separated values (items) between square brackets. Important thing about a list is that items in a list need not be of the same type. • Example: • list1 = ['physics', 'chemistry', 1997, 2000]; • list2 = [1, 2, 3, 4, 5 ];
  • 30. Sn Function with Description 1 cmp(list1, list2) Compares elements of both lists. 2 len(list) Gives the total length of the list. 3 max(list) Returns item from the list with max value. 4 min(list) Returns item from the list with min value. 5 list(seq) Converts a tuple into list.
  • 31. Lists • Index: Where an item is in the list >>> Beatles = [“John”, “Paul”, “George”, “Ringo”] >>> Beatles[0] ‘John‘ [“John”, “Paul”, “George”, “Ringo”] 0 1 2 3 Python always starts at zero!
  • 33. Tuples: • A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets. • Example: • tup2 = (1, 2, 3, 4, 5 ); • tup3 = ("a", "b", "c", "d“); • Accessing Values: • print "tup2[1:5]: “ • Output: • tup2[1:5]: [2, 3, 4, 5]
  • 34. LOOPS & CONDITIONAL STATEMENTS
  • 35. Loop Type Description while loop Repeats a statement or group of statements while a given condition is TRUE. It tests the condition before executing the loop body. For loop Executes a sequence of statements multiple times and abbreviates the code that manages the loop variable. Nested loops You can use one or more loop inside any another while, for or do..while loop.
  • 36. Statement Description If statements An if statement consists of a boolean expression followed by one or more statements. If else statements An if statement can be followed by an optional else statement, which executes when the boolean expression is FALSE. nested if statements You can use one if or else if statement inside another if or else if statement(s).
  • 37. I believe the trial has shown conclusively that it is both possible and desirable to use Python as the principal teaching language • It is Free (as in both cost and source code). • It is trivial to install on a Windows PC allowing students to take their interest further. For many the hurdle of installing a Pascal or C compiler on a Windows machine is either too expensive or too complicated; • It is a flexible tool that allows both the teaching of traditional procedural programming and modern OOP; It can be used to teach a large number of transferable skills; • It is a real-world programming language that can be and is used in academia and the commercial world; • It appears to be quicker to learn and, in combination with its many libraries, this offers the possibility of more rapid student development allowing the course to be made more challenging and varied; • and most importantly, its clean syntax offers increased understanding and enjoyment for students;