Python Learning Path--day 1

Source: Internet
Author: User

Python installation

Go to the official website to download the installation package and choose the Python version you need. Now Python has already entered the 3.x era, it is best to choose 3.x version. The version of 2.x is not updated and will stop service in 2020.

Installation process The next step is fine, but remember your installation path. For subsequent configuration of the Python environment variables.

Use Python-v to see if the Python installation is successful and current version in the DOS interface.

The first Python program

Output Hello World

1, can be output in Python's own idle

Print ("Hello world!")

2. You can also create a new document example:FitstPythonProj.py

The suffix of the document must be a. py format that is known by the Python program

Enter Python firstputhonproj.py in the DOS interface

    

Python variables

Python does not need to be in other languages (such as C,c++,java, etc.), before use, you need to declare the variable type,

Example: String name= "Jackson"in Java; the type of name is a character type. In Python, the direct

name= "Javason" does not need to be declared, Python will automatically match us.

  

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 ']

User input

  name  = input ( "What is your name?" )   print ( "Hello " + name )Need to hide input number is can import module Getpass import getpass # 将用户输入的内容赋值给 name 变量 pwd  = getpass.getpass( "请输入密码:" )   # 打印输入的内容 print (pwd)Loop statement:

The simplest loop 10 times

forinrange(10):

     print ( "loop:" , i ) function range prototypes: Range (start, end, scan):

parameter meaning : Start: Count starts from start. The default is starting from 0. For example, range (5) is equivalent to range (0, 5);

End: The technology ends with end, but does not include end. For example: Range (0, 5) is [0, 1, 2, 3, 4] No 5

Scan: The distance between each hop is 1 by default. Example: Range (0, 5) is equivalent to range (0, 5, 1)

Python Learning Path--day 1

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.