随笔分类 -  人工智能

上一页 1 2 3 4 下一页
Python函数(下) _ 不做代码复读机
摘要:def calculate_BMI(weight, height): BMI = weight / (height * height) if BMI < 18.5: category = "偏瘦" elif BMI < 25: category = "正常" elif BMI < 30: categ 阅读全文
posted @ 2025-10-31 11:29 偷懒的阿贤 阅读(3) 评论(0) 推荐(0)
Python函数(上) _ 不做代码复读机
摘要:def calculate_sector(central_angle, radius): #接下来是一些定义函数的代码 sector_area = central_angle / 360 * 3.14 * radius ** 2 print("Sector area: ", sector_area) 阅读全文
posted @ 2025-10-31 11:17 偷懒的阿贤 阅读(3) 评论(0) 推荐(0)
列表
摘要:1 阅读全文
posted @ 2025-10-31 10:33 偷懒的阿贤 阅读(6) 评论(0) 推荐(0)
数组
摘要:1 阅读全文
posted @ 2025-10-31 10:32 偷懒的阿贤 阅读(4) 评论(0) 推荐(0)
字典
摘要:1 阅读全文
posted @ 2025-10-31 10:32 偷懒的阿贤 阅读(3) 评论(0) 推荐(0)
Python 格式化字符串 _ 优雅群发春节短信
摘要:gpa_dict = {}#字典增加key:valuegpa_dict.setdefault("A", 10.2)gpa_dict.setdefault("B", 30.315)gpa_dict.setdefault("C", 20.45)gpa_dict.setdefault("D", 40.65 阅读全文
posted @ 2025-10-31 10:31 偷懒的阿贤 阅读(6) 评论(0) 推荐(0)
Python while循环 _ 捕捉日落
摘要:count = 0total = 0user_input = input("请输入数字(完成所有数字输入后,请输入q终止程序):")while user_input != "q": num = float(user_input) total += num count += 1 if count == 阅读全文
posted @ 2025-10-30 21:59 偷懒的阿贤 阅读(8) 评论(0) 推荐(0)
Python for循环 _ 找出不正常体温
摘要:total = 0#range(1,101) 其实是加到100,不会加到101for i in range (1,101): total = total + iprint("\n" + str(total)) 阅读全文
posted @ 2025-10-30 21:48 偷懒的阿贤 阅读(4) 评论(0) 推荐(0)
Python字典 _ 创个秒查流行语的词典
摘要:#声明字典slang_dict = {}slang_dict["觉醒年代"] = "A"slang_dict["双剑"] = "何必"slang_dict["加入"] = "“打不过”"query = input("请输入您想要查询的文字:")if query in slang_dict: prin 阅读全文
posted @ 2025-10-30 20:09 偷懒的阿贤 阅读(12) 评论(0) 推荐(0)
Python列表 _ 创一个购物清单
摘要:shopping_list = []shopping_list.append("键盘")shopping_list.append("键帽")print(shopping_list)print(shopping_list[0])print(len(shopping_list))price = [1,2 阅读全文
posted @ 2025-10-30 18:01 偷懒的阿贤 阅读(17) 评论(0) 推荐(0)
Python逻辑运算 _ 今年过节能收礼吗
摘要:house_work_count = int(input("house_work_count:"))red_envelope_count = int(input("red_envelope_count:"))shopping_count = int(input("shopping_count:")) 阅读全文
posted @ 2025-10-30 17:48 偷懒的阿贤 阅读(7) 评论(0) 推荐(0)
Python嵌套_多条件判断 _ 对象今天会生气吗 II
摘要:#BMI = 体重 / (身高 ** 2)user_weight = float(input("请输入您的体重(单位:kg):"))user_height = float(input("请输入您的身高(单位:m):"))user_BMI = user_weight / (user_height) * 阅读全文
posted @ 2025-10-30 17:37 偷懒的阿贤 阅读(7) 评论(0) 推荐(0)
Python条件语句 _ 对象今天会生气吗
摘要:mood_index = int(input("对象今天的心情指数是:"))if mood_index >= 60: print("恭喜,今晚应该可以打游戏,去吧皮卡丘!") print("<><><><><>")else: # mood_index<60 print("为了自个儿小命,还是别打了。 阅读全文
posted @ 2025-10-30 17:24 偷懒的阿贤 阅读(8) 评论(0) 推荐(0)
Python input _ 写个用户问答互动程序
摘要:#BMI = 体重 / (身高 ** 2)user_weight = float(input("请输入您的体重(单位:kg):"))user_height = float(input("请输入您的身高(单位:m):"))user_BMI = user_weight / (user_height) * 阅读全文
posted @ 2025-10-30 17:12 偷懒的阿贤 阅读(6) 评论(0) 推荐(0)
Python交互模式 _ 读一行执行一行
摘要:python脚本是对代码进行一行一行的解释并执行,所以可以不读完整个文件,进行执行某一行命令 交互模式:打开cmd中的命令行或者编辑器中的python命令行 阅读全文
posted @ 2025-10-30 16:51 偷懒的阿贤 阅读(8) 评论(0) 推荐(0)
Python数据类型 _ 程序世界的物种们
摘要:s = "一切问题都可以解决"#打印s变量print(s)#打印s变量类型print(type(s))#打印s变量中最后一个字符print(s[len(s)-1])#None类型,标识什么类型都不是none = None#打印none变量类型print(type(none))#布尔类型 只有Fals 阅读全文
posted @ 2025-10-30 16:45 偷懒的阿贤 阅读(6) 评论(0) 推荐(0)
Python注释 _ 悄悄在代码里骂用户?
摘要:单行注释: # a 多行注释: ''' aaa bbb ''' 阅读全文
posted @ 2025-10-30 16:33 偷懒的阿贤 阅读(8) 评论(0) 推荐(0)
Python数学运算 _ 用代码秒杀计算器
摘要:import math python的math库并不提供简单的加减乘除的api,如:add import math # 求和s = math.fsum([0.1, 0.2, 0.3]) # 0.6,减少浮点累积误差 # 连乘p = math.prod([1, 2, 3, 4]) # 24 # 余数与 阅读全文
posted @ 2025-10-30 16:28 偷懒的阿贤 阅读(6) 评论(0) 推荐(0)
Python命名规则 _ 哪些变量名算好名字
摘要:变量名字只能由文字、数字、下划线组成 下划线命名法:字母全部小写;不同单词用下划线分开;解释器区分大小写 阅读全文
posted @ 2025-10-30 16:03 偷懒的阿贤 阅读(8) 评论(0) 推荐(0)
Python变量 _ 怎么让程序记住你对象的手机号
摘要:greet = "你好"greet_chinese = greetgreet_english = "you hello"greet = greet_englishprint("\n" + greet + "13233455566")print(greet_chinese + "16522598746 阅读全文
posted @ 2025-10-30 15:57 偷懒的阿贤 阅读(4) 评论(0) 推荐(0)

上一页 1 2 3 4 下一页