做出了自己的思路,在看看评论,果然牛人很多,同时明白了一个道理:python是面向对象的,非面向过程。从这一点来看,用python做事情就灵活多了。真是仁者见仁智者见智!
2018-04-10
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for name in d:
print name +':'+ str(d[name]);
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for name in d:
print name +':'+ str(d[name]);
2018-04-10
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.'''
2018-04-10
print(45678+0x12fd2)
print('Learn Python in imooc')
print(100<99)
print(0xff == 255)
print('Learn Python in imooc')
print(100<99)
print(0xff == 255)
2018-04-10
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74}
print(sum([x for x in d.values()])/4.0)
print(sum([x for x in d.values()])/4.0)
2018-04-09
sum = 0
x = 1
while x < 100:
x = x + 2
sum = sum + x
print sum
x = 1
while x < 100:
x = x + 2
sum = sum + x
print sum
2018-04-09
for x in ['0','1','2','3','4','5','6','7','8','9']:
for y in ['0','1','2','3','4','5','6','7','8','9']:
if x<y:
print x+y
for y in ['0','1','2','3','4','5','6','7','8','9']:
if x<y:
print x+y
2018-04-09
先循环出前100,然后取余判断奇偶数,然后相加即可。
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2==0:
continue
sum = sum + x
print sum
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2==0:
continue
sum = sum + x
print sum
2018-04-09
偷偷用之前一个大牛的写法,偷学的。。嘿嘿
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print ('%s:%s' % (key, d[key]))
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print ('%s:%s' % (key, d[key]))
2018-04-09
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop(2)
print L
L.pop(2)
L.pop(2)
print L
2018-04-09
int x = 1;
int y = 0;
for (int i = 0; i < 100; i++)
{
y = y+(x + i * 3);
}
Debug.Log("计算的结果" + y);
int y = 0;
for (int i = 0; i < 100; i++)
{
y = y+(x + i * 3);
}
Debug.Log("计算的结果" + y);
2018-04-09
sum = 0
x = 1
n = 1
while True:
sum=sum+x
x=2*x
n=n+1
if n>20:
break
print sum
x = 1
n = 1
while True:
sum=sum+x
x=2*x
n=n+1
if n>20:
break
print sum
2018-04-09