当前位置:网站首页>006 operator introduction
006 operator introduction
2022-07-25 14:39:00 【A rookie who can't burn to death is called Phoenix】
One 、 Mind mapping

Two 、 Knowledge and examples
1、a=a+3 Equate to a+=3;a=a3 Equate to a=3
2、“/” True division ;“//” Rounding Division
Example :10\3=3.33333;10//3=3
3、 Square operation
32=9 It's Square 2 Time
3***5 It's Square 5 Time
4、 Examples of remainder operations :
5%2 Represents the remainder result =1
5、 Logic short circuit phenomenon of logic operation symbols
Please say the answer as fast as you can :not 1 or 0 and 1 or 3 and 4 or 5 and 6 or 7 and 8 and 9
answer :4
reason : stay python in , Logical operators or,x or y, If x by True Then return to x, If x by False return y value . Because if x by True that or There is no need to calculate , Because if one is true, it is true , So back x Value . If x The value of is false , that or The result of the operation depends on y, So back y Value .
** stay python in , Logical operators and,**x and y, If x by True Then return to y value . If x by False Then return to y value . If x The value of is True,and The operation of will not end , Will continue to watch y Value , So at this time, true or false depends on y Value , therefore x If it is true , Then return to y Value . If x For false , that and The operation will end , Because one is false and For false , So back x Value .
3、 ... and 、 In class code
Four 、 After-school exercises
1、 Improve our games : When the user enters the wrong type , Prompt the user to re-enter , Prevent the program from crashing .
print('***** i love cjy *****')
a=input('hi, Guess how many hours I slept last night \n')
while a.isdigit ()!=True:
a= input('please input a int number\n')
if int(a)==9:
print(' You guessed it , But I haven't slept enough ')
else:
print(' I sleep How long have you been unable to count ? Don't care about me at all , idot !!! Stupid stupid \n' )
print(' Game over , Play something different next time ')
2、 Write a program , Determine whether a given year is a leap year .
a=input('please input a year: ')
year=int(a)
if (year%4==0 and year%100!=0) or (year%400==0):
print('this is a leap year ')
else:
print('this is a not a leap year')
3、 Set up printing 1-100 Base number of
Code :
for i in range(1,101):
if i%2!=0:
print(i)
i+=1
Mistakes that have happened :
stay for Forget to use after the cycle ’:‘ 了
边栏推荐
- 软件测试 -- 1 软件测试知识大纲梳理
- 苹果官网产品打折 买iPhone 13 Pro Max 可省600元
- The supply chain collaborative management system, a new "engine" of digitalization in machinery manufacturing industry, helps enterprises' refined management to a new level
- 微信公众号正式环境上线部署,第三方公众平台接入
- Number of high-quality number pairs [bit operation characteristics + abstract ability evaluation + grouping fast statistics]
- 【MySQL必知必会】触发器 | 权限管理
- 如何让一套代码完美适配各种屏幕?
- Matplotlib data visualization three minutes entry, half an hour enchanted?
- 云安全技术发展综述
- 【MySQL系列】-索引知多少
猜你喜欢

关于ROS2安装connext RMW的进度条卡在13%问题的解决办法

Matplotlib data visualization three minutes entry, half an hour enchanted?

Gameframework making games (I)

Go语言创始人从Google离职

Heyuan City launched fire safety themed milk tea to boost fire prevention and control in summer

LeetCode-198-打家劫舍

Realsense-Ros安装配置介绍与问题解决

PS制作加载GIF图片教程

阿里云技术专家邓青琳:云上跨可用区容灾和异地多活最佳实践

安防市场进入万亿时代,安防B2B网上商城平台精准对接深化企业发展路径
随机推荐
Jmeter的随机数函数怎么用
[nuxt 3] (XI) transmission & module
The concept and operation rules of calculus of variations
Vs2017 large factory ERP management system source code factory general ERP source code
软件测试 -- 1 软件测试知识大纲梳理
Browser based split screen reading
sudo rosdep init Error ROS安装问题解决方案
基于PaddleOCR开发uni-app离线身份证识别插件
Filters get the data in data; Filters use data in data
How to make a set of code fit all kinds of screens perfectly?
[eloquence] negotiation persuasion skills and Strategies
关于左值和右值的一些问题总结[通俗易懂]
Gameframework making games (II) making UI interface
云安全技术发展综述
基于浏览器的分屏阅读
物理量与单位符号的书写标准
Numpy basic package for data analysis
IP地址分类,判断一个网段是子网超网
The security market has entered a trillion era, and the security B2B online mall platform has been accurately connected to deepen the enterprise development path
How to design a high concurrency system?