文章分类 -  python【3】

摘要:1 def main(): 2 list1 = ["demonstrate","aviation","strip","disastrous","tile"] 3 list1.sort(key=len) 4 print("Sorted by length in ascending order:") 5 print(list1,'\n') 6 li... 阅读全文
posted @ 2018-03-26 21:54 Justice-V 阅读(515) 评论(0) 推荐(0)
摘要:1 #列表解析 2 list1 = ['2','4','6','8'] 3 4 def g(x): 5 return(int(x)**2) 6 7 list2= [g(x) for x in list1] 8 print(list2) 阅读全文
posted @ 2018-03-26 15:28 Justice-V 阅读(118) 评论(0) 推荐(0)
摘要:取最多元音和最少元音: 阅读全文
posted @ 2018-03-25 07:22 Justice-V 阅读(140) 评论(0) 推荐(0)
摘要:import numpy as npimport matplotlib.pyplot as plt x = np.linspace(0, 10, 1000)y = np.sin(x)z = np.cos(x**2) plt.figure(figsize=(8,4))plt.plot(x,y,labe 阅读全文
posted @ 2018-03-25 07:08 Justice-V 阅读(87) 评论(0) 推荐(0)
摘要:1 list1 = [] 2 print("(Enter -1 finish)") 3 num = eval(input("Enter :")) 4 while num!=-1: 5 list1.append(num) 6 num = eval(input("Enter a nonegative n 阅读全文
posted @ 2018-03-20 20:42 Justice-V 阅读(87) 评论(0) 推荐(0)
摘要:1 #太阳花 2 from turtle import * 3 color("red","yellow") 4 begin_fill() 5 while True: 6 forward(200) 7 left(170) 8 if abs(pos())<1: 9 break 10 end_fill() 阅读全文
posted @ 2018-03-18 16:34 Justice-V 阅读(110) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2018-03-16 18:37 Justice-V 阅读(13) 评论(0) 推荐(0)
摘要:var = "python" #字符串的长度 len(var) #转换为大小写 var.upper() var.lower() #字符串首字母大写 var.capitalize() #字符串中每个单词的首字母大写 var.title() #移除字符串末尾的空白字符 var.rstrip() #查询最后一个匹配的 fullname = input("Enter a Name:") n... 阅读全文
posted @ 2018-03-16 17:56 Justice-V 阅读(100) 评论(0) 推荐(0)