x=raw_input()
y=raw_input()
z=raw_input()
lst=[]
lst.append(x)
lst.append(y)
lst.append(z)
lst.sort()
for i in range(0,3):
print lst[i],
a=1
b=2
a,b=b,a
print a,b
str.zfill(x),在str前面填充0,以达到x宽度;
string.zfill(x,y),在x前面填充0,以达到y宽度。
import string
for i in range(6):
print string.zfill(i,5)
str="hello"
print str.zfill(10)
output:
00000
00001
00002
00003
00004
00005
00000hello
for i in range(1,10):
for j in range(1,i+1):
print i,'*',j,'=',i*j,
print ''
import math
for i in range(1,101):
if i==1:
continue
else:
flag=1
for j in range(2,int(math.sqrt(i))+1):
if i%j==0:
flag=0
break
if(flag==1):
print i
for i in range(1,10000+1):
tmp=i
s=0
while(tmp!=0):
s+=pow(tmp%10,3)
tmp/=10
if(s==i):
print i
import math
x=int(raw_input("raw_input"))
i=2
k=x
while(i<=k):
if(x%i==0):
x/=i
if(x==1):
print i
break
else:
print i,'*',
else:
i+=1
s=raw_input()
alpha=0
space=0
digit=0
other=0
for c in s:
if c.isalpha():
alpha+=1
elif c.isspace():
space+=1
elif c.isdigit():
digit+=1
else:
other+=1
print alpha,space,digit,other
import math
lst=[1]*104
for i in range(2,int(math.sqrt(100))+1):
if lst[i]==1:
for j in range(i*2,100,i):
lst[j]=0
for i in range(2,100):
if lst[i]==1:
print i,' '
a=[]
for i in range(5):
a.append(int(raw_input()))
a.sort()
for i in range(5):
print a[i],' ',
a=[]
for i in range(5):
a.append(int(raw_input()))
tmp=0
for i in range(5):
for j in range(5-i-1):
if (a[j]>a[j+1]):
tmp=a[j]
a[j]=a[j+1]
a[j+1]=tmp
for i in range(5):
print a[i],' ',
a=[0,10,20,30,40,50]
x=int(raw_input())
for i in range(0,len(a)):
if a[i]>x:
a.insert(i,x)
break
for y in a:
print y,
#-*-coding:utf-8-*-
f=open("test.txt",'w')
f.write("hello world ")
f.write("hello python ")
f.close()
f=open("test.txt",'r')
content=f.readlines() #读取文件中的所有行,存储在列表中
print type(content)
for i in range(len(content)):
print content[i],
output:
<type 'list'>
hello world hello python