当前位置:网站首页>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 ’:‘ 了
边栏推荐
- QObject source code analysis -d pointer and Q pointer
- Maya modeling exercise
- Flask SSTI injection learning
- Numpy basic package for data analysis
- Go language founder leaves Google
- Browser based split screen reading
- Doris学习笔记之与其他系统集成
- Doris learning notes integration with other systems
- I2C设备驱动程序的层次结构
- Practical guide for network security emergency response technology (Qianxin)
猜你喜欢

DVWA practice - brute force cracking

PS制作加载GIF图片教程

SSM framework integration, simple case

机械制造业数字化新“引擎”供应链协同管理系统助力企业精细化管理迈上新台阶

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

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

微信公众号正式环境上线部署,第三方公众平台接入

直播课堂系统05-后台管理系统

SQL优化的一些建议,希望可以帮到和我一样被SQL折磨的你

如何让一套代码完美适配各种屏幕?
随机推荐
Famous handwritten note taking software recruit CTO · coordinate Shenzhen
应用实践:Paddle分类模型大集成者[PaddleHub、Finetune、prompt]
idea正则表达式替换(idea正则搜索)
sqli-labs Basic Challenges Less11-22
[eloquence] negotiation persuasion skills and Strategies
Dpkg package download addresses of various platforms (including arm64)
QObject源码剖析-d指针和q指针
河源市区推出消防安全主题奶茶 助推夏季火灾防控
I2C设备驱动程序的层次结构
基于PaddleOCR开发uni-app离线身份证识别插件
【cartographer_ros】八: 官方Demo参数配置和效果
awk从入门到入土(21)awk脚本调试
Two Sum
Jmeter的随机数函数怎么用
English语法_不定代词 - other / another
CTS测试介绍(面试怎么介绍接口测试)
Summary of some problems about left value and right value [easy to understand]
MySQL 45 talks about | 06 global locks and table locks: Why are there so many obstacles to adding a field to a table?
QObject source code analysis -d pointer and Q pointer
Opencv video tracking "suggestions collection"