Python Common data types

Source: Internet
Author: User
Python built-in data types include numbers, strings, lists, tuples, and dictionaries

1. Integral type and floating point type

As a result, the type of the variable can be changed, and when Python assigns a value to an already existing variable, it actually creates a new variable, even if the variable name is the same, but their identity is different, and the identity can be output with the ID function.


2. Boolean type
Boolean for logical operations, there are two values true and false, the identity of the true and false, actually with Java nothing
Difference

3.Python operator
(1) The arithmetic operators used in Python are basically the same as the operators in mathematics, with + 、-、 *,/
and parentheses, the order of operations is first multiplication after the addition and subtraction, the parentheses precedence calculation. Here are a few examples to illustrate:

(2) There are two arithmetic operators are% and * *, (modulo operation and exponentiation), modulo operation is to take the remainder, the power operation is a result of a multiplicative, the sample code is as follows


I'm not saying much here. It's easy to understand, to add that Python is not supported by the self-increment operator + + and the self-decrement operator.

Use of 4.Python strings
(1) There are three ways to represent a string in Python: single quotes, double quotes, and three quotes, as shown in the following example:

(2) Other uses of strings
Python strings can be multiplied by multiplying an integer and a string, such as the number 6 by the string ' A ', the structure is the string aaaaaa, equivalent to string a copied 6 times, the code is as follows:

Python Common data types

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.