文章分类 - 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...
阅读全文
摘要: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)
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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()
阅读全文
摘要:var = "python" #字符串的长度 len(var) #转换为大小写 var.upper() var.lower() #字符串首字母大写 var.capitalize() #字符串中每个单词的首字母大写 var.title() #移除字符串末尾的空白字符 var.rstrip() #查询最后一个匹配的 fullname = input("Enter a Name:") n...
阅读全文

浙公网安备 33010602011771号