Python3.x based learning - popular understanding of their own way (a)

  The first learn any programming language statements beginning is to print "Hello World!",

python is no exception:

print("Hello World!")

  python is an explanatory compiler, interactive, and object-oriented scripting language (source Baidu Encyclopedia), why can learn so many languages, Python but had to learn it? Because the syntax is simple, the same function, Python might get 10 lines of code, java might be 100 lines. I have engaged in work is testing, functional testing in the case spent most of the time, the use of automation to assist test, if the use of high difficulty of other programming languages, is bound to make their work efficiency is reduced, so that the project process was can not effectively improved. Of course, Python has many disadvantages, such as running slow, language is not encryption. In short, any language has its own limitations, to choose their own is the best.

  This blog is mainly written record their own learning experience, any similarity, are generally not the same, ha ha

 

The data type 1 Python

With language similar to Java:

It can be divided into: 1 integer int, float float, Boolean bool, complex-type complex, the string str, listing list [], Dictionary dict {}, the set of set {}, tuple tuple ()

1. Integer int

Print (123 ) 

# use type view data type 
Print (type (123 )) 

# <class 'int'>
View Code

 

2. float float, double

print(123.456)
print(type(123.456))
# <class 'float'>
View Code

 

3. Boolean bool

print(True)
print(False)
print(type(True))
# True
# # False
# # <class 'bool'>
View Code

 

4. The complex-type complex

print(type(2j+3j))
# <class 'complex'>
View Code

 

The string str

 

Print ( " I love you " )
 Print (of the type ( " I love you " ))
 # I love you 
# <class 'str'>
View Code

 

 

6. List list

 

x = [1,2,3,'hello']
print(x)
print(type(x))
# [1, 2, 3, 'hello']
# <class 'list'>
View Code

 

7. tuple tuple

 

x = (1,2,3,'hello')
print(x)
print(type(x))
# (1, 2, 3, 'hello')
# <class 'tuple'>
View Code

 

 

8. dictionary dict

 

x = {"id":1,"name":"小明"}
print(x)
print(type(x))
# {'id': 1, 'name': '小明'}
# <class 'dict'>
View Code

 

9. collection set

 

x = {1,2,3}
print(x)
print(type(x))
# {1, 2, 3}
# <class 'set'>
View Code

 

Binary

  From my limited computer knowledge to understand, commonly used in binary, octal, hexadecimal, decimal, and it is widely used in computer binary

Binary to 0b (0,1), said octal representation to 0o (0,7), hexadecimal with 0x (0,9, af)

2.1 hex conversion

print(bin(10)) 
print(oct(10)) 
print(hex(10)) 
#0b1010
#0o12
#0xa
View Code

 

Last wrote: still not be written, to pit their own experience to write about, these people have a general tutorials, and more detailed written, do not delete this article, as a souvenir.

Guess you like

Origin www.cnblogs.com/johnsonbug/p/12556245.html