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