python入门-----有编程基础，直接写代码

http://www.cnblogs.com/CheeseZH/archive/2012/11/05/2755107.html

#输入三个整数，将其按从小到大输出。
x,y,z=(int(i)for i in input().split(' '))
print(min(x,y,z),end=' ')
print(x+y+z-max(x,y,z)-min(x,y,z),end=' ')
print(max(x,y,z),end='\n')

#输入几个空格隔开的整数，输出其和。
a=(int(i)for i in input().split(' '))
print(sum(a))

#将输入的若干整数添加到数组中
data=[3,4,2,2]
i=(int(i) for i in input().split(' '))
for j in i:
data.append(j)
print(data)

#输出9*9乘法表
for i in range(1,10):
for j in range(i,10):
print (i,'*',j,'=',i*j,end=' ')
print (' ')

#素数判断
from math import sqrt
def sushu(n):
flag=1
k=int(sqrt(n))
for i in range(2,k+1):
if n%i==0:
flag=0
break
return flag

#输出100以内的素数
data=[]
for i in range(2,101):
data.append(i)
for j in data:
print (j,end=' ')
i=j
while i*j<50:
if(i*j in data):
data.remove(i*j)
i=i+1
print(' ')
print(data)

print(len(data))

# Python 3: Simple arithmetic
>>> 1 / 2
0.5
>>> 2 ** 3
8
>>> 17 / 3  # classic division returns a float
5.666666666666667
>>> 17 // 3  # floor division
5

# Python 3: Fibonacci series up to n
>>> def fib(n):
>>>     a, b = 0, 1
>>>     while a < n:
>>>         print(a, end=' ')
>>>         a, b = b, a+b
>>>     print()
>>> fib(1000)
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987

# Python 3: List comprehensions
>>> fruits = ['Banana', 'Apple', 'Lime']
>>> loud_fruits = [fruit.upper() for fruit in fruits]
>>> print(loud_fruits)
['BANANA', 'APPLE', 'LIME']

# List and the enumerate function
>>> list(enumerate(fruits))
[(0, 'Banana'), (1, 'Apple'), (2, 'Lime')]

# Python 3: Simple output (with Unicode)
>>> print("Hello, I'm Python!")
Hello, I'm Python!

# Input, assignment
>>> name = input('What is your name?\n')
>>> print('Hi, %s.' % name)
Python
Hi, Python.

# For loop on a list
>>> numbers = [2, 4, 6, 8]
>>> product = 1
>>> for number in numbers:
...    product = product * number
...
>>> print('The product is:', product)
The product is: 384