The learning journey of Python ——— basic data types

Source: Internet
Author: User

The data is the variable value

int integral type
Definition: age=10 #age =int (10)
For identification: Age, grade, ID number, QQ number, number

float Float Type
Definition: salary=3.1 #salary =float (3.1)
Used to identify: salary, height, weight

String

The character that is quoted in Python is the string type

Definition name= "Sunny" #name =str (' Egon ')

There is no difference between single and double quotes

The list in [], separated by commas, can hold N of any type of value. The count order in the list starts at 0

Definition: room=[1, ' Xiaohong ', [' A ', ' B ']

A list can be nested

When a nesting of a in a list's suite is taken

Print= (Room[2][0])

Dictionary

Dictionaries are somewhat similar to lists, but better than lists. The purpose of our use of lists and dictionaries is to access the values, and the value in the list is to know the value in the list

Position. Because the dictionary specifies a hard mapping relationship type, the arrangement can be unordered, arbitrary.

Definition: info={' name ': ' Zhou ', ' age ': $, ' food ': ' Apple ' #info =dict ({' name ': ' Zhou ', ' age ': ' Food ': ' Apple '}) Used to identify: when storing multiple values, each value has a unique key that can be more easily and efficiently evaluated.

Print (info[' food ')

Lists and dictionaries can print multiple values at once

Print (info[' name '],info[' age ')

Zhou 18

Boolean

Boolean value two consciousness True one False

Boolean is a logical operation that determines whether a condition is established. A false identity with true identity is not established.

The learning journey of Python ——— basic 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.