Python-100道练习题答案
题目链接:http://www.runoob.com/python/python-100-examples.html
#5.
# def find_max():
# a=int(input("输入:"))
# b = int(input("输入:"))
# c = int(input("输入:"))
# list_=[a,b,c]
# print(list_)
# list_.sort()
# find_max()
#6.
# def f(a):
# if a==1 or a==2:
# flag=-1
# return 1
# else:
# return f(a-2)+f(a-1)
# print(f(12))
# for i in range(1,13):
# print(f(i))
#
# a=[1,2,3,5,4,3,32,2]
# b=a[:]
# print(b)
#
# for i in range(1,10):
# for j in range(1,i+1):
# print("%d * %d = %d "%(i,j,j*i),end="")
# print()
#
# import time
# time.sleep(1)
# print("s")
#
# import time
# print(time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time())))
# time.sleep(1)
# print(time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time())))
#
# def f(a):
# if a==1 or a==2:
# return 1
# else:
# return f(a-1)+f(a-2)
# print(f(11))
#
# import math
# def sushu():
# a=[x for x in range(100,201)]
# for i in a:
# flag = 1
# b=int(math.sqrt(i // 2 + 1))+1
# for j in range(2,b):
# if i%j==0:
# flag=-1
# break
# if flag==1:
# print(i)
# sushu()
#
# def f():
# for i in range(100,1000):
# b=i//100
# s=i//10%10
# g=i%10
# if b**3+s**3+g**3==i:
# print(i)
# f()
#
# import math
# def f(a):
# print("{}=".format(a),end="")
# c=[]
# i=2
# while i <=a:
# if a%i==0:
# c.append(i)
# a=a/i
# print("{}*".format(i),end="")
# i=2
# else:
# i+=1
# f(100)
#
# def f():
# a=float(input("输入成绩:"))
# if 90<=a<=100:
# print("成绩是:A")
# elif 70<=a<90:
# print("成绩是:B")
# else:
# print("成绩是:C")
# f()
#
# import time
# a=time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time()))
# print(a)
#
# def f():
# space=0
# digit=0
# alpha=0
# other=0
# a=input("输入任意内容")
# a=list(a)
# for i in a:
# if i.isspace():
# space+=1
# elif i.isalpha():
# alpha+=1
# elif i.isdigit():
# digit+=1
# else:
# other+=1
# print("字母是%d个,数字是%d个,空格是%d个,其他是%d个"%(alpha,digit,space,other))
# f()
#
# def f(a,num):
# sum_a_num=0
# if num==0:
# print("0")
# else:
# for i in range(num):
# for j in range(-1,i):
# print(a,end="")
# print()
# print(sum_a_num)
# f(2,5)
# def f(a,num):
# c=[]
# t=0
# if num==0:
# print("0")
# else:
# for i in range(num):
# t=t+a
# a=a*10
# print(t)
# c.append(t)
# print(sum(c))
# f(2,5)
#
# def f():
# for i in range(2,1001):
# c = []
# for j in range(1,i//2+1):
# if i%j==0:
# c.append(j)
# if sum(c)==i:
# for k in c:
# print(k,end=",")
# print()
# print(i)
# f()
#
# def high(n):
# h=100
# n_high=100/(2**(n))
# print(n_high)
# high(10)
#
# num=1
# for i in range(1,10):
# num=2*(num+1)
# print(num)
#
# def f():
# jia="abc"
# yi="xyz"
# for i in jia:
# for j in yi:
# if (i=="a" and j=="x") or (i=="c" and j=="x" )or (i=="c" and j=="z" ):
# print(i,j)
# f()
# #23
# for i in range(1,4):
# for j in range(1,4-i):
# print(" ",end="")
# for k in range(1,2*i+1-1):
# print("*",end="")
# print()
# for i in range(1,3):
# for j in range(1,i+1):
# print(" ",end="")
# for k in range(1,2*(3-i)+1-1):
# print("*",end="")
# print()
#
# def f():
# i=2
# j=1
# a=0
# for x in range(10):
# a = i / j
# b=j
# j = i
# i = i + b
# # a+=a
# print(a)
# f()
#
# def f():
# sum_=0
# for i in range(1,21):
# s=1
# for j in range(1,i+1):
# s=s*j
# sum_+=s
# print(sum_)
# f()
#
# def f(n):
# if n==1:
# return 1
# else:
# return n*f(n-1)
# print(f(5))
#
# def f(a,b):
# if b>=1:
# print(a[b-1],end="")
# return f(a,b-1)
# else:
# exit()
# str_=input("字符串:")
# len_str=len(str_)
# f(str_,len_str)
#
# def f(n):
# if n==1:
# return 10
# else:
# return 2+f(n-1)
# print(f(5))
#
# def f():
# a=int(input("输入数字"))
# b=str(a)
# len_a=len(b)
# print("长度是:",len_a)
# for i in range(len_a):
# print(b[len_a-i-1],end="")
# f()
#
# def f():
# a=input("输入:")
# len_a=len(a)
# len_a2=len(a)//2
# for i in range(len_a2):
# flag = 1
# if a[len_a-i-1]!=a[i]:
# print("不是回文")
# flag=-1
# break
# if flag==1:
# print("回文")
# f()
#
# def f():
# a=input("输入:")
# if a[0].lower()=="w":
# print("星期三")
# elif a[0].lower()=="m":
# print("星期一")
# elif a[0].lower()=="f":
# print("星期五")
# elif a[0].lower()=="t":
# if a[1].lower()=="h":
# print("星期四")
# else:
# print("星期二")
# elif a[0].lower()=="s":
# if a[1].lower()=="a":
# print("星期六")
# else:
# print("星期日")
# f()
#
# def f():
# a=input("输入:")
# a=list(a)
# lena=len(a)
# len_a=len(a)-1
# for i in range(lena):
# print(a[len_a-i],end="")
# f()
#
# a=[1,2,3]
# print("_".join(str(x) for x in a))
#
# def func1():
# print("这是函数1")
# def func2():
# func1()
# print("这是函数2")
# func2()
#
#
# import math
# def f():
# a=[i for i in range(1,101)]
# print(a)
# for k in range(4,101):
# b=int(math.sqrt(k))+1
# print(b)
# for j in range(2,b):
# if k%j==0:
# a.remove(k)
# break
# print(a)
# f()
#
# def f():
# a=list(input("输入数字:"))
# print(a)
# len_a=len(a)
# for i in range(len_a):
# for j in range(i+1,len_a):
# if a[i]<=a[j]:
# k=a[i]
# a[i]=a[j]
# a[j]=k
# print(" ".join(a))
# f()
#
# a=[]
# for i in range(0,4):
# b=[]
# for j in range(1,5):
# b.append(i+j)
# a.append(b)
# print(a)
# len_a=len(a)
# len_a_=len(a[0])
# sum_=0
# for i in range(len_a):
# for j in range(len_a_):
# if i==j:
# sum_+=a[i][j]
# print(sum_)
#
# def f():
# a=list(input("输入:"))
# len_a=len(a)
# for i in range(len_a):
# for j in range(i+1,len_a):
# if a[i]<=a[j]:
# k=a[i]
# a[i]=a[j]
# a[j]=k
# print(a)
# print(" ".join(a))
# b=input("输入一个数:")
# for i in range(len_a):
# if int(b)>=int(a[i]):
# a.insert(i,b)
# break
# print(" ".join(a))
# f()
#
# def f():
# a=tuple(input("输入:"))
# len_a=len(a)
# for i in range(len_a):
# print(a[len_a-1-i],end="")
# f()
#
# def f():
# var=0
# print("var是:",var)
# var+=1
# for i in range(3):
# f()
# class A():
# var=0
# def f(self):
# self.var+=1
# print("var是:",self.var)
# a=A()
# for i in range(3):
# a.f()
#
# num=2
# def f():
# num=1
# print("局域:",num)
# num+=1
# for i in range(3):
# f()
# num+=1
# print("全局",num)
#
# class A():
# var=1
# def f(self):
# self.var+=1
# print("属性是:",self.var)
# a=A()
# var1=9
# for i in range(3):
# var1 += 1
# print("变量是:",var1)
# a.f()
#
# x = [[12,7,3],
# [4 ,5,6],
# [7 ,8,9]]
#
# y= [[5,8,1],
# [6,7,3],
# [4,5,9]]
# c=[]
# for i in range(3):
# b=[]
# for j in range(3):
# b.append(x[i][j]+y[i][j])
# c.append(b)
# print(c)
#
# a=[i for i in range(1,101)]
# print(sum(a))
# def f(n):
# print((n*(n+1)/2))
# f(100)
#
# while True:
# a=int(input("输入某数:"))
# if a**2<=50:
# break
# else:
# print("和:",a**2)
#
# def f():
# a=input("一:")
# b=input("二:")
# c=a
# a=b
# b=c
# print("一:",a)
# print("二:",b)
# f()
#
# def f():
# a=int(input("一:"))
# b=int(input("二:"))
# if a==b:
# print("%d=%d"%(a,b))
# elif a>b:
# print("%d>%d"%(a,b))
# else:
# print("%d<%d"%(a,b))
# f()
#
# a=[lambda:[x for x in range(10)]]
# b=[x for x in range(10)]
# list2=[1,4,6,-3,-9,-2]
# print(sorted(c,key=lambda x:abs(x)))
# print(list(map(lambda x:x+1,c)))
# print(list(filter(lambda x: x%2==0,c)))
# print(sorted(c,key=lambda x:x["time"]))
# def f(a,b):
# return lambda x:a*x+b
# z=f(3,3)
# print(z(4))
#
# import random
# a_rand=random.randint(0,19)
# print(a_rand)
#
#位运算符,按照二进制进行计算
#
#
#
#
#
#
#
#
# def f():
# for i in range(100,1000):
# i_3=i//100
# i_2=i//10%10
# i_1=i%10
# print("{},{},{}".format(i_3,i_2,i_1))
# f()
#
# def f():
# k=0
# str_=input("输入:")
# print(len(str_))
# for i in str_:
# k+=1
# print(k)
# f()
#
# b=[[1],]
# for i in range(0,5):
# c=[]
# for j in range(0,i+1):
# if j==0:
# c.append(b[i][j])
# if j<=i-1:
# c.append(b[i][j]+b[i][j+1])
# c.append(1)
# b.append(c)
# print(b)
# for i in b:
# for k in i:
# print(k,end=" ")
# print()
# print(b) # b=[]
# for i in range(0,5):
# c=[]
# for j in range(0,i):
# if j==0:
# c.append(b[i-1][j])
# if j<=i-2:
# c.append(b[i-1][j]+b[i-1][j+1])
# c.append(1)
# b.append(c)
# print(b)
# for i in b:
# for k in i:
# print(k,end=" ")
# print()
# print(b) #
# def f():
# a=input("字符串1:")
# b=input("字符串2:")
# print(a.find(b))
# f()
#
#
#
#
# def f():
# d=[]
# a=int(input("a:"))
# b=int(input("b:"))
# c=int(input("c:"))
# d.extend([a,b,c])
# d.sort(reverse=True)
# print(d)
# f()
#
# def f():
# c=[]
# for i in range(6):
# a=int(input("输入数字:"))
# c.append(a)
# c1 = c
# print(c)
# for i_1 in range(6):
# for i_2 in range(i_1,6):
# if c1[i_1]<=c1[i_2]:
# k=c1[i_1]
# c1[i_1]=c1[i_2]
# c1[i_2]=k
# max_=c.index(c1[0])
# min_=c.index(c1[5])
# max_1=c[0]
# c[0]=c[max_]
# c[max_]=max_1
#
# min_1 = c[5]
# c[5] = c[min_]
# c[min_] = min_1
# print(c)
# f()
#
# def f(m,n):
# c=[]
# b=[]
# for i in range(m):
# a=input("输入:")
# c.append(a)
# for i in range(n,m):
# b.append(c[i])
# for i in range(n):
# b.append(c[i])
# print(b)
# f(8,4)
#
# def people_3(a):
# j=0
# list_a=[x for x in range(1,a+1)]
# i=0
# while i<len(list_a):
# j+=1
# if j==3:
# list_a.remove(list_a[i])
# j=0
# i-=1
# if i==len(list_a)-1:
# i=-1
# i+=1
# if len(list_a)==1:
# print(list_a)
# break
# people_3(4)
#
# if __name__=="__main__":
# a=input("输入:")
# print(len(a))
#
# d = {}
# def write():
# print(type(d))
# for i in range(5-len(d)):
# a=input("输入键名:")
# if a == "0":
# break
# b=input("输入键值:")
# # d.update({a:b})
# d.update([(a,b)])
# print(d)
# def read():
# a = input("输入键名:")
# for key,value in d.items():
# if a==key:
# print(key,":",value)
# write()
# read()
# a={"q":1,"w":"2"}
# for key,value in a.items():
# if "w"==key:
# print(key,":",value)
#
# def f():
# c=[]
# for i in range(3):
# a=int(input("输入:"))
# c.append(a)
# print(c)
# f()
#
# def f():
# a=input("输入")
# len_a=len(a)
# for i in range(len_a):
# print(a[len_a-i-1],end="")
# f()
#
# def f():
# a=list(input("输入:"))
# b=list(input("输入:"))
# a.sort()
# b.sort()
# print(a+b)
# f()
#
# for i in range(5):
# n = 0
# if i != 1: n += 1
# if i == 3: n += 1
# if i == 4: n += 1
# if i != 4: n += 1
# if n == 3: print(64 + i)
#
# def f(a):
# sum_a=0
# if a%2==0:
# for i in range(1,a//2+1):
# sum_a+=(1/(2*i))
# else:
# for i in range(1,a//2+1):
# sum_a+=1/2*i+1
# print(sum_a)
# f(6)
#
# def f():
# a=list(input())
# for i in a:
# print(i,end="")
# f()
#
# def f():
# dic={'a':1,'f':2,'c':3,'h':0}
# sorted(dic.items(),key=lambda x:x[1])
# print(dic)
# f()
# a={"001":{"name":"张三","age":12},
# "002":{"name":"李四","age":22},
# "003": {"name": "王二", "age": 19}}
#
# def f():
# a=input("")
# b=input("")
# c=input("")
# if a>b : a,b=b,a
# if a>c: a,c=c,a
# if b>c: b,c=c,b
# print(a,b,c)
# f()
#
# def f():
# for i in range(3120,4000):
# flag = 1
# k=i
# for j in range(5):
# if i%5==1:
# i=(i//5)*4
# else:
# flag=-1
# break
# if flag==1:
# print(k)
# f()
#81:
# def f():
# a=809
# for i in range(10,100):
# if (a*i==800*i+9*i) and (9000<a*i<10000):
# print(a*i)
# f()
#
# def f(a):
# c=[]
# while True:
# x1=a//8
# x2=a%8
# c.append(x2)
# a=x1
# if x1<8:
# c.append(x1)
# break
# for i in range(len(c)):
# print(c[len(c)-i-1],end="")
# f(28)
#
# def f():
# for i in range(0,7):
# if i==0:
# print("4")
# elif i == 1:
# print("28")
# else:
# print(7*(8**(i-1))*4)
# f()
#
# def f(a):
# c=[]
# for i in range(a):
# b=input("")
# c.append(b)
# print("--".join(c))
# f(3)
#
# def f():
# a=int(input("输入奇数:"))
# for i in range(1,10):
# z = 0
# for j in range(0,i):
# z+=9*(10**j)
# # print(z)
# if z%a==0:
# print(z)
# break
# f()
#
# def f():
# a=input("字符串:")
# b = input("字符串:")
# print("{}-{}".format(a,b))
# print(a+b)
# print("-".join(a))
# f()
#
# class A():
# var=1
# var2="a"
# def f(self,c):
# c.var=3
# c.var2="c"
# a=A()
# a.var=10
# a.var2="asd"
# a.f(a)
# print(a.var)
# print(a.var2)
#
# a=int(input("一:"))
# print(a*"*")
#
# def f():
# a=input("")
# a=list(a)
# c=[]
# for i in a:
# i=(int(i)+5)%10
# c.append(i)
# print(c)
# c[0],c[3]=c[3],c[0]
# c[1],c[2]=c[2],c[1]
# print(c)
# f()
#
# list.append()
# list.extend([])
# list.insert(index,num)
# list.remove()
# list.pop()
# del list()
# list.index()
# list.count()
# list.sort()
# sorted(list,lambda x:)
#
#time模块
#
# import time
# def f():
# start=time.time()
# time.sleep(1)
# end=time.time()
# print(end-start)
# f()
#
#
#
#
# def f():
# a=input()
# b=input()
# print(a.count(b))
# f()
#
# def f():
# a=input()
# for i in a:
# if i!="#":
# print(i,end="")
# else:
# break
# f()
#
# def f():
# a=input()
# a=a.upper()
# with open(r"C:\Users\Administrator\Desktop\1.txt","w") as f:
# f.write(a)
# f()
#
# with open (r"C:\Users\Administrator\Desktop\1.txt","r") as f1:
# cont1=f1.read()
# with open(r"C:\Users\Administrator\Desktop\2.txt", "r") as f2:
# cont2=f2.read()
# l=list(cont1+cont2)
# l.sort()
# print(l)
# s="-".join(l)
# print(s)
# with open(r"C:\Users\Administrator\Desktop\3.txt", "w") as f3:
# f3.write(str(s)) #
# def f():
# a=list(input())
# b=list(input())
# c=dict(zip(a,b))
# print(c)
# f()
# i = ['a', 'b']
# l = [1, 2]
# a=dict([i,l])
# print (a)
Python-100道练习题答案的更多相关文章
- [转]numpy 100道练习题
100 numpy exercise 翻译:YingJoy 网址: https://www.yingjoy.cn/ 来源:https://github.com/rougier/numpy-100 Nu ...
- python面试题100道
python 100道面试题 1.一行代码实现1--100之和 利用sum()函数求和 2.如何在一个函数内部修改全局变量 函数内部global声明 修改全局变量 3.列出5个python标准库 os ...
- 这 100 道 Python 题,拿去刷!!!
2020年,学 Python 还有价值吗? 根据 2020 年 2 月的 TIOBE 编程语言排行榜显示,Python仍然稳居第三位. 此排行榜排名基于互联网上有经验的程序员. 课程和第三方厂商的数量 ...
- 学生选课数据库SQL语句45道练习题整理及mysql常用函数(20161019)
学生选课数据库SQL语句45道练习题: 一. 设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四 ...
- Python面试真题答案或案例
Python面试真题答案或案例如下: 请等待. #coding=utf-8 #1.一行代码实现1--100之和 print(sum(range(1,101))) #2.如何在一个函数内部修改全局变量 ...
- MySQL查询 45道练习题
SQL查询45道练习题 1.查询Student表中的所有记录的Sname.Ssex和Class列.select sname,ssex,class from student2.查询教师所有的单位即不重复 ...
- Python之基础练习题
Python之基础练习题 1.执行 Python 脚本的两种方式 2.简述位.字节的关系 解:8位是一个字节 3.简述 ascii.unicode.utf-8.gbk 的关系 4.请写出 “李杰” 分 ...
- Python:程序练习题(二)
Python:程序练习题(二) 2.1温度转换程序. 代码如下: t=input("请输入带符号的温度值(如:32C):") if t[-1] in ["C", ...
- 常见的 35 个 Python 面试题及答案
1. Python 面试问题及答案 作为一个 Python 新手,你必须熟悉基础知识.在本文中我们将讨论一些 Python 面试的基础问题和高级问题以及答案,以帮助你完成面试.包括 Python 开发 ...
随机推荐
- Linux 文件系统(一)---虚拟文件系统VFS----超级块、inode、dentry、file
转自:http://blog.csdn.net/shanshanpt/article/details/38943731 http://elixir.free-electrons.com/linux/v ...
- 高通 MSM8K bootloader之一: SBL1
MSM8K Boot Flow 转自:http://www.cnblogs.com/liang123/p/6325257.html http://blog.csdn.net/F ...
- 使用eclipse整合ssh项目的例子--lljf(1)
最近向自己单独做一个基于ssh的项目,来预习和巩固自己的Java基础.找了一个实际生活中的定做衣服的例子来做一做,放到博客上给大家一起分享学习,后边会持续更新项目编写时候遇到的困难和使用的技术等. 1 ...
- C++中的字符串的输入输出函数、空字符与空格的区别、字符变量赋值和字符串初始化
一.字符串输入输出函数 1. cin.get() 逐个字符输入输出 2. cin 可以将整个字符串一次性输入,但是,cin将空格.Tab和回车键,因此不能用于数组的一次性输入. 注意:ci ...
- Vmware网络不可达
1. ifconfig -a 查看当前的网卡 2. cd /etc/sysconfig/network-scripts/ 3. 打开对应网卡名称文件, 具体修改内容参考(https://www. ...
- 汉诺塔I
题目描述 对于传统的汉诺塔游戏我们做一个拓展,我们有从大到小放置的n个圆盘,开始时所有圆盘都放在左边的柱子上,按照汉诺塔游戏的要求我们要把所有的圆盘都移到右边的柱子上,请实现一个函数打印最优移动轨迹. ...
- day 23 对象的名称空间 类,对象属性和方法 封装 接口提供
一.对象的特有名称空间 # 对象独有的名称空间:在产生对象时就赋初值 '''class ted: def func(): 当func里不存在参数时,调用时不需要给值 print('hah')ted.f ...
- 关于MySQL5.7 这几天的总结(json类型)
一开始,老板让调整一下 innodb_buffer_pool_size 大小,因为这台机器内存大. 看了下内存,16G,再SQL下面命令,得到结果是4G. SELECT @@innodb_buffer ...
- Springboot读取本地图片并显示
在application.yml中配置url访问路径和本地图片路径: 方框1:url中访问路径,这里为:localhost:8080/testspringboot/image/... 方框2:本地图片 ...
- HML
1.元素分类: 2.浮动: 在非IE浏览器(如Firefox)下,当容器的高度为auto,且容器的内容中有浮动(float为left或right)的元素,在这种情况下,容器的高度不能自动伸长以适应内容 ...