40923235 cp2020

  • Home
    • Site Map
    • reveal
    • blog
  • 首頁
  • HW1
    • UNIT 1
      • Strategies for Learning學習策略
      • What You Need to Know About the Course您需要了解的課程內容
      • About these Materials 關於這些材料
      • Metacognition元認知
      • Metacognition in Action行動中的元認知
    • UNIT2
      • Introduction簡介
      • Functions of Computers  Input  Output  Storage  and Processing計算機功能  輸入  輸出  存儲和處理
      • Hardware硬件
      • Software軟件
      • Fireware固件
      • Componentization  Standardization組件化  標準化
      • Connection Interfaces and Cables連接接口和電纜
  • HW2
  • HW3
    • Chacrater input字符輸入
      • input strings types int輸入字符串類型int
      • Discussion討論區-1
      • User input in Python使用Python的用戶輸入
      • Manipulating strings a few ways處理字符串幾種方法
    • Odd Or Even奇數或偶數
      • Exercise 2 and solution練習2和解決方案
      • Discussion討論區-2
      • Modular arithmetic the modulus operator模塊化算術模運算符
      • Conditionals有條件的
      • Checking for equality and comparators in general檢查是否相等以及一般的比較器
    • List Less Than Ten列出少於十
      • Exercise 3 and Solution練習3和解決方案
      • Discussion討論區-3
      • Lists清單
      • More Conditionals更多條件
  • 心得
Discussion討論區-2 << Previous Next >> Conditionals有條件的

Modular arithmetic the modulus operator模塊化算術模運算符

We have been doing arithmetic (addition, subtraction, multiplication, division) since elementary school, and often it is useful for us to find not the answer to a division problem but the remainder when we do a division operation. This operation is called the “modulus operation.” For example, when I divide 5 by 3, the remainder is 2, and the sentence reads like this: “5 modulo 3 is 2.”

In the Python shell:

>>> 5 % 3

2

>>> 6 % 3

0

>>> 7 % 3

1

The % sign is exactly the modulus operator.

從小學開始,我們就一直在進行算術運算(加,減,乘,除),這對於我們尋找除法問題不是答案,而是對除法運算的其餘部分有用。該操作稱為“模運算”。例如,當我將5除以3時,餘數為2,句子的內容如下:“ 5模3為2”。

在Python Shell中:

  
>>> 5 % 3
2
>>> 6 % 3
0
>>> 7 % 3
1

該%標誌是完全模運算符。


Discussion討論區-2 << Previous Next >> Conditionals有條件的

Copyright © All rights reserved | This template is made with by Colorlib