Discover core python applications programming, include the articles, news, trends, analysis and practical advice about core python applications programming on alibabacloud.com
, num2 to the same type, and then returns in tuples
Divmod (NUM1,NUM2), return (NUM1/NUM2,NUM1%NUM2)
Pow (num1,num2) to achieve num1**num2
Round (flt,ndig=0), rounding the floating-point number FLT, saves the Ndig decimal place. The default feels 0.
Functions for integral types only
Binary conversion function, Oct (), Hex ()
ASCII conversion function
Chr () accepts a single-byte integer value, returning the corresponding
The second edition of Python core programming, which is much more detailed than the second edition of the Python Basics tutorial, enriches many details, although it is a classic introductory book, but I find there are some obvious mistakes. In this chapter of object-oriented progra
string, if beg and end specify a range, the check is included in the range, or returns 1 if the index value is returned. String.index (str, beg = 0, end = Len (string)) is the same as the Find method only if Str does not report an exception in string String.isalnum () returns True if the string has at least one character and all characters are letters or numbers, otherwise false String.isalpha () returns True if the string has at least one character and all characters are letters, otherwise fal
)
Convert an object to an integer
Len (obj)
Returns the length of an object
Open (FN, mode)
Open a file named fn in mode (' r ' = Read, ' W ' = Write)
Range ([[Start,]stop[,step])
Returns a list of integers. The starting value is start and the ending value is stop-1; StartThe default value is 0, and the step default is 1.
Raw_input (str)
Waits for the user to enter a string that can provide an optional parameter
1p18.python the standard library location (typically the location of string.py, or you can find it whereis python)C:\Python27\Lib/usr/lib64/python2.6Third-party library location (typically site-packages location)C:\Python27\Lib\site-packages/usr/lib/python2.6/site-packages2p14.windows when you run a Python script, the double-click exits directly. Add the Raw_inpu
returns in tuples
Divmod (NUM1,NUM2), return (NUM1/NUM2,NUM1%NUM2)
Pow (num1,num2) to achieve num1**num2
Round (flt,ndig=0), rounding the floating-point number flt, saving the Ndig decimal place, the default is 0.
Functions for integral types only
Binary conversion function, Oct (), Hex ()
ASCII conversion function
Chr () accepts a single-byte integer value, returning the corresponding character
Ord () takes a c
Python core programming-Chapter 5-personal notes, Chapter 5
1. Use del to delete references to objects
>>> a = 123>>> a123>>> del a>>> aTraceback (most recent call last): File "
2. Integer
(1) Boolean value range of this type: Boolean value True and Boolean value False
(2) Standard integer long integer
① The value range of p
I will share with you the answers to my core Python programming exercise.Because it is not from official resources, it is your own exercises. It may be wrong or not the best solution.
[Recommendation] blog: Python module of niubHttp://www.cnblogs.com/chu888chu888/archive/2011/01/09/1931084.html
[Recommendation] recomme
Here are some of the post-lesson exercises that you do when you're learning python core programming. Now paste them out to record your learning process. Brother is a mechanical background, a lot of practice topics written is very mechanical. Although the script can be written to meet the requirements of the topic, but the efficiency may not be the best, so, the y
The Python statement adds a newline character to each line by default, as long as you add a comma at the end to change the behavior
Automatically returns the None object if no return is in the function
PEP (Python Enhancement proposal abbreviated) Http://python.org/dev/peps
Dir () Displays the object properties and, if there are no parameters, displays the names of the global variables
Help
eval (), but is well suited for print statement outputThe repr () and ' operations are very similar in character and function, they return an "official" string representation of an object, and in most cases the object can be re-acquired by Eval ().In summary, the REPR () output is more friendly to Python, the STR () output is more user friendly, and in many cases the output of the three is exactly the same.(4) type () Isinstance ()Isinstance () is a
num1 * NUM2/GCD (NUM1, num2) print gcd (24 , 18 ) print LCM (24 , 18 ) 5-16 household finances. Given an initial amount and monthly cost, use the loop to determine the remaining amount and the current month's expenditure, including the last expenditure. The Payment () function uses the initial and monthly amounts, and the output should resemble the following format (the numbers in the example are for demonstration purposes only): def pay():Balance = Float (raw_input (' Enter Opening balance
The Spring Festival finally over, return to enrich the study of life. Open the long-lost CSDN blog, see the official push "blog markdown Editor Online", let me immediately have the desire to write, is really the welfare of programmers. Before reading a variety of article books, are made with markdownpad notes, like and accustomed to markdown concise grammar.All kinds of convenience. In order to try the results, the previous reading of "Python
2. Python Start 2.1 Print1 Print " Hello world! "2.2_: The value of the last expression>>: Output redirection%: Prints the formatted string and values for the style, and the value after% is a tuple object, with "()" containing thePrint "%s is a number%d."% ("Python", 6)ImportSYSPrint>> Sys.stderr,"msg"file= Open ("filename","a")Print>> file,"File MSG."file.close () Hello= Raw_input ("Hello:")Print "Num:%d.
Chapter III Python BasicsI. Statements and syntax\ n Standard Line delimiter\ Continue on line; Connect two statements to one line: Separate the head and body of the code blockCode blocks are represented as indented blocksPython files are organized in a modular formatIi. Assigning values to variablesNote: Objects in Python are passed by reference!Python does not
4-1python objectsAll Python objects has three Attributes:type,id,and value.All was readonly with a possible expection of the value (which can being changed only if the object is mutable).4-5str () and repr ()Repr () is a built-in function while STR () was a built-in function, changed to a factory function Inpython2.2.they would Both returns a string representation of an OBJECT;HOWEVER,STR () returns a printable string representation while repr () ret
Python core programming-exercises-Chapter 2, Chapter 2
PS: PDF online address: http://bcmi.sjtu.edu.cn /~ Zhaohai/ptm2012/data/Python-kernel.programming.v2.pdf
2-1 variables, print and string formatting operators. Start the interactive interpreter, assign values (strings, values, and so on) to some variables, and displ
The Create file (maketextfile.py) script reminds the user to enter a file name that does not yet exist, and then the user enters each line of the file, and then writes all the text to the text file1 #!/usr/bin/env python 2 3 ' maketextfile.py--creat text file ' 4 5 import os 6 ls = os.linesep 7 8 # get Fil E name 9 while true:10 if Os.path.exists (fname): #不存在返False, there is a return True11 print "ERROR: '%s ' already exists"% fname
1,false corresponding to integral type 0the Python object that ② has has a built- in true or False value. The Boolean value of the following object is false:None;False (Boolean type);All the values are zero numbers;0 (integral type);0.0 (floating point type);0L (Long integer type);0.0+0.0j (plural );"" (empty string);[] (empty list);() (empty tuple);{} (empty dictionary);The Boolean value of an object that is not a value other than the one listed abo
has been a programmer for many years, the first time to open a blog, welcome to fellow critics, comments.Recently obsessed with Python, after reading the Python Basics tutorial, and holding a "Python Core programming (third edition)" began to chew.After reading the first cha
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.