python day05 作业答案
1.
b.不可以
c.
tu=("alex",[11,22,{"k1":"v1","k2":["age","name"],"k3":(11,22,33)},44])
tu[1][2]["k2"].append("Seven")
print(tu)
d.
tu[1][2]["k3"] 不可以
2.
dic={"k1":"v1","k2":"v2","k3":[11,22,33]}
a.请循环输出所有的key
for a in dic.keys():
print(a)
b.请循环输出所有的key
for a in dic.values():
print(a)
c.请循环输出所有的key和values
for a in dic.items():
print(a)
d.
dic["k4"]="v4"
print(dic)
e.
dic["k1"]="alex"
print(dic)
f.
dic={"k1":"v1","k2":"v2","k3":{1:[11,22,33]}}
dic["k3"].append(44)
print(dic)
g.
dic["k3"].insert(1,'')
print(dic)
dic.pop('k1')
print(dic)
4.
a='k1:1|k1:2|k2:3|k4:4'
dic={}
lst=a.split('|')
print(lst)
for i in lst:
print(i)
k,v=i.split(":")
dic[k]=int(v)
print(dic)
5. li=[11,56,59,52,98,98,65,69,11,32]
dic={}
list=[]
list2=[] for a in li :
if a > 66:
list.append(a)
else :
list2.append(a)
print(list)
dic.setdefault("k1",list)
dic.setdefault("k2", list2)
print(dic) 6. lst=[1,2,9,3,"name","电脑"]
goods=[{"name":"电脑","price":""},{"name":"鼠标","price":""},{"name":"键盘","price":""}] while 1:
xh = input("") if xh.lower()=='q': break elif int(xh) >len(goods) or int(xh) <=0: print("输入有误") else: print(xh+goods[int(xh)-1]["name"]+" "+goods[int(xh)-1]["price"])
python day05 作业答案的更多相关文章
- python day10作业答案
2.def func(*args): sum = 0 for i in args: sum=sum+int(i) return sum a=func(2,3,9,6,8) print(a) 3. a= ...
- python day09作业答案
2. def lst(input): lst2=[] count=0 for i in range(0,len(input)): if i %2!=0: lst2.append(input[i]) r ...
- python day08作业答案
1. a f=open('11.txt','r',encoding='utf-8') a=f.read() print(a) f.flush() f.close() b. f=open('11.txt ...
- python day07作业答案
1. sum=0 a=input() for i in a: sum=sum+int(i)**3 if sum==int(a): print('水仙数') 2. lst=[100,2,6,9,1,10 ...
- python day06 作业答案
1. count=1 while count<11: fen=input('请第{}个评委打分' .format( count)) if int(fen) >5 and int(fen) ...
- python day05作业
- python day04 作业答案
1. 1) li=['alex','WuSir','ritian','barry','wenzhou'] print(len(li)) 2) li=['alex','WuSir','ritian',' ...
- python day02 作业答案
1. (1).false (2).false 2. (1).8 (2).4 3. (1).6 (2).3 (3).false (4).3 (5).true (6).true (7) ...
- My way to Python - Day05 - 面向对象-思维导图
My way to Python - Day05 - 面向对象 思维导图
随机推荐
- UI基础二:下拉,F4,OP等
常用的搜索帮助有SE11的SH,域,值列表,组件等...下面介绍一下经常用的: 一:下拉 dropdown是最经常用的,也是最简单的一种. 不管是查询条件,还是结果清单,还是明细界面,下拉都是一样的 ...
- java集合类整理
LinkedList 优点:插入删除迅速 缺点:不适合随机访问 List<String> staff = new LinkedList<String>(); staff.add ...
- 【LeetCode】Permutation全排列
1. Next Permutation 实现C++的std::next_permutation函数,重新排列范围内的元素,返回按照 字典序 排列的下一个值较大的组合.若其已经是最大排列,则返回最小排列 ...
- holiday
holiday.pas/c/cpp Description 经过几个月辛勤的工作,FJ 决定让奶牛放假.假期可以在1…N 天内任意选择一段(需要连 续),每一天都有一个享受指数W.但是奶牛的要求非常苛 ...
- js 日期格式: UTC GMT 互相转换
//UTC 转指定格式日期 let date = '2018-03-07T16:00:00.000Z' console.log(moment(date).format('YYYY-MM-DD HH:m ...
- Spring Cloud之路:(七)SpringBoot+Shiro实现登录认证和权限管理
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/sage_wang/article/details/79592269一.Shiro介绍1.Shiro是 ...
- day03_python_1124
01 昨日内容回顾 while 条件: 循环体 如何终止循环: 1,改变条件. 2,break. 3,exit() quit() 不推荐. 关键字: break continue while else ...
- Jquery源码探索
封装原理 这里参考的jquery来进行封装的一个常用方法的一个库,可作为自己的一个库 原理:创建一个构造函数,将所有方法放在该构造函数原型里,访问$()方法时,返回这个构造函数的实例化,这样就简单的实 ...
- @ResponseBody中文乱码解决方案
java web项目,使用了springmvc4.0,用@ResponseBody返回中文字符串,乱码$$ 本以为很简单的问题,不过也找了一个小时. 网上有说这样配置的: <mvc:annota ...
- sqlalchemy(二)简单的连接示例
# -*- coding: utf-8 -*- import sqlalchemy from sqlalchemy import create_engine from sqlalchemy.ext.d ...