#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 学习网站:www.runoob.com
#****************************************************
# Python3 运算符 *
#****************************************************
'''
python支持以下类型的运算符:算术运算符、比较(关系)运算符、赋值运算符
逻辑运算符、位运算符、成员运算符、身份运算符、运算符优先级。
'''
#============
# 算术运算符
#============
# +(加)、-(减)、*(乘)、/(除)、//(整除)、%(模)、**(幂)
#============
# 比较运算符
#============
# ==(等于)、!=(不等于)、>(大于)、<(小于)、>=(大于等于)、<=(小于等于)
#============
# 赋值运算符
#============
# =(正常赋值)、+=(加法赋值)、-=(减法赋值)、*=(乘法赋值)、/=(除法赋值)、
# %=(取模赋值)、**=(幂赋值)、//=(取整除赋值)
#============
# 位运算符
#============
# &(按位与)、|(按位或)、^(按位异或)、~(按位取反)、<<(按位左移)、
# >>(按位右移)
#============
# 逻辑运算符
#============
'''
x and y: 布尔“与” - 如果x,y同时为True,则返回True,否则返回False
x or y: 布尔“或” - 如果x,y同时为False,则返回False,反正返回True
not x: 布尔“非” - 如果x为True,返回False。如果x为False,返回True
'''
#============
# 成员运算符
#============
# in - 如果在指定的序列中找到值返回True,否则返回False
# not in - 如果在指定的序列中没有找到值返回True,否则返回False
x = 1; y = 20
l_tmp = [1, 2, 3, 4, 5]
print ( x in l_tmp ) # True
print ( x not in l_tmp ) # False
print ( y in l_tmp ) # False
print ( y not in l_tmp ) # True
print ("--------------------分割线------------------")
#============
# 身份运算符
#============
# 身份运算符用于比较两个对象的存储单元
# is - 判断两个标识符是不是引用自一个对象,是则True,否则False.
# not is - 判断两个标识符是不是引用自不同对象,不是则True,否则False.
x = 20; y = 20
print ( x is y ) # True
print ( id(x) == id(y) ) # True
# id()函数用于获取对象内存地址
y = 30
print ( x is y ) # False
print ( id(x) == id(y) ) # False
print ("--------------------分割线------------------")
# is 与 == 区别:http://blog.youkuaiyun.com/metears/article/details/79353357
#============
# 运算符优先级
#============
'''
运算符 描述
** 指数 (最高优先级)
~ + - 按位翻转, 一元加号和减号(最后两个的方法名为+@和-@)
* / % // 乘,除,取模和取整除
+ - 加法减法
>> << 右移,左移运算符
& 位 'AND'
^ | 位运算符
<= < > >= 比较运算符
<> == != 等于运算符
= %= /= //= -= += *= **= 赋值运算符
is is not 身份运算符
in not in 成员运算符
not or and 逻辑运算符
'''
#============
# 数字表示方式
#============
'''
2 进制是以 0b 开头的: 例如: 0b11 则表示十进制的 3
8 进制是以 0o 开头的: 例如: 0o11 则表示十进制的 9
16 进制是以 0x 开头的: 例如: 0x11 则表示十进制的 17
分别使用 bin,oct,hex 可输出数字的二进制,八进制,十六进制形式
'''
a = 0b111100
print ( a, bin(a) ) # 60 0b111100
print ( oct(a), hex(a) ) # 0o74 0x3c
相关推荐
PotPlayer自用皮肤
自用 PotPlayer 皮肤,仅微调了字体大小与颜色,是按个人习惯调整,未做适配性调整。
Python|运算符
本文是笔者在学习李立宗老师的课程后的笔记整理,希望能帮助到有需要的人,侵删。
2-shell及常用命令-续.pdf
2-shell及常用命令-续.pdf
Python3 学习笔记6_字符串_20180224
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.runoob.com #**************************************************** # Python3 字符串 * #*************************...
ROS探索篇(一)在Gazebo中实现移动机器人仿真与环境搭建
$x+y=z$
保姆级教程:手把手带你玩转英飞凌TC397开发板的板载资源(CAN FD、LCD、SD卡)
本文提供英飞凌TC397开发板的全面开发指南,涵盖CAN FD通信、LCD显示、SD卡文件系统和以太网通信等核心功能。通过详细的代码示例和硬件连接说明,帮助开发者快速上手并充分利用开发板的丰富资源,实现高效嵌入式系统开发。
Python3 学习笔记20_函数式编程-高阶函数-map/reduce_20180312
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.liaoxuefeng.com #**************************************************** # Python3 函数式编程-高阶函数-map/reduce * #************************...
APO的全面进化之路(2):走向IBP、建设端到端供应链计划体系
前一篇记录阐述了在供应链计划(Supply Chain Planning)领域里SAP的关键产品APO的不断进化之路,即部分产品从APO进化到S/4HANA,本篇将继续阐述进化之路上的另一大中坚产品力量SAP-IBP(Integrated Business Planning)。作为SAP数字化供应链(Digital Supply Chain)中供应链计划SCP的左膀右臂,S/4HANA与IBP共同完善了计划域的完整闭环。本篇作为收尾,在先谈对IBP产品的个人认知之前,特别是在当今这个IT产品迭代多、技术革新
Python3 学习笔记5_数字(Number)_20180223
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.runoob.com #**************************************************** # Python3 数字(Number) * #***********************...
Windows11下QGIS 3.34.4安装Geo-SAM插件全流程(附RTX3060 CUDA12.0配置技巧)
本文详细介绍了在Windows 11系统中为QGIS 3.34.4安装和配置Geo-SAM插件的完整流程,特别针对RTX 3060显卡用户提供了CUDA 12.0与PyTorch环境的精准搭建方案。通过预编码与交互式分割两大核心步骤,该插件能显著提升遥感图像半自动标注的效率,降低硬件门槛,是地理信息处理领域融合AI技术的实用指南。
SAP ERP销售应收&成本科目确定
ERP作为业财一体软件,其中最核心的就是业务与财务模块的自动集成,无需财务进行手工做账,提高工作效率的同时降低人工操作产生的误差。今天浅浅的分享一下SD模块生成会计凭证时,借贷项确定的系统配置。一般项目上借贷项、科目都有FICO提供,但是具体的集成配置是在SD这边。
Python3 学习笔记8_元组_20180227
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.runoob.com #**************************************************** # Python3 元组 * #*************************...
MAX30102心率血氧传感器原理图设计,已量产(e-Health传感器)
在最近的便携健康监测设备项目中,我们采用了集成算法的 MAX30102 心率血氧模块 —— 这类带内置 MCU 算法的传感器能直接输出心率 / 血氧数值,大幅降低了主控资源占用。但硬件电路的稳定性直接决定了 PPG 信号的采集精度,下面结合实际项目里的原理图,拆解下这个模块的设计细节。
Python3 学习笔记14_递归函数_20180305
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.liaoxuefeng.com #**************************************************** # Python3 函数 * #************************...
3.2 直流无刷电机(BLDC):状态空间模型与传递函数
状态空间模型和传递函数是分析BLDC电机动态特性的重要工具。状态空间模型通过微分方程描述系统内部状态与输入输出关系,适用于多变量系统分析;传递函数则在频域表征系统特性,便于控制器设计。本文详细推导了三相坐标系和dq坐标系下的BLDC电机状态空间模型,讨论了线性化方法,并介绍了从状态空间模型到传递函数的转换过程。这些模型为BLDC电机的控制系统设计提供了理论基础。
2、探索谷歌云平台(GCP):入门指南
本文全面介绍了谷歌云平台(GCP)的入门知识,涵盖其全球基础设施、核心服务和使用方法。内容包括GCP区域与可用区结构、创建免费账户、配置计算资源(如GCE虚拟机)、存储类型(PD、Filestore、GCS)、网络架构(VPC)、组织与项目管理、身份访问控制(IAM),以及计算、存储、数据库、大数据和人工智能等各类云服务。文章还提供了资源规划、安全管理和成本控制等实用建议,帮助用户快速上手并高效利用GCP构建可扩展的云解决方案。
Python3 学习笔记21_函数式编程-高阶函数-filter/sorted_20180312
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.liaoxuefeng.com #**************************************************** # Python3 函数式编程-高阶函数-filter/sorted * #*************************...
锂电池充电器电路设计 里面有电路
锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。
Python3 学习笔记13_函数的参数_20180305
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.liaoxuefeng.com #**************************************************** # Python3 函数 * #************************...
怀旧版电脑GBC模拟器
再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
Python3 学习笔记23_函数式编程-匿名函数_20180314
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.liaoxuefeng.com #**************************************************** # Python3 函数式编程-匿名函数 * #************************...
IMSL CNL 7.0.0 (x86-64)Crack
IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件
Python3 学习笔记11_条件语句_20180301
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.runoob.com #**************************************************** # Python3 循环语句 * #*************************...
Python3 学习笔记9_字典_20180228
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.runoob.com #**************************************************** # Python3 字典 * #*************************...
Python3 学习笔记1_基础语法_20180209
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.runoob.com #**************************************************** # Python3 教程 * #*********************...
Python3 学习笔记10_条件语句_20180228
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.runoob.com #**************************************************** # Python3 条件语句 * #*************************...
Python3 学习笔记25_函数式编程-偏函数_20180315
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.liaoxuefeng.com #**************************************************** # Python3 函数式编程-偏函数 * #************************...
Python3 学习笔记3_基本数据类型_20180222
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.runoob.com #**************************************************** # Python3 基本数据类型 * #***************************...
862



被折叠的 条评论
为什么被折叠?



