Python Tutorial - Bedford-computing.co.uk

1y ago
12 Views
2 Downloads
4.96 MB
425 Pages
Last View : 2m ago
Last Download : 3m ago
Upload by : Braxton Mach
Transcription

Python Tutorial

PYTHON TUTORIALSimply Easy Learning by tutorialspoint.comtutorialspoint.comi

ABOUT THE TUTORIALPython TutorialPython is a general-purpose, interpreted, interactive, object-oriented and high-levelprogramming language. Python was created by Guido van Rossum in the late eighties andearly nineties. Like Perl, Python source code is also now available under the GNU GeneralPublic License (GPL).AudienceThis tutorial has been designed for software programmers with a need to understand thePython programming language starting from scratch. This tutorial will give you enoughunderstanding on Python programming language from where you can take yourself to ahigher level of expertise.PrerequisitesBefore proceeding with this tutorial you should have a basic understanding of ComputerProgramming terminologies. A basic understanding of any of the programming languages willhelp you in understanding the Python programming concepts and move fast on the learningtrack.Copyright & Disclaimer Notice Allthe content and graphics on this tutorial are the property of tutorialspoint.com. Any content fromtutorialspoint.com or this tutorial may not be redistributed or reproduced in any way, shape, or formwithout the written permission of tutorialspoint.com. Failure to do so is a violation of copyright laws.This tutorial may contain inaccuracies or errors and tutorialspoint provides no guarantee regarding theaccuracy of the site or its contents including this tutorial. If you discover that the tutorialspoint.com siteor this tutorial content contains some errors, please contact us at webmaster@tutorialspoint.comTUTORIALS POINTSimply Easy Learning

Table of ContentPython Tutorial . 2Audience . 2Prerequisites . 2Copyright & Disclaimer Notice. 2Python Overview . 40History of Python: . 40Python Features: . 40Python Environment . 42Getting Python: . 43Install Python:. 43Unix & Linux Installation: . 43Windows Installation:. 43Macintosh Installation: . 44Setting up PATH: . 44Setting path at Unix/Linux: . 44Setting path at Windows: . 44Python Environment Variables: . 44Running Python: . 45(1) Interactive Interpreter: . 45(2) Script from the Command-line: . 46(3) Integrated Development Environment. 46Python Basic Syntax . 47First Python Program: . 47INTERACTIVE MODE PROGRAMMING: . 47SCRIPT MODE PROGRAMMING: . 47Python Identifiers: . 48Reserved Words: . 48Lines and Indentation: . 49Multi-Line Statements:. 50Quotation in Python: . 50Comments in Python: . 50Using Blank Lines: . 51Waiting for the User:. 51Multiple Statements on a Single Line: . 51Multiple Statement Groups as Suites: . 51Command-Line Arguments: . 51Accessing Command-Line Arguments: . 52TUTORIALS POINTSimply Easy Learning

Example: . 52Parsing Command-Line Arguments: . 52getopt.getopt method: . 52exception getopt.GetoptError: . 53Example . 53Python Variable Types . 55Assigning Values to Variables: . 55Multiple Assignment: . 55Standard Data Types: . 56Python Numbers: . 56Examples: . 57Python Strings: . 57Python Lists:. 58Python Tuples: . 58Python Dictionary: . 59Data Type Conversion:. 59Python Basic Operators . 62Python Arithmetic Operators: . 62Example: . 63Python Comparison Operators: . 64Example: . 64Python Assignment Operators: . 66Example: . 66Python Bitwise Operators: . 67Example: . 68Python Logical Operators: . 69Example: . 69Python Membership Operators: . 70Example: . 70Python Identity Operators:. 71Example: . 71Python Operators Precedence . 72Example: . 73Python Decision Making. 75If statements. 76Syntax: . 76Flow Diagram: . 76Example: . 76if.else statements . 77TUTORIALS POINTSimply Easy Learning

Syntax: . 77Flow Diagram: . 77Example: . 78The elif Statement . 78Example: . 78nested if statements . 79Syntax: . 79Example: . 79Single Statement Suites: . 80Python Loops . 81while loop . 82Syntax: . 82Flow Diagram: . 82Example: . 83The Infinite Loop: . 83The else Statement Used with Loops . 84Single Statement Suites: . 84Syntax: . 84Flow Diagram: . 85Example: . 85Iterating by Sequence Index:. 86The else Statement Used with Loops . 86Syntax: . 87Example: . 87Loop Control Statements:. 88Syntax: . 88Flow Diagram: . 89Example: . 89Syntax: . 90Flow Diagram: . 90Example: . 90Syntax: . 91Example: . 91Python Numbers . 92Examples: . 92Number Type Conversion: . 93Mathematical Functions: . 93Syntax . 96Parameters. 96TUTORIALS POINTSimply Easy Learning

