"Basic Python Tutorial 2nd edition revision" Learning notes (i)

Source: Internet
Author: User

"Basic Python Tutorial   2nd edition   Revision" study notes (i) Chapter I: Rapid transformation: Fundamentals 1.1  Installing Python (slightly) how to become a  Hacker:http://www.catb.org/~esr/faqs/hacker-howto.html Chinese version: How to become a hacker http://blog.jobbole.com/64196/  (Bole online version, I think the current version is more perfect) 1.2  Interactive interpreter >>>1.3  What is the goal of the algorithm: Cook a plate of lunch meat and egg food process: 1. First add a luncheon meat 2. Then add a lunch meat 3. Add one more lunch meat 4. If you like spicy food, add more lunch meat  # if6. Cooked, check every 5 minutes  # %101.4  algorithm 2  integer 2.5  floating point number (real number) 1/2 = 0   integer divided by integer, fractional portion is trapped 1.0/2.0 =  0.5,1/2.0 = 0.5,1.0/2 = 0.5  double floating point number or any floating-point number to divide the result into floating-point numbers, such as only normal division (reserved decimals): From __future_ _ import division # future before and after the double underscore is divisible by:// #  floating-point number is also divisible%  to take the remainder:10%3 =  The precedence of the 1 power operator is higher than the inverse (unary decrement operator): -3**2 = -(3**2) wants to calculate (-3) **2 need to explicitly describe an integer: cannot be greater than 2147483647, or less than-2147483647, Out of range you can use long integers long integers: integer tails plus l long integers and ordinary integers can be mixed with 1.5  variable variables: A name that represents or refers to a value x = 3  #赋值x  * 2 =  6 before using a variable, you must first assign a variable name that can include letters, numbers, underscores (_), and not start with a number 1.6  statement = Directive expression: Something statement: A general feature of a statement: they change things. For example, an assignment statement changes the changeThe print statement changes the contents of the screen display. 1.7  Gets the user input function: >>>input ("Please enter Number:")    #input是语句, () is a prompt, is a string, need to use "" Please enter a number:15151.8  Function functions are like small programs that can be used to implement specific functions. For example: POW is used to calculate standard functions such as Solutionkeys &GT;&GT;&GT;2**38&GT;&GT;&GT;POW (2.3) 8pow, called built-in functions, or you can customize functions. The 1.9  module can be thought of as an extension that imports into Python to enhance its functionality and is imported using the Import command. For example: Import the Math module with import and use >>>import math>>>math.floor (32.9) in the format "module. function" 32.0 If you do not want to write the module name each time the function is called, you can use: "From module import function" >>>from math import sqrt # Import the SQRT function from the Math module &GT;&GT;&GT;SQRT (9) 3.0 You can use the variable reference function:>>>foo = math.sqrt  #将函数赋值到一个变量上 > >>foo (4) 2.0nan:not a number  #非数值虚数以j结尾1 .10  Save and execute the program file name with a. Py End Unix Direct operation method: First line plus: #! followed by the absolute path of Python, for example: #!/usr/bin/env python after using:chmod a+x hello.py  to make the file executable properties windows in the tail join: raw_ Input ("press <enter>") double-click the window does not automatically disappear after the comment: #字符串: A string of characters: concatenation of a string, a value is represented as a string: reprinput: Enter a value raw_ Input: Enter string as far as possible using raw_input long string (across lines): ""   "" "  #三引号原始字符串 (Pure string): R begins line break: \ Nunicode string using U-prefix Summary: algorithm: is a detailed description of how to complete a task. Expression: WithTo represent a value. Variable: is a name used to represent a value. Statement: An instruction that tells the computer to do something. Functions: Functions like math, can take parameters, and return values. Modules: Some extensions to Python. String: The text fragment.


This article is from the "Hello3389 blog" blog, make sure to keep this source http://hello3389.blog.51cto.com/1171990/1630264

"Basic Python Tutorial 2nd edition revision" Learning notes (i)

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.