Basic types of Python

Source: Internet
Author: User

Objective:

What is code?

Code is the mapping of real-world things in the computer world.

What do you write code for?

Writing code is to describe things in the real world in a computer language.

One, number: shaping and floating-point type

Integral type: int

Float type: float (no single and double precision points)

Special note that 2/2=1.0 get float result 2//2=1 get is int result

Binary, 10, 2, 8, 16

Three, the representation and transformation of the system

OB indicates 2 binary 0B10 =2

0o = 8 binary 0o10=8

0x = 16 binary 0x10=16

Bin () can convert any number of bytes into binary bin (0x10) = ' 0b10000 '

int () converts any number of bytes into a decimal int (0x10) =16

Hex () converts any number of bytes into hex hex (+) = ' 0x10 '

The Oct () can convert any number of bytes into an octal Oct (8) = ' 0o10 '

Iv. Boolean types and complex numbers

BOOL Boolean type: Denotes True and false

Complex complex J denotes 36j

BOOL (0), BOOL ("), bool ([]), BOOL ({}), bool (None) are False

Five, single quotes and double quotes, three quotation marks (in English)

"Let's go" = ' let\ 's go ' = ' Let's Go '

"Content"

Six, escape character

Special characters

Characters that cannot be "seen"

Characters that are conflicting with the language itself syntax

\ nthe line break

\ ' Single quotation mark

\ t Transverse tab

Seven, original string

When an R is prepended to a string, it is not a normal string, but a primitive string

Print (R ' c:\no\nother ') output: C:\no\nother

Eight, string arithmetic

+ string concatenation

* String multiplication ' Hello world ' *2= ' Hello Worldhello world '

String index ' Hello World ' [1] = ' e ' or ' Hello Worldhello world ' [ -5]= ' W '

Intercept string ' Hello World ' [0:2]= ' he '

Basic types of Python

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.