首页
友情链接
每日60s读懂世界
Search
1
伊朗.ir后缀域名免费注册
225 阅读
2
Python模拟实现“京东秒杀”界面文字内容
182 阅读
3
用C语言程序将十进制数转换为二进制数
173 阅读
4
Python的NumPy库
157 阅读
5
英语词汇105-121
141 阅读
英语的平行世界
HTML5+CSS3
Python
C语言
MySQL
技术分享
登录
Search
标签搜索
英语的平行世界
正文
词汇
Python程序设计任务驱动式教程
Python数据分析案例实战
Numpy库
C语言程序设计实例教程慕课版|第二版
中华人民共和国网络安全法
.ir域名
域名注册
免费域名
M.
累计撰写
21
篇文章
累计收到
88
条评论
首页
栏目
英语的平行世界
HTML5+CSS3
Python
C语言
MySQL
技术分享
页面
友情链接
每日60s读懂世界
搜索到
8
篇与
的结果
2023-10-25
Python应用比较运算符与逻辑运算符设置条件表达式
说明开头添加引用 datetime 模块 name 定义为书籍的名称 publisher 定义为出版社名称 price 定义为书籍价格 strDate 定义为出版日期 print 输出判断数据价格逻辑运算符例子:变量x为21,y为10,z为0,即x=21,y=10,z=0符号名称表达式方向说明实例运算结果and逻辑与x and y从左到右如果x为False或0,x and y返回False或0,否则返回y的计算值x and y,x and z,z and x10,0,0or逻辑或x or y从左到右如果x为True,则返回x的值,否则返回y的计算值x or y,x or z,z or x21,21,21not逻辑非not x从右到左如果x为True,则返回False。如果x为False,则返回Fruenot x,not y,not(x and y),not(x or y),not zFalse,False,False,False,True任务3-2{tabs}{tabs-pane label="任务代码"}import datetime name="HTML5+CSS3网页设计与制作实战" name1="HTML5+CSS3网页设计与制作实战" name2="HTML5+CSS3移动Web开发实战" publisher="人民邮电出版社" publisher1="人民邮电出版社" publisher2="高等教育出版社" price="59.80" priceTest="91.50" price1="50.00" price2="85.00" strDate="2019-11-8" date=datetime.datetime.strptime(strDate,"%Y-%m-%d") strDateStart="2019-7-1" dateStart=datetime.datetime.strptime(strDateStart,"%Y-%m-%d") strDateEnd="2020-7-1" dateEnd=datetime.datetime.strptime(strDateEnd,"%Y-%m-%d") strDateTest1="2019-9-1" dateTest1=datetime.datetime.strptime(strDateTest1,"%Y-%m-%d") StrDateTest2="2020-10-5" dateTest2=datetime.datetime.strptime(StrDateTest2,"%Y-%m-%d") print("判断价格范围1:",price>=price and price<price2) print("判断价格范围2:",priceTest>=price and priceTest<price2) print("判断出版日期范围1:",date>dateStart and date<=dateEnd) print("判断出版日期范围2:",dateTest1<dateStart or dateTest1>dateEnd) print("判断出版日期范围3:",dateTest2>dateStart or dateTest2>dateEnd) print("判断图书名称与出版社:",name==name1 and publisher==publisher1) print("判断价格与出版日期:",price>=price1 and price<price2 and date>dateStart and date<=dateEnd){/tabs-pane}{tabs-pane label="运行成功效果"}{/tabs-pane}{/tabs}
2023年10月25日
126 阅读
0 评论
0 点赞
2023-10-25
Python应用比较运算符设置查询条件表达式
说明import是指模块名,可以直接引入datetime 是时间日期类型模块,可以准确表示精准的日期和时间简单来说就是直接引入时间日期类型模块name、name1、name2 赋值为书名pubisher、pubisher1、pubisher2 赋值为出版社price、price1、price2 赋值为价格strDate、strDateStart、steDateEnd 赋值为出版日期引用了时间模块中的datetime综合类date类:主要用于处理年、月、日time类:主要用于处理时、分、秒datetime类:date类和time类的综合使用,可以处理年、月、日、时、分、秒timedelta类:主要用于做时间加减的 这个类的使用一定要结合date类的对象或datetime类的对象使用 注意timedelta不能单独和time的对象结合使用,末尾会解释tzinfo类:时区类strftime()用来格式化 datetime 对象,会比较方便== 比较x和y两个对象是否相等,x=y运行结果为False!= 比较x和y两个对象是否不相等,x!=y运行结果为True> 比较x是否大于y,x>y运行结果为True< 比较x是否小于y,x<y运行结果为False>= 比较x是否大于或者等于y,x>=y运行结果为True<= 比较x是否小于或者等于y,x<=y运行结果为False任务3-1{tabs}{tabs-pane label="任务代码"}import datetime name="HTLM5+CSS3 网页设计与制作实战" name1="HTLM5+CSS3 网页设计与制作实战" name2="HTLM5+CSS3 移动Web开发实战" publisher="人民邮电出版社" publisher1="人民邮电出版社" publisher2="高等教育出版社" price="59.80" price1="50.00" price2="85.00" strDate="2019-11-8" date=datetime.datetime.strptime(strDate,"%Y-%m-%d") strDateStart="2019-7-1" dateStart=datetime.datetime.strptime(strDateStart,"%Y-%m-%d") strDateEnd="2020-7-1" dateEnd=datetime.datetime.strptime(strDateEnd,"%Y-%m-%d") print("判断图书名称:",name==name1,name==name2) print("判断出版社:",publisher!=publisher1,publisher2!=publisher) print("判断价格1:",price>=price1) print("判断价格2:",price<price1) print("判断价格3:",price<price2) print("判断价格4:",price>=price2) print("判断出版社日期1:",date>=dateStart) print("判断出版社日期2:",date<dateStart) print("判断出版社日期3:",date<dateEnd) print("判断出版社日期4:",date>=dateEnd){/tabs-pane}{tabs-pane label="运行成功效果"}{/tabs-pane}{/tabs}
2023年10月25日
117 阅读
0 评论
0 点赞
2023-10-25
用Python计算与输入购买商品的实付总额等数据
说明num 赋值为商品数量 input输出number 定义为整数, int指的是整数originalprice、discountprice 赋值为99.80和91.80,后面代码将其定义为(商品原价-商品现价)和商品原价discountRate 定义为(商品原价-商品现价)/商品原价total 定义为所购买的商品总价cashback 定义为返现金额discount 定义为商品优惠金额totalDiscount 定义为返现金额加上优惠金额carriage 赋值为15,定义为运费payable定义为实付总额chr(9785) 是一个笑脸表情{:.2f}.format 表示输出的函数保留两位小数任务2-3{tabs}{tabs-pane label="任务代码"}num=input("请输入购买数量:") number=int(num) originalPrice=99.80 discountPrice=91.80 discountRate=discountPrice/originalPrice total=number*discountPrice cashback=150.00 discount=15.00 totalDiscount=cashback+discount carriage=15.00 payable=total-totalDiscount+carriage print(str(number)+"件商品,总商品金额: ¥"+"{:.2f}".format(total)) print(" 运费: "+chr(9785)+"¥"+"{:.2f}".format(carriage)) print(" 返现: -¥"+"{:.2f}".format(cashback)) print(" 折扣率: -¥"+"{:.2f}%".format(discountRate*100)) print(" 商品优惠: -¥"+"{:.2f}".format(discount)) print(" 实付总额: ¥"+"{:.2f}".format(payable)){/tabs-pane}{tabs-pane label="运行成功效果"}{/tabs-pane}{/tabs}format函数用法格式描述<左对齐>右对齐^居中对齐{:b}将数字用二进制表示{:c}将整数转换成对应的Unicode字符串{:d}将数字用十进制整数表示(format中相应内容应是整数{:o}将数字用八进制表示{:x}将数字用十六进制表示{:#x}针对字母小写,补充前缀其他进制可以用{:#X}针对字母大写,补充前缀只有十六进制使用{:f}将数字用浮点数表示{:e}将数字用科学计数法表示{:%}将数字用百分数表示{:,}用逗号分隔数字{:.2%}将数字用百分数表示,且小数点保留两位小数{:.2f}保留两位小数{:.3f}保留三位小数{:+.2f}带符号保留小数点后两位{:.0f}不带小数{:0<2d}数字补零(填充左边,宽度为2){:x<4d}数字补x(填充右边,宽度为4){:.2%}百分比格式{:.2e}指数记法{:>10d}右对齐(宽度为10){:<10d}左对齐(宽度为10){:^10d}居中对齐(宽度为10)
2023年10月25日
102 阅读
0 评论
0 点赞
2023-10-25
用Python输出当前日期和时间
说明第一行引入time模块第二行用于输出当前日期第三行获取当前时间的小时数第四行获取当前时间的分钟数第五行获取当前时间的秒数第六行输出当前时间任务2-1{tabs}{tabs-pane label="任务代码"}import time print("当前日期: ",time.strftime("%Y年%m月%d日",time.localtime())) hour=time.localtime().tm_hour minute=time.localtime().tm_min second=time.localtime().tm_sec print("当前时间: {0}时{1}分{2}秒".format(hour,minute,second,end="\r")) {/tabs-pane}{tabs-pane label="运行成功效果"}{/tabs-pane}{/tabs}struct_time元组属性名称含义tm_year4位数的年份0000~9999tm_mon1~12的月份tm_mday1~31的日期tm_hour0~23的小时tm_min0~59的分钟tm_sec0~61的秒数tm_wday0~6的周(0表示周一)tm_yday1~366(366表示闰年)tm_isdst1(夏令时)0(非夏令时),-1(不确定),默认为1time内置函数函数说明time.perf_number()用于返回系统运行时间time.process_time()用于返回进程运行时间time.altzone()返回相对于格林尼治西部夏时令地区的偏移秒数,如果该地区在格林尼治东部会返回负值如西欧,包括英国。启用夏时令地区才能使用time.asctime([tupletime])接收时间元组并返回一个形式为“Tue Dec 11 18:07:14 2020”(2020年12月11日周二18时07分14秒)的字符串time.ctime([sece])相当于asctime(localitime(sece)) ,没有参数相当于asctime()time.gmtime([sece])接收时间戳并返回格林尼治天文时间下的时间元组time.localitime([sece])接收时间戳并返回当地时间下的时间元组t(t.tm_isdst可取0或1,取决于当地当时是不是夏时令)time.mktime(tupletime)接受时间元组并返回时间戳time.sleep(sece)推迟调用线程的运行,sece指秒数time.strftime(fmt[,tupletime])结束时间元组,并返回以可读字符串表示当地时间,格式由fml决定time.strptime(str,fml='%a%b%d%H:%M:%S%Y')根据fml的格式把时间字符串解析为时间元组time.time()返回当前时间的时间戳time.tzset()根据环境变量TZ重新初始化时间相关设置time.pert_counter()返回计时器的精准时间(系统的运行时间),包含整个系统的睡眠时间。由于返回值的基准点是未定义的,所以只有连续调用的结果之间的差才是有效的time.process()返回当前进程运行结束CPU的时间总和,不包含睡眠时间。由于返回值的基准点是未定义的,所以只有连续调用的结果之间的差才是有效的time库的三类函数函数说明time获得当前的时间戳,浮点数,从1970.1.1 0:00开始以秒为单位的数值ctime获得当前时间并以易读方式表示gmtime表示为计算机可处理的时间格式strftime(str,tpl)tpl是格式化模板字符串,用来定义输出效果,ts是计算机内部时间类型变量strptime(str,tpl)str是字符串形式的时间值perf_counten()测量时间,返回一个CPU级别精准时间计数值,单位为秒sleep()产生时间,如sleep(s)s拟休眠时间,单位为秒,可以是浮点数
2023年10月25日
97 阅读
0 评论
0 点赞
2023-10-25
用Pyhon计算并输出购买商品的实付金额与平均价格等数据
说明number1 赋值为1, number1在这里是一号商品数量price1 赋值为45.20, price1 在这里是一号商品价格amount 赋值为 number1amount 二次赋值为 amount+number2total 赋值为 number1*price1+number2*price2discount 赋值为40.00payable 赋值为 total-discountaveragePrice 赋值为 total/amounttotal 定义为商品总额, discount 定义为商品优惠, payable 定义为实付总额, averagePrice 定义为平均价格任务2-1{tabs}{tabs-pane label="代码内容"}number1=1 price1=45.20 amount=number1 number2=1 price2=59.30 amount=amount+number2 total=number1*price1+number2*price2 discont=40 payable=total-discont averagePrice=total/amount print("商品总额: ¥",total) print("商品优惠: -¥",discont) print("实付优惠: ¥"+str(payable)) print("平均价格: ¥"+str(averagePrice)){/tabs-pane}{tabs-pane label="运行成功效果"}{/tabs-pane}{/tabs}
2023年10月25日
123 阅读
0 评论
0 点赞
1
2