已采纳回答 / idancer
一是print的区别。python2中print是语句,要显示的对象不需要括号;python3中print是函数,要显示的对象需要加上括号。如:python2中的print ‘A=’,5。在python3中改为print(‘A=‘,5)。这是我们编程中经常需要注意的问题。二是取值范围的区别。python2中用xrange ,python3中用range。如:python2中的 xrange( 0, 4 ) 改为python3中的range(0,4)。关键字更清楚明白啦。三是字符串存储的区别。python2...
2019-04-24
print r'''"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.'''
Whether it's nobler in the mind to suffer.'''
2019-04-24
def move(n, a, b, c):
if n==1:
print a,'-->',c
return
print a,b,c,n,'------\n'
move(n-1,a,c,b)
print a,b,c,n,'++++++'
print a,'-->',c
print a,b,c,n,',,,,,,,'
move(n-1,b,a,c)
print a,b,c,n+3,'1111111111111\n'
move(4, 'A', 'B', 'C')
逻辑结构查看方式
if n==1:
print a,'-->',c
return
print a,b,c,n,'------\n'
move(n-1,a,c,b)
print a,b,c,n,'++++++'
print a,'-->',c
print a,b,c,n,',,,,,,,'
move(n-1,b,a,c)
print a,b,c,n+3,'1111111111111\n'
move(4, 'A', 'B', 'C')
逻辑结构查看方式
2019-04-23
L = [75, 92, 59, 68]
sum = 0.0
for score in L:
sum = sum + score
aver = sum/len(L)
print aver
sum = 0.0
for score in L:
sum = sum + score
aver = sum/len(L)
print aver
2019-04-23
已采纳回答 / weixin_慕斯卡6428930
name=['Adam','Bart']k=0for i in name: k=k+1 j=i.lower() name.append(j) if(k==2): breaks = set(name)print 'adam' in sprint 'bart' in s<...code...>
2019-04-23