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'>
2. float float, double
print(123.456) print(type(123.456)) # <class 'float'>
3. Boolean bool
print(True) print(False) print(type(True)) # True # # False # # <class 'bool'>
4. The complex-type complex
print(type(2j+3j)) # <class 'complex'>
The string str
Print ( " I love you " ) Print (of the type ( " I love you " )) # I love you # <class 'str'>
6. List list
x = [1,2,3,'hello'] print(x) print(type(x)) # [1, 2, 3, 'hello'] # <class 'list'>
7. tuple tuple
x = (1,2,3,'hello') print(x) print(type(x)) # (1, 2, 3, 'hello') # <class 'tuple'>
8. dictionary dict
x = {"id":1,"name":"小明"} print(x) print(type(x)) # {'id': 1, 'name': '小明'} # <class 'dict'>
9. collection set
x = {1,2,3} print(x) print(type(x)) # {1, 2, 3} # <class 'set'>
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
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.