为了账号安全,请及时绑定邮箱和手机立即绑定

初识Python

廖雪峰 移动开发工程师
难度入门
时长 5小时 0分
学习人数
综合评分9.43
3762人评价 查看评价
9.7 内容实用
9.4 简洁易懂
9.2 逻辑清晰
sum = 0
x = 1
n = 1
while True:
if n > 20:
break
sum = sum + x
x = x * 2
n = n + 1
print sum
sum = 0
x = 1
n = 1
while True:
sum = sum + x
x =2*(n-1)
if n > 20:
break
print sum
>>>store = 75

>>> if store >= 60:

... print 'Bart store is',store

... print 'passed'

...

Bart store is 75

passed
>>>store = 75
>>> if store >= 60:
... print 'Bart store is',store
... print 'passed'
...
Bart store is 20
passed
t = ('Adam',)
print t
运行结果:('Adam',)
#如何将最后的逗号去掉?
t = tuple('Adam')
print t
运行结果:('A', 'd', 'a', 'm')
t = tuple('Adam')
print t

运行结果:('A', 'd', 'a', 'm')
L = []
i=1
while i <101:
L.append(i*i)
i=i+1
print sum(L)

最新回答 / qq_325_0
第一行s和L定义时候不要放在同一行,L前换行就可以了
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in zip(list(range(1,5)), L):
print('%s - %s' % x)
为神马我把答案复制进去 按了enter 没有任何显示。。。我表示一窍不通啊

最赞回答 / qq_醉月飞羽觞_0
没有这样的吧,就算是c/c++/java中也是在函数名前面添加返回的类型吧,如int getReturn();      return 返回的类型就是函数名前面的类型int。而python 中没有给变量声明类型,所以说return 1 根据return 后的数据类型来确定为整型(如果省略写法是return 1,2     ,则完整写法return (1, 2) 所以容易知道tuple类型, 即把return 后面的复制给一个变量,根据这个变量的类型确定我们返回值的类型),相当于c:int get(){  ...
本地python3.6过啦,线上不行,返回全是整形了。。。
print ('hello,python')
print ('hello,''python')
print ('hello,'+'python')
print 'hello,python'
print (10 / 4.0)+2.5
课程须知
如果您了解程序设计的基本概念,会简单使用命令行,了解中学数学函数的概念,那么对课程学习会有很大的帮助,让您学起来得心应手,快速进入Python世界。
老师告诉你能学到什么?
通过本课程的学习,您将学会搭建基本的Python开发环境,以函数为基础编写完整的Python代码,熟练掌握Python的基本数据类型以及list和dict的操作。

微信扫码,参与3人拼团

微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消