Python learning about data types and looping essentials

Source: Internet
Author: User

Python notes:
1.E notation, scientific counting method equals 10 of how many times Square. 1.5e5=150000.0. Note: The resulting number is floating point.;
2. Type conversion: Int (translates to shaping), str (converted to string), float ();
Note: The floating-point number is converted to an integer and the integer part is truncated. int (3.6) = 3;
Shaping into floating-point type, plus. 0;float (3) = 3.0;
Float (4e10) = ' 4e+10 '; + indicates positive or negative;
When the BIF keyword is used for a common variable name, in future use, Python will continue to use the new identity of the keyword, and will not use the original BIF functionality. Example: str= ' Zjh '; c=str (3), the first sentence can print Str smoothly, but the following statement will report an error.

3. Get information about the type.
type (); function. Example: A= ' 520 ', type (1), Printed: Class ' str ';
isinstance (). Returns a Boolean type value. A= ' Zjh '; isinstance (A,STR); return true;
4. Integer division (/), in Python3, returns the true result, without intercepting the integer part. 10/8=1.25; available (//) for floor division. 10//8=1;
5.** power operation, 3**2=9;
6. Logical operator: And,or,not;
Note: The other does not change. **,+,-, *,/,//,+,-, <,<=,>,>=,==,!=,and,or,not;
7.python in Elif=else if;
8. Unique ternary operator: condition operator. X if condition else y;
9. Assert assert. Throws an Assertionerror exception when the condition after the keyword is false.
10.while Condition: Loop body
11.for target in list: loop body; example for I in Zjh:print (i,end= ") z J H;
12.range ([Start,]stop[,step]); in which the parameters within the brackets are optional, step indicates the path. So,range the number of reference can be 1--3, when 1, the expression from 0--stop-1, when two, the expression from the start--stop-1, when three is indicated from the Start--end (end<stop), the step path is step;

Python learning about data types and looping essentials

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.