摘要: 实例01(创建计算BMI指数的模块) 1 def fun_bmi(person,height,weight): 2 '''功能:根据身高和体重计算BMI指数 3 person: 姓名 4 height: 身高,单位:米 5 weight: 体重,单位:千克 6 ''' 7 print(person 阅读全文
posted @ 2022-12-13 21:57 Sharonsss 阅读(35) 评论(0) 推荐(0)
摘要: 实战01(大乐透号码生成器) 1 from random import sample 2 def number(): 3 front = sample([str(i) for i in range(1,36)],5) 4 back = sample([str(i) for i in range(1, 阅读全文
posted @ 2022-12-13 21:21 Sharonsss 阅读(280) 评论(0) 推荐(0)
摘要: 实例01(使用wx.StaticText输出Python之禅) 1 # -*- coding:utf-8 -*- 2 import wx 3 class MyFrame(wx.Frame): 4 def __init__ (self, parent,id): 5 wx. Frame. __init_ 阅读全文
posted @ 2022-12-13 20:45 Sharonsss 阅读(51) 评论(0) 推荐(0)
摘要: 实例01(制作一个跳跃的小球游戏) 1 # -*- coding:utf-8 -*- 2 import sys 3 import pygame 4 pygame.init() 5 size=width,height=640,480 6 screen=pygame.display.set_mode(s 阅读全文
posted @ 2022-12-13 16:16 Sharonsss 阅读(33) 评论(0) 推荐(0)
摘要: 实战01(导演为剧本选角色)1 def act(actor): 2 print(actor+"开始参演这个剧本") 3 A=input("导演选定的角色是:") 4 act(A) 实战02(模拟美团外卖商家的套餐)1 def taocan(a,b,c,d,e,f): 2 print('米线店套餐如下 阅读全文
posted @ 2022-12-09 23:48 Sharonsss 阅读(98) 评论(0) 推荐(0)
摘要: 实战01(模拟篮球自动弹跳) # -*- coding:utf-8 -*-import sys # 导入sys模块import pygame # 导入pygame模块 pygame.init() # 初始化pygamesize = width, height = 640, 480 # 设置窗口scr 阅读全文
posted @ 2022-12-01 23:32 Sharonsss 阅读(43) 评论(0) 推荐(0)
摘要: 实例01(创建SQLite数据库文件)1 import sqlite3 2 #连接到SQLite数据库 3 #数据库文件是mrsoft.db,如果文件不存在,会自动再当前目录创建 4 conn=sqlite3.connect('mrsoft.db') 5 cursor=conn.cursor() 6 阅读全文
posted @ 2022-11-23 23:41 Sharonsss 阅读(48) 评论(0) 推荐(0)
摘要: 实战01(模拟支付宝蚂蚁森林的能量产生过程) 1 print("查询能量请输入能量来源!退出程序请输入0") 2 source=input("能量来源如下:\n生活缴费,行走捐,共享单车,线下支付,网络购票\n") 3 if source=="生活缴费": 4 print("100g") 5 eli 阅读全文
posted @ 2022-11-20 08:16 Sharonsss 阅读(136) 评论(0) 推荐(0)
摘要: 实战01(模拟手机充值场景) print("欢迎使用移动充值业务,请输入充值金额:") n=int(input())print("充值成功,您本次充值"+str(n)+"元") 实战02(绘制《植物大战僵尸》中的石头怪) 实战02(绘制《植物大战僵尸》中的石头怪) 1 print(''' 2 * * 阅读全文
posted @ 2022-11-13 00:15 Sharonsss 阅读(268) 评论(0) 推荐(0)
摘要: 实战01(根据当前时间创建文件) import timedef create(): global name localTime = time.strftime("%Y%m%d%H%M%S", time.localtime()) name = localTime + '.txt' with open( 阅读全文
posted @ 2022-11-09 23:39 Sharonsss 阅读(66) 评论(0) 推荐(0)