4. More Control Flow Tools — Python 3.14.7 documentation

docs.python.org

Tin mới

4.3. The range() Function¶

If you do need to iterate over a sequence of numbers, the built-in function range() comes in handy. It generates arithmetic progressions:

3. An Informal Introduction to Python

5. Data Structures

Python Module Index

3.14.7 Documentation

The Python Tutorial

4.1. if Statements¶

As well as the while statement just introduced, Python uses a few more that we will encounter in this chapter.

4.3. The range() Function¶

If you do need to iterate over a sequence of numbers, the built-in function range() comes in handy. It generates arithmetic progressions:

4.3. The range() Function¶

If you do need to iterate over a sequence of numbers, the built-in function range() comes in handy. It generates arithmetic progressions:

4.4. break and continue Statements¶

The break statement breaks out of the innermost enclosing for or while loop:

Handling Exceptions

In a for or while loop the break statement may be paired with an else clause. If the loop finishes without executing the break, the else clause executes.

4.9.1. Default Argument Values¶

The most useful form is to specify a default value for one or more arguments. This creates a function that can be called with fewer arguments than it is defined to allow. For example:

object.__annotations__

Function annotations are completely optional metadata information about the types used by user-defined functions (see PEP 3107 and PEP 484 for more information).

A First Look at Classes

Name your classes and functions consistently; the convention is to use UpperCamelCase for classes and lowercase_with_underscores for functions and methods. Always use self as the name for the first method argument (see A