当前位置: 首页 > news >正文

网站建设丨选择金手指排名15app外包接单

网站建设丨选择金手指排名15,app外包接单,佛系汉化组.wordpress com,wordpress中文版没有繁体字目录 一、字符串1.1 在字符串中使用变量 二、列表2.1 遍历列表练习题代码 2.2 列表元素的插入和删除涉及方法练习题代码 2.3 组织列表涉及方法练习题代码 2.4 索引 参考书#xff1a;Python从入门到实践#xff08;第二版#xff09; 一、字符串 1.1 在字符串中使用变量 f… 目录 一、字符串1.1 在字符串中使用变量 二、列表2.1 遍历列表练习题代码 2.2 列表元素的插入和删除涉及方法练习题代码 2.3 组织列表涉及方法练习题代码 2.4 索引 参考书Python从入门到实践第二版 一、字符串 1.1 在字符串中使用变量 f “{ 变量名 }” f代表formatPython把花括号里的变量名替换为其值来设置字符串的格式。Python3.6引入 代码示例 first_name input(Your first name is: ) last_name input(Your last name is : ) full_name f{first_name} {last_name} print(fMy name is {full_name.title()})二、列表 2.1 遍历列表 练习题 将一些朋友的姓名存储在一个列表中并将其命名为names 。依次访问该列表中的每个元素从而将每个朋友的姓名打印出来。 代码 names [winnie,jack,lili,will,diana] for name in names:print(fHello, my name is {name.title()}) else:print(The list is overlooped)代码解释 使用for循环遍历列表中的所有信息使用format字符串形式输出字符串中的变量使用title方法对列表中的字母进行首字母大写 2.2 列表元素的插入和删除 涉及方法 append() : 在列表末尾添加元素insert() 在列表任意位置添加元素remove() 根据具体值删除元素del 语句 删除整个列别或某一元素pop() 弹出任意元素 练习题 代码 #3-4 names [diane,kalinda,alicia,will,peter,cary] for name in names:print(fDear {name.title()}, lets have a dinner together this evening.) num_guests len(names) print(fWe have invited {num_guests} guests now,) print(\n)#3-5 print(Ops! Peter is busy with his campaign so he cant joy the dinner.\n) names.remove(peter) names.append(zerk) for name in names:print(fDear {name.title()}, lets have a dinner together this evening.) num_guests len(names) print(fWe have invited {num_guests} guests now,) print(\n)#3-6 print(We can invite more guests now because I have found a bigger dinner table now.\n) names.insert(0,tom) names.insert(int(len(names)/2),mary) names.append(winnie) for name in names:print(fDear {name.title()}, lets have a dinner together this evening.) num_guests len(names) print(fWe have invited {num_guests} guests now,) print(\n)#3-7 print(Sorry, I can only invite 2 guests to joy the dinner.\n) while len(names)2:name names.pop()print(fDear {name.title()}, sorry for the change, we can have dinner the next time!) for name in names:print(fDear {name.title()}, you are still invited to the dinner tonight.) del names[0] del names[0] print(names)输出如下 Dear Diane, let’s have a dinner together this evening. Dear Kalinda, let’s have a dinner together this evening. Dear Alicia, let’s have a dinner together this evening. Dear Will, let’s have a dinner together this evening. Dear Peter, let’s have a dinner together this evening. Dear Cary, let’s have a dinner together this evening. We have invited 6 guests now Ops! Peter is busy with his campaign so he can’t joy the dinner. Dear Diane, let’s have a dinner together this evening. Dear Kalinda, let’s have a dinner together this evening. Dear Alicia, let’s have a dinner together this evening. Dear Will, let’s have a dinner together this evening. Dear Cary, let’s have a dinner together this evening. Dear Zerk, let’s have a dinner together this evening. We have invited 6 guests now We can invite more guests now because I have found a bigger dinner table now. Dear Tom, let’s have a dinner together this evening. Dear Diane, let’s have a dinner together this evening. Dear Kalinda, let’s have a dinner together this evening. Dear Mary, let’s have a dinner together this evening. Dear Alicia, let’s have a dinner together this evening. Dear Will, let’s have a dinner together this evening. Dear Cary, let’s have a dinner together this evening. Dear Zerk, let’s have a dinner together this evening. Dear Winnie, let’s have a dinner together this evening. We have invited 9 guests now Sorry, I can only invite 2 guests to joy the dinner. Dear Winnie, sorry for the change, we can have dinner the next time! Dear Zerk, sorry for the change, we can have dinner the next time! Dear Cary, sorry for the change, we can have dinner the next time! Dear Will, sorry for the change, we can have dinner the next time! Dear Alicia, sorry for the change, we can have dinner the next time! Dear Mary, sorry for the change, we can have dinner the next time! Dear Kalinda, sorry for the change, we can have dinner the next time! Dear Tom, you are still invited to the dinner tonight. Dear Diane, you are still invited to the dinner tonight. 2.3 组织列表 涉及方法 sort对列表排序sorted对列表暂时排序不改变原有顺序reverse翻转列表 练习题 代码 #3-8 travel [italy,france,america,spain,denmark] print(original:,travel) print(sorted:,sorted(travel)) print(after sorted:,travel) travel.reverse() print(reverse:,travel) travel.reverse() print(reverse again:,travel) travel.sort() print(sort:,travel) travel.sort(reverseTrue) print(sort reverseTrue:,travel)#3-9 names [diane,kalinda,alicia,will,peter,cary] print(The number of guests are %d. %len(names)) 2.4 索引 列表从前往后的下标从0开始从后往前的下标从-1开始
http://www.w-s-a.com/news/29045/

相关文章:

  • 网站设计建议建设商务网站作用
  • 网站策划的最终体现是什么模板网站建设流程图
  • 网站设计与开发技术教程十度公司做网站怎么样
  • 企业网站推广方案在哪里智慧团建登录入口官网手机版
  • google网页版入口seo索引擎优化
  • 东乡做网站常州网络公司联系方式
  • 做网站激励语家居装饰网站设计论文
  • 镜像的网站怎么做排名无极网站建设质量
  • 奉贤集团公司网站建设小工具文本wordpress
  • 不用代码做网站网站建设和运行费用
  • 阜阳网站开发招聘网站建设合作协议申请
  • 电子配件 技术支持 东莞网站建设wordpress 生成html代码
  • 网站用免费空间好不好网站建设的视频
  • 网站开发项目职责门户资源分享网站模板
  • 建网站需要什么语言如何做二维码跳转到网站
  • 天津建设交培训中心网站做网站起名字
  • 黑河北京网站建设湛江市住房和城乡建设局网站
  • 网站建设拾金手指下拉十九企业查询官网
  • 邢台提供网站建设公司哪家好五合一建站
  • 京东网站设计代码驻马店做网站的公司
  • 织梦网站模板使用教程福州网站建设工作
  • 做网站要准备的需求asp 网站后台
  • 滨州网站开发公司中立建设集团有限公司网站
  • 泰安建设厅网站做网站为什么要建站点
  • 有什么好的手机推荐网站创建网站需要哪些工作
  • 网站能给企业带来什么上饶市网站建设公司
  • 学做网站卖东西去哪学南宁网站建设gxjzdrj
  • 欧美网站建设案例网站开发 男生
  • 网站正在开发中做电子元器件的网站
  • 做网站搭建的公司中国建设银行官网站u盾证书