sum = 0
x = -1
while True:
x = x + 2
if x > 100:
break
sum+=x
print sum
x = -1
while True:
x = x + 2
if x > 100:
break
sum+=x
print sum
2018-04-14
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key,':',d[key]
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key,':',d[key]
2018-04-14
# -*- coding: utf-8 -*-
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
str=input("input \n")
for (key,value) in d.items():
if value == str:
print key
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
str=input("input \n")
for (key,value) in d.items():
if value == str:
print key
2018-04-14
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2==0:
continue
else:
sum+=x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2==0:
continue
else:
sum+=x
print sum
2018-04-14
print 打印出变量的值,在一个中a等于字符串python,在做与或非运算时为逻辑值1,1或上任何都为1,所以打印出a的值 python
在第二个中,变量b为空,做逻辑运算认为是0,0或上任何值取决与后者,打印出world
在第二个中,变量b为空,做逻辑运算认为是0,0或上任何值取决与后者,打印出world
2018-04-13
sum = 0
x = 1
n = 1
while True:
if n<=20:
sum+=pow(2,n-1)
n=n+1
else:
break
print sum
x = 1
n = 1
while True:
if n<=20:
sum+=pow(2,n-1)
n=n+1
else:
break
print sum
2018-04-13
sum = 0
x = 1
while x<100:
if x%2 >0:
sum +=x
x=x+1
print sum
x = 1
while x<100:
if x%2 >0:
sum +=x
x=x+1
print sum
2018-04-13
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
a = 0.0
a = sum(d.values())/float(len(d))
print a
用什么for呀,费劲
a = 0.0
a = sum(d.values())/float(len(d))
print a
用什么for呀,费劲
2018-04-13
def greet(str = 'world'):
print 'hello,' + str + '.'
greet()
greet('Bart')
大写小写,,傻傻分不清
print 'hello,' + str + '.'
greet()
greet('Bart')
大写小写,,傻傻分不清
2018-04-13