#!usr/bin/env python
#-*-Coding:utf-8-*-
#python的算法加减乘除用符号: +,-, *,/to indicate
#以下全是python2. x, 3.x above please in Python (printed in parentheses) For example: print (' 1+1= ', + +)
print ' *-----------------------------------------------------* separator '
Print "1+1=", #打印加法1 +1 results of 2
Print "2-1=", results of 2-1 #打印减法2-1 1
Print "3*1=", 3*1 #打印乘法3 x1 Results 3
Print "4/2=", 4/2 #打印除法4 ÷2 Results 2
print ' *-----------------------------------------------------* separator '
Print "1++1=", 1++1 #双 + number notation here means that the following 1 is positive, understandable 1+1=2
Print "1--1=", 1--1 #双-code This means that the following 1 is a negative number (equivalent to mathematics-negative negative positive) the disassembly of 1-(-1) =2
Print "3**2=", 3**2 #双 * indicates that the second party represents 3 of the 2 square, understood to be two 3 multiplied, 3x3=9
Print "4//3=", 4//3 #双/number means that the remainder here means 4 divided by 3, understanding 4 in addition to 3 digits 1, followed by decimals but because we take the whole, this 1 is the remainder
print ' *-----------------------------------------------------* delimiter '
print ' Childhood 99 multiplication table is as follows: '
‘‘‘
The first line. For loop statements A statement in Python that can execute commands repeatedly
Generate list Statement range (1,10) 1 start value, 10 end value, execution effect [1,2,3,4,5,6,7,8,9] default last one does not output n-1 so only to 9
Y in range (1,10) represents y from the list [1,2,3,4,5,6,7,8,9] and takes a value y=1,y=2...,y=9 into the loop to execute
The second line. Since the two-digit multiplication requires simultaneous generation of numbers, the end value of Y is resumed after each loop until the value ends.
X in range (1,y) the first cycle (1, (y=1) +1) list [+] perform 1x1
Second cycle (1,2+1) list [1,2][2,2] execution 1x2,2x2
......
Nineth cycle (1,9+1) list [1,9] ... [9,9] Execute 1x9,2x9 ... 9x9
The third line. The format of the output does not understand the basics of the previous section
Line four. In order to output the effect loop after a number is finished in the line wrap output
‘‘‘
For y in range (1,10): #第一行
For x in range (1,y+1): #第二行
Print x, ' x ', y, ' = ', X*y, ', #第三行
print ' #第四行
print ' *-----------------------------------------------------* delimiter '
#以下为打印结果:
Python basic algorithm synthesis: subtraction Arithmetic method