Python Basics Details Summary, 0 basis a minute to master

Source: Internet
Author: User

Now that you want to start learning Python, you first have to download a python from the official website, which uses 3.6

Installation tutorial Baidu Experience is still very detailed.

So let's get to the chase!

Two ways to format output

The first is to format the output string with the% operation

The code is as follows:

Run the result of the above code output:

The second way to format the output string using the format () method

Code a straight line of statements.

You will find the same result after running!

Conversion of types in Python

Many beginners at the beginning of the study of Python are a bit unclear about the data type, such as:

    • A = 666 This is a definition of a is 666, the default is an integer type
    • B = ' 666 ' which is also directly defined and then the default is the string

There are three built-in functions in Python that let us do type conversions, they are int (), float (), and STR () function

the int () function receives a floating-point or appropriate string

For example: Int (3.1415), int (' 1314 '), int (' 3.1415 ')

So is the result of their operation the same?

The result is obvious that the INT () function receives a floating-point or a suitable string!

The float () function receives an integer and an appropriate string

For example: float (3.1415 ')

The STR () function turns a number of integers or floating-point numbers into strings

For example: Str (1231), str (3.1415)

So for the type of conversion understand, you can try it yourself

Some operations on the list

For example, age = [1,2,3,4,5,6] #其实这里面也可以放不同类型的数据

Lists can be changed, such as the addition and deletion of individual elements. We will introduce tuples later, which cannot be modified.

Here are some examples of the operations of the list

    • AGE[2] =13
    • Age[-1]=23
    • Someage = Age[2:4]
    • Someage = Age[0:5:2]
    • Del Age[1]
    • Age.append (' No fan of the program Dog ')

If there's something that you don't understand, you can leave a question underneath.

Python Basics Details Summary, 0 basis a minute to master

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.