Basic Python Tutorial (second edition) Learning Notes Basics section (Chapter 1th)

Source: Internet
Author: User

"Basic Python Tutorial (second edition)" Learning notes
Basic part (1th chapter)
Ide
Windows:idle (GUI), Eclipse+pydev; Python (command line);
Linux/unix:python

>>> 1/2=0 note divisible by 0.
>>> from __future__ Import Division performing normal division
Python-qnew Perform a normal division
Divide, 1//2=0;% take the remainder;
Long integer: End with L
hexadecimal, beginning with 0x; octal starts with 0;
Variable name: letter, number, underline; Do not start with a number;
Print (42); Print 42; Output
X=input ("x:") input data returned to X
Import Math Imports Math module
From math import sqrt importing the SQRT function from the math module
Nan, not a number;
Import Cmath; complex math complex; imaginary numbers end with J;
*.py extension py
X=raw_input ("x:")
Python hello.py
Run the Python code file directly:
#!usr/bin/env python
#chmod a+x hello.py
#hello. py
Comments
string, either single or double quotation marks
Examples of strings: ' abc ', ' abc ', ' Ab ' CD ', ' AB ' CD ', ' AB ' CD ' EF ', ' ab\ ' CD '
Stitching strings:
x= "ABC" "DEF"
x= "ABC" ' DEF '
x= "ABC" + ' DEF '
To get a string from a value:
STR (123)
STR (123L)
Str (12.3)
STR (4+5)
REPR (123)
Repr (123L)
Repr (12.3)
Enter data from the keyboard:
Input (), raw_input ()
Multi-line string:
x= "AA"
Bb
CC ""
String Continuation Line
x= "aa\
Bb\
cc
To renew an expression:
X=1+2\
+3
Statement to continue:
Print \
' ABC '
Original string: R ' abc\def '
Unicode string: U ' ABC123 string '

Basic Python Tutorial (second edition) Learning Notes Basics section (Chapter 1th)

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.