~ Aibirong ~ Python Basics for Learning python

Source: Internet
Author: User

The first step:

try to write Hello world program

This is the first program I wrote in python, one small step, One big step in my Life.

Create a file under Linux called hello.py,

Then execute the command: python hello.py, output

Specify interpreter (refer to Alex Teacher's Summary)

When executing Python hello.py in the previous step, it is clear that the hello.py script is executed by the Python interpreter.

If you want to execute a python script like executing a shell script, for example:./hello.py, then you need to specify the interpreter in the header of the hello.py file,

As a result, execute:./hello.py.

Ps: need to give hello.py Execute permission before execution, chmod 755 hello.py or chmod a+x hello.py

variables \ character encoding

Declaring variables,

The above code declares several variables, for example: the variable is named: name, and the value of the variable name is: "liyasen"

Rules for variable definitions:

    • Variable names can only be any combination of letters, numbers, or underscores
    • The first character of a variable name cannot be a number
    • The following keywords cannot be declared as variable names
      [' and ', ' as ', ' assert ', ' break ', ' class ', ' Continue ', ' def ', ' del ', ' elif ', ' else ', ' except ', ' exec ', ' finally ', ' for ', ' F ' Rom ', ' global ', ' if ', ' import ', ' in ', ' was ', ' lambda ', ' not ', ' or ', ' pass ', ' Print ', ' raise ', ' return ', ' try ', ' while ', ' WI Th ', ' yield ']

Assigning values to variables

 

~ Aibirong ~ Python Basics for Learning python

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.