2.
def lst(input):
lst2=[]
count=0
for i in range(0,len(input)):
if i %2!=0:
lst2.append(input[i])
return lst2
a=lst((2,9,29,36,9))
print(a) 3.
def pd(input):
if len(input)>5:
return True
else:
return False
a=pd((5,5,6,9,7))
print(a) 4.
def a(input):
if type(input)==list:
if len(input)>2:
return input[0],input[1]
else:
return ('请输入列表')
d=a(['小明','大明'])
print(d)
5.写函数,计算传入函数的字符串中, 数字、字母、空格 以及 其他内容的个数,并返回结果。
def func(s=""): # function
shuzi = 0
zimu = 0
kongge = 0
qita = 0
for c in s: # 循环字符串.拿到每个字符
if c.isdigit(): # 数字
shuzi += 1
elif c.isalpha():
zimu+=1
elif c == ' ':
kongge += 1
else:
qita += 1
return shuzi, zimu, kongge, qita
6.
def num(n1,n2):
if n1>n2:
return n1
elif n1<n2:
return n2
a=num(26,98)
print(a)
7.
def dic(dic):
for k,v in dic.items():
if len(v)>2:
dic[k]=v[0:2]
return dic
a=dic({1:'dsfgasdf',2:'sdfsdsd',3:'卡卡卡的双丰收'})
print(a)
8.
def list(input):
dic={}
if type(input)==type([]):
for i in range(0,len(input)):
dic[i]=input[i]
return dic
elif type(input)!=type([]):
return '请输入列表'
a=list([2,3,6,5,9,8])
print(a)
9.
def xx(姓名=input('姓名:'),性别=input('性别:'),年龄=input('年龄:'),学历=input('学历:')):
student_msg={}
student_msg['姓名']=姓名
student_msg['性别'] = 性别
student_msg['年龄'] = 年龄
student_msg['学历'] = 学历
return student_msg
a=xx()
print(a)
9.
def func(name, age,edu,sex ="男"):
f = open("student.msg", mode="a", encoding="utf-8")
f.write(name+"_"+str(age)+"_"+sex+"_"+edu+"\n")
f.flush()
f.close()
10.
def xx():
while True:
a=input('姓名:')
if a.lower() == 'q':
break
else:
student_msg={}
student_msg['姓名']=a
student_msg['性别'] = input('性别:')
student_msg['年龄'] = input('年龄:')
student_msg['学历'] = input('学历:')
return student_msg aa=xx()
print(aa)
11.
def ch(wjm,ynr,xnr):
import os
with open(wjm,'r',encoding='utf-8') as f1, open('a.txt','w',encoding='utf-8') as f2:
for i in f1.readlines():
a=i.replace(ynr,xnr)
f2.write(a)
os.remove(wjm)
os.rename('a.txt',wjm)
ch('4.txt','alex','sb')
12.
def dl(username,password):
count=0
while count<=3:
if username=='' and password=='':
return ('登录成功')
count=count+1
else :
return ('请重新输入:')
count+=1 a=dl(12563,'')
print(a)

python day09作业答案的更多相关文章

  1. 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= ...

  2. 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 ...

  3. python day09作业

  4. 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 ...

  5. python day06 作业答案

    1. count=1 while count<11: fen=input('请第{}个评委打分' .format( count)) if int(fen) >5 and int(fen) ...

  6. python day05 作业答案

    1. b.不可以 c.tu=("alex",[11,22,{"k1":"v1","k2":["age" ...

  7. python day04 作业答案

    1. 1) li=['alex','WuSir','ritian','barry','wenzhou'] print(len(li)) 2) li=['alex','WuSir','ritian',' ...

  8. 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) ...

  9. 笔试 - 高德软件有限公司python问题 和 答案

    高德软件有限公司python问题 和 答案 本文地址: http://blog.csdn.net/caroline_wendy/article/details/25230835 by Spike 20 ...

随机推荐

  1. DHCP机制

    DHCP概念:局域网的网络协议,使用UDP协议工作,在工作过程中,它有两个对象,DHCP客户端和DHCP服务端,DHCP服务运行在67端口和68端口. 用途:1)个内部网络或网络服务供应商自动分配IP ...

  2. 安卓——AlertDialog多样按钮

    在xml 设计页面添加标签 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmln ...

  3. PHP手册-函数参考-日期与时间相关扩展

    一.Calander.日期/时间.HRTime扩展的对比   Calendar 日期/时间 HRTime 简介 历法扩展集包括了一系列用于在不同历法间进行转换的函数,它是以Julian Day计数为中 ...

  4. MySql习题和答案

    MySQL测试题 一.表关系请创建如下表,并创建相关约束 二.操作表 1.自行创建测试数据 2.查询“生物”课程比“物理”课程成绩高的所有学生的学号.ps:针对的是自己的生物成绩比物理成绩高,再把符合 ...

  5. Django知识点梳理

    Django囊括.杂糅了 前端.数据库.Python知识看起来比较复杂! 其实就是由http请求周期为主体,延伸出来的知识 .  PythonWeb服务器网关接口(Python Web Server ...

  6. 更改pip源至国内镜像

    更改pip源至国内镜像   经常在使用Python的时候需要安装各种模块,而pip是很强大的模块安装工具,但是由于国外官方pypi经常被墙,导致不可用,所以我们最好是将自己使用的pip源更换一下,这样 ...

  7. eclipse安装springboot插件

    1.工具栏->Help->Eclise Marketplace打开应用市场 2.在应用市场中搜索sts,选择Spring Tools 4紧张安装 3.按提示进行安装

  8. 微信小程序开发工具

    微信小程序 1● 工具下载 https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/download.html     2● webchart_devto ...

  9. Vue + Element UI 实现权限管理系统(更换皮肤主题)

    自定义主题 命令行主题工具 1.安装主题工具 首先安装「主题生成工具」,可以全局安装或者安装在当前项目下,推荐安装在项目里,方便别人 clone 项目时能直接安装依赖并启动. yarn add ele ...

  10. Jquery源码探索

    封装原理 这里参考的jquery来进行封装的一个常用方法的一个库,可作为自己的一个库 原理:创建一个构造函数,将所有方法放在该构造函数原型里,访问$()方法时,返回这个构造函数的实例化,这样就简单的实 ...