![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
小程序
初665
这个作者很懒,什么都没留下…
展开
-
Python:温度转换
#TempConvert.pyTempStr = input("请输入带有符号的温度值: ")if TempStr[-1] in ['F','f']: C = (eval(TempStr[0:-1]) - 32)/1.8 print("转换后的温度是{:.2f}C".format(C))elif TempStr[-1] in ['C','c']: F = 1.8*eval(TempStr[0:-1]) + 32 print("转换后的温度是{:.2f}F".f.原创 2022-03-19 10:14:35 · 624 阅读 · 0 评论 -
Python:遍历字典中的键和对应的值
练习:喜欢的数使用一个字典来存储一些人喜欢的数。请想出5个人的名字,并将这些名字用作字典中的键;找出每个人喜欢的一个数,并将这些数作为值储存在字典中。打印每个人的名字和喜欢的数。我的方法:#keys(),items(),values()fnumbers = { 'f':'232', 'b':'7236', 'c':'45', 'd':'44', 'e':'12', }for a in fnumbers.keys(): b = fnumbers[a] print(...原创 2022-01-17 10:08:28 · 1399 阅读 · 1 评论 -
Python:矩阵加法、减法和数乘
#矩阵加法、减法和数乘print("Choose a function: 'addition', 'subtraction' or 'multiplication': ")function = input() #选择功能if function == "addition" or function == "subtraction": matrix_1 = [] #定义矩阵规模 matrix_2 = [] matrix_3 = [] lin.原创 2022-03-11 21:39:56 · 1829 阅读 · 0 评论 -
Python:输入并呈现任意规模矩阵
#用列表呈现矩阵matrix = [] #定义一个空列表line = input("Enter the line: ")row = input("Enter the row: ")line =int(line)row = int(row)number_1 = line * row #元素总数number_2 = 1number_3 = 1print(f"Enter a {line}*{row} matrix: ")while number_2 <= number_1:.原创 2022-03-10 21:02:41 · 411 阅读 · 0 评论 -
Python:输入一个年份,判断是否为闰年
#输入一个年份,判断是否为闰年message_1 = "Enter a number to judge if it is a leap year: "message_2 = " is a leap year."message_3 = " is not a leap year."message_4 = "continue or quit? "message_5 = "Wrong, please enter 'continue' or 'quit'. "choice = Truewhile c.原创 2022-03-09 22:45:11 · 5784 阅读 · 0 评论