Login

Search

Learn
2022.11.01 22:17

1.1 Getting into Python

Views 2013 Votes 0 Comment 0

Before we dive into Python, let's start with the operators used in Python.

 

Addition

>>> 1 + 2

 

 

 

 

 

Try writing the above and pressing enter. Do you get an answer?

 

 

Subtraction

>>> 50 - 4
46

 

 

 

 

 

Multiplication

>>> 12345678 * 3
37037034

 

 

 

 

 

Computers know that * means multiply. What about division?

 

 

division

/ is division.

 

 

>>> 5000 / 3
1666.6666666666667
>>> 5000 // 3
1666

 

 

 

 

 

 

 

Remainder

To get the remainder, use the % operator. For example, the remainder of 50 divided by 8 is ?

 

>>> 50 % 8
2

 

 

 

 

 

The quotient of 50 divided by 8 is 6 and the remainder is 2, so the result of 50% 8 is 2.

 

 

Finding the quotient and remainder at once

 

>>> divmod(50, 8)
(6, 2)

 

 

 

 

You can also use the divmod() function to calculate the quotient and remainder at once, like this

 

List of Articles
No. Subject Author Date Views
Notice Learn What is Python? admin 2024.10.19 3102
» Learn 1.1 Getting into Python admin 2022.11.01 2013
23 Learn πŸ‡°πŸ‡· 8.1 μ˜ˆμ™Έμ²˜λ¦¬(try, except) admin 2022.10.27 1373
22 Learn πŸ‡°πŸ‡· 7.1. 클래슀(class)와 μΈμŠ€ν„΄μŠ€ admin 2022.10.27 1325
21 Learn πŸ‡°πŸ‡· 6.1 ν…μŠ€νŠΈ 파일 admin 2022.10.21 1267
20 Learn πŸ‡°πŸ‡· 5.3 μ—¬λŸ¬ κ°€μ§€ λͺ¨λ“ˆ admin 2022.10.15 1349
19 Learn πŸ‡°πŸ‡· 5.2 λͺ¨λ“ˆ κ°€μ Έμ˜€κΈ°(import) admin 2022.10.07 1501
18 Learn πŸ‡°πŸ‡· 5.1 λͺ¨λ“ˆμ΄λž€ admin 2022.10.03 1194
17 Learn πŸ‡°πŸ‡· 4.5 μ„ΈνŠΈ(set) admin 2022.10.02 1371
16 Learn πŸ‡°πŸ‡· 4.4 λ”•μ…”λ„ˆλ¦¬(dict) admin 2022.09.30 1187
15 Learn 4.4 Dictionary admin 2022.09.29 1408
14 Learn πŸ‡°πŸ‡· 4.3 νŠœν”Œ(tuple) admin 2022.09.21 1188
13 Learn πŸ‡°πŸ‡· 4.2 λ¬Έμžμ—΄κ³Ό 리슀트 admin 2022.09.16 1301
12 Learn πŸ‡°πŸ‡· 4.1 μžλ£Œν˜• admin 2022.09.16 1479
11 Learn πŸ‡°πŸ‡· 3.4 λžŒλ‹€(lambda) admin 2022.09.16 1238
10 Learn πŸ‡°πŸ‡· 3.3 μ§€μ—­λ³€μˆ˜, μ „μ—­λ³€μˆ˜ admin 2022.09.15 1251
9 Learn πŸ‡°πŸ‡· 3.2 λ°˜ν™˜(return)λ¬Έ admin 2022.09.10 1125
8 Learn πŸ‡°πŸ‡· 3.1 ν•¨μˆ˜ admin 2022.09.01 1274
7 Learn πŸ‡°πŸ‡· 2.3 forλ₯Ό μ‚¬μš©ν•˜λŠ” 반볡문 admin 2022.08.24 1321
6 Learn πŸ‡°πŸ‡· 2.2 쑰건문 (if-elif-else) admin 2022.08.23 1626
5 Learn πŸ‡°πŸ‡· 2.1 while을 μ‚¬μš©ν•˜λŠ” 반볡문 admin 2022.08.23 1198
Board Pagination Prev 1 2 3 Next
/ 3