1.floor Division (this is only about division, others do not mention)In Python3, there are two kinds of division operations, one is true, the other is floor division, and the two are separate, as shown in the code:2. Use of power (* *)A = 2**2**32= (2 **2) **323. For an even and odd number within 100, pay attention to the difference between the code.# for an even number within 100 (inclusive)num = when num
love" + "You") I loveyou>>> print (' I love ' + ' you ') I love You>>> print ("I love your" *8) I love you I love you I love you I love you I love you I love you I love you I love you >>> print ("I love you\n" *8) I love YouI love YouI love YouI love YouI love YouI love YouI love YouI LoveError code:#python2系列中可以使用, but error >>>print "Hello world!" in Pyhton3 series Syntaxerror:missing parentheses in call to ' print '#C语言输出函数 >>> printf ("Hello worl
Topic:Hello world!Simple Interactive (interactive, file-style) textbook P19The user enters two numbers, calculates and outputs the sum of two digits (try to implement it in one line of code).The user enters the triangular three-side length and calculates the area of the triangle: (Helen Formula)Enter a radius to calculate the area of the circle.Draw a set of identical tangent circlesDraw a PentagramDraw an all-yellow pentagram1. Hello world!Print ('He
">>>for each in Zip (LIST,STR):Print (each)(1. "M") ...4. Create and Invoke functions:>>>def myfirstfunction ():Print ("Hello World")>>> myfirstfunction ()Hello World>>>def First (name):Print (name+ "is Handsome")>>>first ("Myj")Myj is handsome.5. Collecting parameters>>>def Test (*parms):Print ("%d parameters"%len (parms))Print ("The second parameter is:", parms[1]) # * Pack>>>def Test (*parms) #* unpacking>>>a=[1,2,3]>>>test (*a)There are three parameters, the second parameter is 2.6. function
can only look at the data to see what kind of things in the class, inheritance, when the creation of the instance when the change occurred.*, The relationship between classes in Python can be vertical, using the inheritance mechanism to use all the properties and methods in the base class, but the parent class can not use the methods and properties of the subclass, such as fish and sharks, carp salmon, and so on; Of course, there can be horizontal re
Topic:
Hello world!
Simple Interactive (interactive, file-style) textbook P19
The user enters two numbers, calculates and outputs the sum of two digits (try to implement it in one line of code).
The user enters the triangular three-side length and calculates the area of the triangle: (Helen Formula)
Enter a radius to calculate the area of the circle.
Draw a set of identical tangent circles
Draw a Pentagram
Draw an
defined variables. Each module has its own namespace, called the global namespace, which records the module's change, including functions, classes, other imported modules, module-level variables, and constants. There is also a built-in namespace, any moduloblock can access it, which holds the built-in functions and exceptions. when a line of code is to use a variableThe value of x, Python will go to all av
NOTES: 1, inline function: Create another function inside function 2, closure: The important syntax of functional programming, if in an intrinsic function, the external scope (but not the global scope of the variable) is referenced, then the intrinsic function is considered a closure. 3. nonlocal: Used to declare a local variable test question 0. What keyword should you use if you want to modify the value of a global variable in a function? Global 1. In a nested function, what keyword should you
1. VariablesIn other programming languages, when a variable is assigned a value to a name, the value is stored in memory, and the name is called a variable.In Python, it's a bit different, it's more like putting a name on top of a value, so you can say that Python has no variables.34= a + bprint (c)2. Places to note when using variables:You need to assign a value to the its first before using the variable.V
1. Use of flowchart.In the early stages of writing a program, you can try to write a flowchart, understand the logical sequence, realize the function, judge the condition, etc.2. Built-in functionsBIF = = Built-in-function, querying the built-in functions in Python, you can use code:Dir (__builtins__)3. For a function that is not clear, you can learn about functions by using Help (function).4. The game source code
‐‐‐| ')Print (' |‐‐‐1: Query contact information ‐‐‐| ')Print (' |‐‐‐2: Insert new contact ‐‐‐| ')Print (' |‐‐‐3: Delete existing contact ‐‐‐| ')Print (' |‐‐‐4: Exit Address Book Program ‐‐‐| ')contacts = Dict ()While 1:instr = Int (input (' \ n Please enter the relevant instruction code: '))If InStr = = 1:Name = input (' Please enter contact name: ')If name in Contacts:Print (name + ': ' + contacts[name])ElsePrint (' The name you entered is no longe
(support Chinese), which makes the code is legitimateDo it0.S.isalnum () All characters are numbers or letters, return True, otherwise FalseS.isalpha () All characters are letters, returns true for true, otherwise FalseS.isdigit () All characters are numeric and true returns True, otherwise False is returnedS.islower () All characters are lowercase, true is true, otherwise False is returnedS.isupper () All characters are uppercase, returns true for t
= ' abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz 'Number = ' 0123456789 't = ' y 'While t = = ' Y ':Password = input ("Enter the password combination you need to check:")# Use NUM to count the number of occurrences of a character typenum = 0A = b = c = 0# The input cannot be emptywhile password = = ":Password = input ("Cannot be empty, please reenter:")# calculates the value of NUM, if the input is all characters, then num=0, so there will be If Password.isnumeric () or Password.isalpha
Since learned the Turtle module, drew a lot of simple strokes. Like Piglet Paige, Doraemon and so on, but these still do not allow people around to feel the power of Python, is still every time the force will be beaten face. It's like you painted this with turtle.Someone else took out this.What to do? In the face of the library so rich Python, not a library, we h
Let's talk about the cool-Performance of python and the cool-Performance of python.
I have been writing php for 10 years. Python has been rewritten this year.
In contrast, the python niubi:
#) Modularization is better than php;
#)
Five cool Python tools and python tools
A good tool can get twice the result with half the effort. The Python Community provides enough excellent tools to help developers implement some ideas more conveniently, the following tools have brought a lot of convenience to my work. We recommend you to pursue beautiful th
A Cool Idear-> Python tail recursion optimization, idear-python
It's cool to share it with a foreign website. In general, Python and Java, C # do not have the ability to automatically optimize tail recursion. recursive calls are widely criticized for being limited by the cal
Python implements the example code for drawing python Python.
This article mainly studies the example of the Python programming turtle and draws a colorful Python .. The details are as
Accidentally in a foreign site to see, very cool, sent to share. In general, Python, like java,c#, has no tail-recursive auto-optimization capability, and recursive calls are widely criticized for the length of the call stack, but this madman solves the problem in a bizarre way and implements it in Python. This python
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.