zoukankan      html  css  js  c++  java
  • Python基础学习笔记之运算符

    许多人对于编程学习中的数学能力都存在或多或少的误解,虽然每一种编程语言都包含了处理数字和进行数学计算的方法,但是并不像一些人想象得那么难,相反还十分简单,毕竟不是一定要数学天才才能学得好编程。本文为大家总结了关于运算符的Python基础学习笔记,下面一起来看看吧!
     
     
     
     
    1、运算符的表示含义
     
    + 加号
    - 减号
    / (斜杠)除法
    * (星号)乘法
    % (百分号)模除
    < 小于号
    > 大于号
    <= 小于等于号
    >= 大于等于号
     
    2、运算操作
     
    关于Python基础学习中运算符的运算操作完全就是小学水准的计算难度。是的你没有想错,这里的加减乘除完全就是遵循基础的运算法则,比如从左到右开始运算,有乘除先算乘除,有括号先算括号里的。这里给大家展示一段代码案例:
     
    print "I will now count my chickens:"
     
    print "Hens", 25 + 30 / 6
    print "Roosters", 100 - 25 * 3 % 4
     
    print "Now I will count the eggs:"
     
    print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6
     
    print "Is it true that 3 + 2 < 5 - 7?"
     
    print 3 + 2 < 5 - 7
     
    print "What is 3 + 2?", 3 + 2
    print "What is 5 - 7?", 5 - 7
     
    print "Oh, that's why it's False."
     
    print "How about some more."
     
    print "Is it greater?", 5 > -2
    print "Is it greater or equal?", 5 >= -2
    print "Is it less or equal?", 5 <= -2
     
    终端运行结果:
     
    $ python ex3.py
    I will now count my chickens:
    Hens 30
    Roosters 97
    Now I will count the eggs:
    7 Is it true that 3
    +
    2
    <
    5
    -
    7
    False
    What is 3 + 2? 5
    What is 5 - 7? -2
    Oh, that's why it's False.
    How about some more.
    Is it greater? True
    Is it greater or equal? True
    Is it less or equal? False
     
    看完上面的Python基础学习笔记之后,大家对于运算符的知识点是不是已经全部掌握了呀?如果大家觉得这章内容过于简单,也不要掉以轻心,尝试着多做几遍代码的练习吧!
     
  • 相关阅读:
    使用Stream流递归 组合树形结构
    MySQL 8 通用表表达式
    sa-token 权限认证
    先更新缓存还是先更新数据库?
    钉钉 回调事件 消息加解密
    commons-io
    stream和parallelstream的区别
    消除if...else
    springboot 扩展xml请求和响应
    springboot admin 邮箱
  • 原文地址:https://www.cnblogs.com/nanhe/p/13517947.html
Copyright © 2011-2022 走看看