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)
2019-03-07
最赞回答 / 云甡
a = 45678+0x12fd2print(a)print("Learn Python in imooc")print(100<99)print(0xff == 255)
2019-03-07
def greet(name='world'):
print('Hello,{}.'.format(name))
greet()
greet('Bart')
print('Hello,{}.'.format(name))
greet()
greet('Bart')
2019-03-07
def firstCharUpper(s):
return s[0:1].upper() + s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s[0:1].upper() + s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2019-03-07
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x % 2 == 0:
continue
sum += x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x % 2 == 0:
continue
sum += x
print sum
2019-03-07
sum = 0
x = 1
n = 1
while True:
x = 2**(n-1)
sum += x
n += 1
if n > 20:
break
print sum
x = 1
n = 1
while True:
x = 2**(n-1)
sum += x
n += 1
if n > 20:
break
print sum
2019-03-07
sum = 0
x = 1
n = 1
while n <= 20:
x = 2**(n-1)
sum += x
n += 1
print sum
x = 1
n = 1
while n <= 20:
x = 2**(n-1)
sum += x
n += 1
print sum
2019-03-07
print [100* n1 + 10*n2 + n3 for n1 in range(1,10) for n2 in range(10) for n3 in range (1,10) if n1==n3]
2019-03-07
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for n in d.itervalues():
sum=sum+n
print sum/len(d)
sum = 0.0
for n in d.itervalues():
sum=sum+n
print sum/len(d)
2019-03-07
第一小题比较容易理解,第二小题中
b=''
print 'hello,' , '' or 'world'中,逗号分隔两边为独立部分
因此会打印出hello,然后因为''为空值,在布尔类型中为false,
所以'' or world 在布尔短路运算中''false 继续运算打印world
因此 b=''
print 'hello,' , '' or 'world'打印出 hello world
b=''
print 'hello,' , '' or 'world'中,逗号分隔两边为独立部分
因此会打印出hello,然后因为''为空值,在布尔类型中为false,
所以'' or world 在布尔短路运算中''false 继续运算打印world
因此 b=''
print 'hello,' , '' or 'world'打印出 hello world
2019-03-07
# -*- coding: utf-8 -*-
print r'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
print r'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
2019-03-07