Python 3 Study Notes (5) ---- variables, recursion and high-level functions, python high-level functions
I. Variables
1. the variables defined in the subroutine are called local variables, and the variables defined at the beginning of the program are called global variables.2. The global variable scope is the whole program, and the local variable scope is the sub
Python built-in type (3) -- Comparison, python built-in type
Python has eight comparison operators:,,>,>=,==,!=,is,is notThey have the same priority. Their meanings are as follows:
Operator
Description
Less
Less than or equal
>
Greater
>=
Greater than or
How to use Python to perform simple operations on Excel, which is important for interface automation testingA. Prepare a JSON document in the following format:{"Register": {"mobile": "15500000090"},"Login": {"mobile": "15500000090", "Password": "111111"}}1. You may be confused, this format and normal JSON format a little different, the general JSON string is this {"mobile": "15500000090"}* Written in the above format is mainly to wrap a JSON string, w
This article mainly introduces how to use Python arrays. For more information, see 1. Python arrays can be divided into three types:
(1)List common linked listAfter initialization, you can dynamically add elements through specific methods.Definition method: arr = [element]
(2)Tuple fixed arrayOnce defined, the number of elements cannot be changed.Definition method: arr = (element)
(2)Dictionary typeThat is
Python learning diary 3 variable 2, logical judgment, for loop, python variable
Review the questions that occur when you write a quiz code.
The condition in the While statement. It should be when result = false and answer = input. If answer = input () is written outside the while clause, too small will be output as it was yesterday.
There is also the if statement
1 #meta-ancestor elements cannot be modified, cannot be added and deleted2 #Ganso is also orderly.3Tu = (12,'SF', 27,67,34,7,9,4,3,5,7)4 Print(TU)5 #Ganso can be converted to str,list with each other6 #Ganso can be sliced to iterate over an object7 #the first-level element of Ganso cannot be modified, but it is only a level element8T = ('a','b', ['A','B'])9T[2][0] ='X'TenT[2][1] ='Y' One Print(t) NO 3, Life is short, I learn
Create List subject = ["Liunx", "Python", "web", "Java"]#读取列表print (subject) #打印显示 [' Liunx ', ' python ', ' web ', ' Java '] #列表的切片, the slice index is the 0-based print (subject[0]) # NO. 0 index, That is, the first element of the list print (subject[1]) print (subject[2]) print (subject[3]) print (Subject[1:3]) # re
Python 3 is the latest version of Guido van Rossum's powerful universal programming language. Although it breaks backwards compatibility with the 2.x version, it cleans up some grammatical issues. This article is the second in a two-part series that builds on the previous installment of this series, covering more new features and more advanced topics such as the changes in abstract base classes, meta classe
the stack to overflow.Vi. Anonymous functionsAn anonymous function is one that does not require an explicit function to be specified#这段代码def Calc (n): return N**nprint (calc) #换成匿名函数calc = Lambda n:n**nprint (Calc (10))Actual use of the case listres = map (lambda x:x**2,[1,5,7,4,8]) for I in Res: print (i)Output125491664Seven, higher order functionsA variable can point to a function, which can receive a variable, and a function can receive another function as a parameter, a function calle
Reprinted from the programming faction http://codingpy.com/article/why-print-became-a-function-in-python-3/Original Brett CannonOriginal link: http://www.snarky.ca/why-print-became-a-function-in-python-3Translator: [Email protected] programming pieIn Python 2, print is a statement (statement), and in
Python 3 TutorialThe 3.0 version of Python, often referred to as Python 3000, or simply py3k. This is a large upgrade relative to earlier versions of Python. In order not to take too much of a burden, Python 3.0 did not consider b
Read a lot of Python books, note that I want Python 3, not 2. Very good recommendation, general exemption.
Reply content:Thank you for your invitation.
The basics of Python:
Recommended
Basic Python Tutorials(Turing Programming Series: Basic
Section 1 Python also has a good data type: String 2. A String is a String written in ''or" ". 3. Set the brian variable to" Always look on the bright side of life.! "[Python] # Set the variable brian on line 3! Brian = "Always look on the bright side of life! "Section 2 1 Exercise 1 set the variable caesar to Graham 2
and starts executing the next line of code.②python Continue statementsJumps out of the entire while and for loops relative to break. Loop, the Python continue statement jumps out of the loop. The continue statement is used to tell Python to skip the remaining statements of the current loop, and then proceed to the next round of loops.③
") compiled code:Builtins. Print ("Hello, world ")
If you are interested in builtins. Print, you can check it by yourself.
2. String interpolation (string insertion)
String interpolation makes string formatting easy. Let's look at the example:
Toy = "kitty"Print "Hello, $ {toy }"
Any valid boo expression can be inserted into the string. When a string is expanded, boo calculates the expression and then calls the tostring method of the expression result. You can write a few lines of simple code
causes another exception), the entire try statement will be executed after the control is complete.* If the exception occurs in the try code block and there is no matching limit t clause, the exception will be passed up to the program before entering try, or to the top layer of the process (use python to terminate the program and print the default error message)* If no exception occurs in the statements executed under the first line of try,
Reply content:Because Unicode,python3 is going to turn into a mainstream. In the 3.0 era, I began to turn to Python to write my own scripts, because Python 2.x is too tangled in Chinese coding. However, the current Python 3 library is still too small, although more and more libraries began to support. In addition, I wr
python code directly into. NET bytecode.SummaryPython has a lot of interpreters, but the most widely used is cpython. If you want to interact with the Java or. NET platform, the best approach is not to use Jython or IronPython, but to interact via network tuning to ensure the independence of each program.All of the code in this tutorial is only guaranteed to run under the CPython 3.5 release. Be sure to install CPython locally (that is, the installer
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.