Return Value . 96Example . 97Description . 97Syntax . 97Parameters. 97Return Value . 97Example . 97Description . 98Syntax . 98Parameters. 98Return Value . 98Example . 98Description . 99Syntax . 99Parameters. 99Return Value . 99Example . 99Description . 99Syntax . 99Parameters. 100Return Value . 100Example . 100Description . 100Syntax . 100Parameters. 100Return Value . 100Example . 100Description . 101Syntax . 101Parameters. 101Return Value . 101Example . 101Description . 102Syntax . 102Parameters. 102Return Value . 102Example . 102Description . 103Syntax . 103TUTORIALS POINTSimply Easy Learning

Parameters. 103Return Value . 103Example . 103Description . 103Syntax . 103Parameters. 103Return Value . 104Example . 104Description . 104Syntax . 104Parameters. 104Return Value . 104Example . 104Random Number Functions: . 105Description . 105Syntax . 105Parameters. 105Return Value . 105Example . 105Description . 106Syntax . 106Parameters. 106Return Value . 106Example . 106Description . 107Syntax . 107Parameters. 107Return Value . 107Example . 107Description . 107Syntax . 108Parameters. 108Return Value . 108Example . 108Description . 108Syntax . 109Parameters. 109Return Value . 109Example . 109TUTORIALS POINTSimply Easy Learning

Description . 109Syntax . 109Parameters. 110Return Value . 110Example . 110Trigonometric Functions: . 110Description . 111Syntax . 111Parameters. 111Return Value . 111Example . 111Description . 111Syntax . 111Parameters. 111Return Value . 112Example . 112Description . 112Syntax . 112Parameters. 112Return Value . 112Example . 112Description . 113Syntax . 113Parameters. 113Return Value . 113Example . 113Description . 114Syntax . 114Parameters. 114Return Value . 114Example . 114Description . 114Syntax . 114Parameters. 115Return Value . 115Example . 115Description . 115Syntax . 115Parameters. 115TUTORIALS POINTSimply Easy Learning

Return Value . 115Example . 115Description . 116Syntax . 116Parameters. 116Return Value . 116Example . 116Description . 117Syntax . 117Parameters. 117Return Value . 117Example . 117Description . 118Syntax . 118Parameters. 118Return Value . 118Example . 118Mathematical Constants: . 119Python Strings. 120Accessing Values in Strings: . 120Updating Strings: . 120Escape Characters: . 121String Special Operators: . 121String Formatting Operator:. 122Triple Quotes:. 123Raw String: . 124Unicode String: . 124Built-in String Methods: . 125Description . 127Syntax . 127Parameters. 127Return Value . 127Example . 127Description .

All the content and graphics on this tutorial are the property of tutorialspoint.com. Any content from tutorialspoint.com or this tutorial may not be redistributed or reproduced in any way, shape, or form without the written permission of tutorialspoint.com. Failure to do so is a violation of copyright laws.

Related Documents:

Bedford Consulting, PLLC Bedford Dial-A-Ride Bedford Dental Group Bedford Fence Company Bedford Goodfellows Club Bedford High School Alumni Assoc. Bedford Hills Golf Club, Inc. Bedford Homes Real Estate Bedford Now Bedford Press, Inc. Bedford Public Schools Bedford Public Schools Community E

county of origin tax collection district/school district/municipality name psd code bedford schellsburg boro 050209 bedford st clairsville boro 050210 bedford west st clair twp 050211 everett area sd 0503 bedford east providence twp 050301 bedford everett boro 050302 bedford mann twp 050303 bedford monroe twp 050304 bedford southampton twp 050305

Python Programming for the Absolute Beginner Second Edition. CONTENTS CHAPTER 1 GETTING STARTED: THE GAME OVER PROGRAM 1 Examining the Game Over Program 2 Introducing Python 3 Python Is Easy to Use 3 Python Is Powerful 3 Python Is Object Oriented 4 Python Is a "Glue" Language 4 Python Runs Everywhere 4 Python Has a Strong Community 4 Python Is Free and Open Source 5 Setting Up Python on .

Python 2 versus Python 3 - the great debate Installing Python Setting up the Python interpreter About virtualenv Your first virtual environment Your friend, the console How you can run a Python program Running Python scripts Running the Python interactive shell Running Python as a service Running Python as a GUI application How is Python code .

Python is readable 5 Python is complete—"batteries included" 6 Python is cross-platform 6 Python is free 6 1.3 What Python doesn't do as well 7 Python is not the fastest language 7 Python doesn't have the most libraries 8 Python doesn't check variable types at compile time 8 1.4 Why learn Python 3? 8 1.5 Summary 9

Launch Eclipse Install Python plug-in for Eclipse Add a Python Interpreter Create a Python Project Create a Python Program Run a Python Program Debug a Python Program 0 Introduction This tutorial is for students who want to develop Python projects using Eclipse. E

site "Python 2.x is legacy, Python 3.x is the present and future of the language". In addition, "Python 3 eliminates many quirks that can unnecessarily trip up beginning programmers". However, note that Python 2 is currently still rather widely used. Python 2 and 3 are about 90% similar. Hence if you learn Python 3, you will likely

There are currently two versions of Python in use; Python 2 and Python 3. Python 3 is not backward compatible with Python 2. A lot of the imported modules were only available in Python 2 for quite some time, leading to a slow adoption of Python 3. However, this not really an issue anymore. Support for Python 2 will end in 2020.