First I have the basics of programming language, you have the best, so you will soon know Python.
Of course, because of my knowledge and learning limitations, please the vast number of ape/yuan to forgive and correct, common progress.
First of all, Python is a lazy language ———— syntax is relatively streamlined and certainly not comparable to Scala.
Again, there is no sign-ending symbol at the end of each statement in Python (the general language is the number ———— ";" ), judged by the language itself.
However, it has a colon ":" and a dependency indentation, instead of a block of code marked with the old parenthesis "{}".
Of course, this determines that he is sensitive to the code format, such as the following format is correct:
1 if inputnum > luky_num:2 print("Thereal number is smaller ... ")
View Code
Notes for Python:
One line is the pound sign #
Multi-line is six single quotes, to you oh no wrong, 6 single quotes!
‘‘‘
Print ("1111111111111111111")
Print ("2222222222222222222")
Print ("3333333333333333333")
‘‘‘
Oh, that's right. 6 single quotes and a function is to provide the same format of the string, as follows:
1 " " 2 Hello, welcoming Python word! 3 Wall, please ask me question. 4start: " " 5 Print (str)
Common types of Python
1) integral type--int--digit
Python has 5 types of numbers, the most common being the integral type Int,int Python method is very useful. Example: 1234,-1234
2) Boolean--bool--notation = =
Boolean is a special type of Python number, it is only true and false two kinds of values, it is mainly used to compare and judge, the result is called a Boolean value. For example: 3==3 gives true,3==5 gives false
3) string--str--with "' or" "
For example: ' www.iplaypython.com ' or ' hello '
4) List--list--with [] notation
Example: [1,2,3,4]
5) tuple--tuple--with () notation
For example: (' d ', 300)
6) Dictionary--dict--in {} notation
For example: {' name ': ' Coco ', ' country ': ' China '}
python variable data type: list list[], dictionary dict{}
python immutable data type: int, string str ', tuple tuple ()
First, declaring variables
Python declares that a variable does not require a keyword, nor does it have a type, and the language itself is "type inferred."
Like what:
STR1 = "What type am I?" "#声明变量: The language itself will determine that this is a string
NO = 5 #声明变量: The language itself will determine that it is an int
Li = ["I", "AM", "python", "^|^"] #声明变量: The language itself will determine this is the list
DiC = {' K1 ': ' v1 ', ' Adam ': ' Eve '} #声明变量: The language itself will determine that it is a dictionary (dict)
Tu = (1,2,33, 17101012345) #声明变量: The language itself determines that this is a tuple (tuple)
Second, the operator encyclopedia in Python
# ################# #数字运算符 ###############################
#% modulo--returns the remainder of the division
# * * Power--Returns x's Y-square
#/ Pick-up-return
#//Divide--Returns the integer portion of the quotient
# = = equals--Compares two objects for equality
#! = does not equal--compares two objects for equality
# = equals--Assignment
# > greater than
# < less than
# <= less than equals
# >= greater than equals
# + = addition Assignment
#-= Subtraction Assignment
# *= multiplication Assignment
#/= Division Assignment
#%= modulo Assignment
# **= Power Assignment
# ########### #位运算符 #######################################
# & Bitwise AND Operation
# | Bitwise OR Operation
# ^ Bitwise XOR
# ~ bitwise negation
# << bitwise Left SHIFT Operation
# >> bitwise right-shift Operation
# >> bitwise right-shift Operation
# ########### #逻辑运算符 # ######################################
# and logical with
# or logical OR
# not logical non
# ########### #成员运算符 ################ ####################### the element in the front of the
# in operator in the element behind the operator? True: In; False: Not the element in the front of the
# not operator is in the element behind the operator? True: Not in; False: are references from the same object before or after the
# ########### #身份位运算符 ######################################
# is operator? True: Yes; False: Not the
# not before and after is the operator not referencing from the same object? True: No; False: Yes
Not to be continued
A preliminary knowledge of Python (i.)