def s(x1, d, n):
i = 0
sum = 0
while i < n:
sum = sum + x1
x1 += d
i += 1
print sum
s(1, 3, 100)
i = 0
sum = 0
while i < n:
sum = sum + x1
x1 += d
i += 1
print sum
s(1, 3, 100)
2019-04-24
x = int(input("请输入x 坐标"))
y = int(input("请输入y 坐标"))
if(x==0 and y==0):
print("原点")
elif(x==0):
print("y 轴")
elif(y==0):
print("x 轴")
elif(x>0 and y>0):
print("第一象限")
elif(x<0 and y>0):
print("第二象限")
elif(x<0 and y<0):
print("第三象限")
else:
print("第四象限")
y = int(input("请输入y 坐标"))
if(x==0 and y==0):
print("原点")
elif(x==0):
print("y 轴")
elif(y==0):
print("x 轴")
elif(x>0 and y>0):
print("第一象限")
elif(x<0 and y>0):
print("第二象限")
elif(x<0 and y<0):
print("第三象限")
else:
print("第四象限")
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
这个IDE有毒。。。本地完全没问题的一段码:for k,v in d.items(): print k+':'+str(v) 到了这里就不通过了。。。也是无语
2019-04-22
print "I'm python"
print '"fool boy"'
print 'Learning "Python" is cool'
#it's error .
#print 'Bob said "I'm OK"'
print 'Bob said "I\'m OK".'
print 'Bob said \"I\'m OK\".'
#the result
I'm python
"fool boy"
Learning "Python" is cool
Bob said "I'm OK".
Bob said "I'm OK".
print '"fool boy"'
print 'Learning "Python" is cool'
#it's error .
#print 'Bob said "I'm OK"'
print 'Bob said "I\'m OK".'
print 'Bob said \"I\'m OK\".'
#the result
I'm python
"fool boy"
Learning "Python" is cool
Bob said "I'm OK".
Bob said "I'm OK".
2019-04-22
def firstCharUpper(s):
return s.upper()[:1]+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
感觉s[0].upper和s.upper()[:1]一样的,我这种麻烦点
return s.upper()[:1]+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
感觉s[0].upper和s.upper()[:1]一样的,我这种麻烦点
2019-04-22
如例子‘Bob said \"I\'m OK\”.’中,Ok后面的\he said后面的\去掉打印出来的效果是一样的,I后面的那个\是必须的。那什么时候才需要加\呢?
2019-04-22
s = 'Python was started in 1989 by "Guido".\nPython is free and easy to learn.'
print s
print s
2019-04-21