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-08-16
L = []
a = 1
n = 100
while a <= n:
L.append(a*a)
a+=1
print sum(L)
a = 1
n = 100
while a <= n:
L.append(a*a)
a+=1
print sum(L)
2019-08-16
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
else:
s.add(x)
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
else:
s.add(x)
print s
2019-08-16
最新回答 / 清风菜鸟
s = set(['Adam', 'Lisa', 'Paul'])L = ['Adam', 'Lisa', 'Bart', 'Paul']for new in L: if new in s: s.remove(new) s.add(new)print s按理说这个才是对的,不同点在于没有用else.判断如果在就remove
2019-08-16
最赞回答 / 程序鸭
t = ('abc') #这里的 'abc'代表的是一个字符串类型的数据 所以你print之后输出的就是一个字符串,括号为优先级运算而不是元组的格式print tt = ('Adam',) #这里的字符串后面加了 , 符合元组的格式,所以就以元祖的格式输出,这是我的理解,不知道你的理解是什么样的呢?print t
2019-08-16
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:'+str(d.get('Adam'))
print 'Lisa:'+str(d.get('Lisa'))
print 'Bart:'+str(d.get('Bart'))
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:'+str(d.get('Adam'))
print 'Lisa:'+str(d.get('Lisa'))
print 'Bart:'+str(d.get('Bart'))
2019-08-15
def firstCharUpper(s):
return '%s'%s[0:1].upper()+'%s'%s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return '%s'%s[0:1].upper()+'%s'%s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2019-08-15
def average(*args):
if not args:
print 0.0
else:
print sum(args)*1.0/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
if not args:
print 0.0
else:
print sum(args)*1.0/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2019-08-15
def greet(n = 'world'):
print 'hello,%s.'%n
greet()
greet('Bart')
print 'hello,%s.'%n
greet()
greet('Bart')
2019-08-15
sum = 0
x = 1
while x<100:
sum=sum+x
x=x+2
print sum
x = 1
while x<100:
sum=sum+x
x=x+2
print sum
2019-08-15