#5-5
def swit(mon):
cent = [25,10,5,1]
n=[]
y=mon*100
for i in cent:
x,y = divmod(y,i)
n.append(int(x))
print n
swit(input("dollar"))
#5-6
def calculater():
a=raw_input(">")
for i in ['**','+','-','*','/','%']:
if i in a:
x=a.split(i)
break
for j in range(2):
if '.' in x[j]:
x[j]=float(x[j])
else:
x[j]=int(x[j])
dict={'+':x[0]+x[1],'-':x[0]-x[1],'*':x[0]*x[1],
'/':x[0]/x[1],'**':x[0]**x[1],'%':x[0]%x[1]}
return dict[i]
print calculater()
#5-13
def Timeconvert():
time=raw_input("the time is:")
a=time.split(':')
ntime=int(a[0])*60+int(a[1])
return ntime
print Timeconvert()
#5-15
def Twoints():
m=a1=int(raw_input("The first number:"))
n=a2=int(raw_input("The second number:"))
while True:
a1,a2=a2,a1%a2
if a2==0:
print "most is:", a1
print "least is:", m*n/a1
break
Twoints()
#5-16
sum=float(raw_input("Enter opening balance:"))
pay=float(raw_input("Enter monthly payment:"))
print " Amount Remaining"
print "Pymt# Paid Balance"
print "----- ------ -------"
n=0
print "0 $ 0.00 $100.00"
while sum>=pay:
n+=1
sum-=pay
print "%d $%5.2f $%6.2f" % (n,pay,sum)
print "%d $%.2f $%6.2f" % (n+1,sum,0)
转载于:https://my.oschina.net/u/2519674/blog/651623