美文网首页
2018-11-01

2018-11-01

作者: smallcatmeat | 来源:发表于2018-11-01 23:28 被阅读0次

学习了循环语句

为什么下列代码必须加_和the

the_tuple=(1,2,3)
the_list=list(the_tuple)
the_list[2]=4
new_tuple=tuple(the_list)
print(new_tuple)

_用来连接the与tuple使之成为整体,因此the不是必须,可以用list1 list2取代;追加,一般不改变Python自带关键字;

在list[5,6,7,8]前面加[1,2,3,4]有哪几种方法

再创建新list并用+号连接;是否可以用append和extend?

如何使用while计算从1加到100

a=1
b=668868
sum=0
while a<=b:
    sum=sum+a
    a+=1
print('从1加到%d等于%d'%(b,sum))

如何使用while无限循环

设置永久成立的条件

a=1111
while a==1111:
    num=int(input('请输入数字:'))
    print('你输入的数字是',num)

为什么a+ =1之间有空格会导致错误

+是运算符号 +空格无意义;

如何使用break函数

注意print与if对齐,否则出现错误:IndentationError: unindent does not match any outer indentation level

for letter in 'abcdaaaaaaefg':
   if letter =='d' :
       break
   print('当前字母为',letter)

相关文章

网友评论

      本文标题:2018-11-01

      本文链接:https://www.haomeiwen.com/subject/jtdfxqtx.html