What are the markers for statement blocks in python language?

烟雨青岚
Release: 2020-07-15 11:34:55
Original
24550 people have browsed it

There is no obvious statement block mark in python. Statement blocks are identified through indentation. Python is a cross-platform computer programming language; it is a high-level scripting language that combines interpretability, compilation, interactivity and object-oriented; it is mostly used for the development of independent, large-scale projects.

What are the markers for statement blocks in python language?

Python does not have obvious statement block markers, and statement blocks are identified through indentation.

Open the editor here and create a new py file as a demonstration.

def happy():
    print("Very Happy!")
happy()
Copy after login

When creating a function, you need to indent after the colon to mark the statement block.

What are the markers for statement blocks in python language?

x = 1
while x < 5:
    print(x)
    x += 1
Copy after login

When using while, you need to indent after the colon to mark the statement block.

What are the markers for statement blocks in python language?

x = 1
if x < 10:
    print("ok")
else:
    print("not ok")
Copy after login

When using if and else statements, they need to be indented after the colon to mark the statement block.

What are the markers for statement blocks in python language?

If you do not mark the statement block, an error will be reported.

What are the markers for statement blocks in python language?

def hey():
    x = 1
    while x < 3:
        print("hey")
        x += 1
        if x == 3:
            print("ok")
hey()
Copy after login

After each colon, a statement block needs to be marked, and it must be marked layer by layer according to the format.

What are the markers for statement blocks in python language?

Recommended tutorial: "python tutorial"

The above is the detailed content of What are the markers for statement blocks in python language?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template