Python Learning Path Basics 01

Source: Internet
Author: User

1.python Introduction

2. Installation

3. First Python program

4. Variables

5. User input

1.python Introduction

According to a study published by IEEE Spectrum, Python, ranked third in 2016, has become the world's most popular language this year, with C and Java ranked second and third respectively. This shows that Python will be the future language

2. Installation

First we go into the https://www.python.org to download the corresponding version of python2.7 or python3.5 to your system

3. First Python program

Run Python and set up a Hello,word program.

4. variable \ character encoding

Variables is used to store information to is referenced and manipulated in a computer program. They also provide a labeling data with a descriptive name, so we programs can be understood more clearly by the RE Ader and ourselves. It's helpful to think of variables as containers, that's hold information. Their sole purpose is to label and store data in memory. This data can and is used throughout your program.

declaring variables

123 #_*_coding:utf-8_*_name ="Alex Li"

The code above declares a variable named: Name, and the value of the variable name is: "Alex Li"

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

12345678 name ="Alex Li" name2 = nameprint(name,name2) name = "Jack"print("What is the value of name2 now?")

Notes

When the line stares: # is annotated content

Multiline Comment: "" "Annotated Content" ""

5. User input
1234567 #!/usr/bin/env python#_*_coding:utf-8_*_#name = raw_input("What is your name?") #only on python 2.xname = input("What is your name?")print("Hello " +name )

When entering a password, if you want to be invisible, you need to take advantage of the Getpass method in the Getpass module, namely:

12345678910 #!/usr/bin/env python# -*- coding: utf-8 -*- import getpass  # 将用户输入的内容赋值给 name 变量pwd = getpass.getpass("请输入密码:") # 打印输入的内容print(pwd)

Python Learning Path Basics 01

Related Article

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.