jagomart
digital resources
picture1_Python Pdf 186478 | Tutorial


 110x       Filetype PDF       File size 0.62 MB       Source: fossies.org


File: Python Pdf 186478 | Tutorial
pythontutorial release 3 10 9 guidovanrossum andthepythondevelopmentteam december06 2022 pythonsoftwarefoundation email docs python org contents 1 whetting your appetite 3 2 using the python interpreter 5 2 1 invoking the ...

icon picture PDF Filetype PDF | Posted on 02 Feb 2023 | 2 years ago
Partial capture of text on file.
                                 PythonTutorial
                                       Release 3.10.9
                              GuidovanRossum
                       andthePythondevelopmentteam
                                        December06,2022
                                   PythonSoftwareFoundation
                                     Email: docs@python.org
                                                                                                                                                                                  CONTENTS
                             1     Whetting Your Appetite                                                                                                                                                        3
                             2     Using the Python Interpreter                                                                                                                                                  5
                                   2.1        Invoking the Interpreter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                           5
                                              2.1.1         Argument Passing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                         6
                                              2.1.2         Interactive Mode              . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                            6
                                   2.2        TheInterpreter and Its Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                               6
                                              2.2.1         Source Code Encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                           6
                             3     AnInformalIntroduction to Python                                                                                                                                              9
                                   3.1        Using Python as a Calculator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                             9
                                              3.1.1         Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                        9
                                              3.1.2         Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                    11
                                              3.1.3         Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                    14
                                   3.2        First Steps Towards Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                              15
                             4     MoreControlFlowTools                                                                                                                                                        17
                                   4.1        ifStatements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                             17
                                   4.2        forStatements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                            17
                                   4.3        Therange()Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                                 18
                                   4.4        breakandcontinueStatements,andelseClausesonLoops . . . . . . . . . . . . . . . . .                                                                               19
                                   4.5        passStatements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                             20
                                   4.6        matchStatements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                              20
                                   4.7        Defining Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                           23
                                   4.8        MoreonDefiningFunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                                24
                                              4.8.1         Default Argument Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                        24
                                              4.8.2         KeywordArguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                         25
                                              4.8.3         Special parameters               . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                         27
                                              4.8.4         Arbitrary Argument Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                       29
                                              4.8.5         Unpacking Argument Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                         30
                                              4.8.6         LambdaExpressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                        30
                                              4.8.7         Documentation Strings                  .  .  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                     31
                                              4.8.8         Function Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                       31
                                   4.9        Intermezzo: Coding Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                           32
                             5     DataStructures                                                                                                                                                              33
                                   5.1        MoreonLists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                            33
                                              5.1.1         Using Lists as Stacks               .  .  .  .  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                    34
                                              5.1.2         Using Lists as Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                      35
                                              5.1.3         List Comprehensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                        35
                                              5.1.4         Nested List Comprehensions                      . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                    36
                                   5.2        Thedelstatement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                              37
                                   5.3        Tuples and Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                           38
                                   5.4        Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                         39
                                   5.5        Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                         39
                                                                                                                                                                                                                  i
                                   5.6        Looping Techniques                 .  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                            40
                                   5.7        MoreonConditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                             42
                                   5.8        Comparing Sequences and Other Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                                42
                             6     Modules                                                                                                                                                                     43
                                   6.1        MoreonModules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                              44
                                              6.1.1         Executing modules as scripts                    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                    45
                                              6.1.2         TheModuleSearchPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                            45
                                              6.1.3         “Compiled” Python files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                      46
                                   6.2        Standard Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                           46
                                   6.3        Thedir()Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                               47
                                   6.4        Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                           48
                                              6.4.1         Importing * From a Package                      . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                    49
                                              6.4.2         Intra-package References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                       50
                                              6.4.3         Packages in Multiple Directories                      . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                  50
                             7     Input and Output                                                                                                                                                            51
                                   7.1        Fancier Output Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                            51
                                              7.1.1         Formatted String Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                      52
                                              7.1.2         TheString format() Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                        53
                                              7.1.3         Manual String Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                       54
                                              7.1.4         Old string formatting               .  .  .  .  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                    55
                                   7.2        Reading and Writing Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                            55
                                              7.2.1         Methods of File Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                      56
                                              7.2.2         Saving structured data with json . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                       57
                             8     Errors and Exceptions                                                                                                                                                       59
                                   8.1        Syntax Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                          59
                                   8.2        Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                           59
                                   8.3        Handling Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                            60
                                   8.4        Raising Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                           62
                                   8.5        Exception Chaining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                           63
                                   8.6        User-defined Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                            64
                                   8.7        Defining Clean-up Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                            64
                                   8.8        Predefined Clean-up Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                            65
                             9     Classes                                                                                                                                                                     67
                                   9.1        AWordAboutNamesandObjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                                    67
                                   9.2        Python Scopes and Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                               68
                                              9.2.1         Scopes and Namespaces Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                          69
                                   9.3        AFirst Look at Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                           70
                                              9.3.1         Class Definition Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                      70
                                              9.3.2         Class Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                      70
                                              9.3.3         Instance Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                     71
                                              9.3.4         MethodObjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                        71
                                              9.3.5         Class and Instance Variables                    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                    72
                                   9.4        RandomRemarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                              73
                                   9.5        Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                          74
                                              9.5.1         Multiple Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                     75
                                   9.6        Private Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                          76
                                   9.7        OddsandEnds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                              76
                                   9.8        Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                        77
                                   9.9        Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                           78
                                   9.10 Generator Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                                  79
                             10 Brief Tour of the Standard Library                                                                                                                                             81
                                   10.1 Operating System Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                                 81
                                   10.2 File Wildcards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                                 81
                                   10.3 CommandLineArguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                                       82
                             ii
The words contained in this file might help you see if this file matches what you are looking for:

...Pythontutorial release guidovanrossum andthepythondevelopmentteam december pythonsoftwarefoundation email docs python org contents whetting your appetite using the interpreter invoking argument passing interactive mode theinterpreter and its environment source code encoding aninformalintroduction to as a calculator numbers strings lists first steps towards programming morecontrolflowtools ifstatements forstatements therange function breakandcontinuestatements andelseclausesonloops passstatements matchstatements defining functions moreondefiningfunctions default values keywordarguments special parameters arbitrary unpacking lambdaexpressions documentation annotations intermezzo coding style datastructures moreonlists stacks queues list comprehensions nested thedelstatement tuples sequences sets dictionaries i looping techniques moreonconditions comparing other types...

no reviews yet
Please Login to review.