prop-cli 1.0.0__tar.gz → 1.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,224 @@
1
+ Metadata-Version: 2.4
2
+ Name: prop-cli
3
+ Version: 1.0.2
4
+ Summary: A command-line tool to solve proportions using the rule of three
5
+ Author-email: "Domenico Bruno \"Lobkowitz\"" <blobkowitz@gmail.com>
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: OS Independent
8
+ Requires-Python: >=3.6
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Dynamic: license-file
12
+
13
+ # prop-cli
14
+
15
+ [![PyPI version](https://img.shields.io/pypi/v/prop-cli)](https://pypi.org/project/prop-cli/)
16
+ ![License](https://img.shields.io/badge/license-MIT-blue.svg)
17
+ ![Python Version](https://img.shields.io/pypi/pyversions/prop-cli)
18
+ ![Downloads](https://img.shields.io/pypi/dm/prop-cli)
19
+ ![Tests](https://github.com/Lobko/prop-cli/actions/workflows/test.yml/badge.svg)
20
+ ![Lint](https://github.com/Lobko/prop-cli/actions/workflows/lint.yml/badge.svg)
21
+ ![Build](https://github.com/Lobko/prop-cli/actions/workflows/build.yml/badge.svg)
22
+
23
+ A command-line tool that solves proportions of the form:
24
+
25
+ ```
26
+ a : b = c : d
27
+ ```
28
+
29
+ where one term is unknown (`x`).
30
+ The tool uses classic **cross-multiplication**, also known as the **rule of three**.
31
+
32
+ ---
33
+
34
+ ## Installation
35
+
36
+ ```
37
+ pip install prop-cli
38
+ ```
39
+
40
+ This installs the command:
41
+
42
+ ```
43
+ prop-cli
44
+ ```
45
+
46
+ ### Installing from source (local clone)
47
+
48
+ If you clone this repository manually:
49
+
50
+ ```
51
+ git clone https://github.com/Lobko/prop-cli
52
+ cd prop-cli
53
+ ```
54
+
55
+ You can install the package locally with:
56
+
57
+ ```
58
+ pip install .
59
+ ```
60
+
61
+ Or, if you want to install it in development/editable mode:
62
+
63
+ ```
64
+ pip install -e .
65
+ ```
66
+
67
+ This allows you to modify the source code and use the `prop-cli` command immediately without rebuilding the package.
68
+
69
+ ---
70
+
71
+ ## Usage
72
+
73
+ ```
74
+ prop-cli <a> <b> <c> <d>
75
+ ```
76
+
77
+ Example:
78
+
79
+ ```
80
+ prop-cli 10 12 x 30
81
+ ```
82
+
83
+ Output:
84
+
85
+ ```
86
+ Proportion: 10:12 = 25:30
87
+ x = 25
88
+ ```
89
+
90
+ You can place `x` in any position:
91
+
92
+ ```
93
+ prop-cli x 5 6 12
94
+ prop-cli 2 x 4 8
95
+ prop-cli 3 9 x 27
96
+ prop-cli 4 5 0.1 x
97
+ ```
98
+
99
+ ---
100
+
101
+ ## More Examples
102
+
103
+ ```
104
+ prop-cli 5 20 x 120 # x = 30
105
+ prop-cli x 4 12 48 # x = 1
106
+ prop-cli 3 x 9 15 # x = 5
107
+ ```
108
+
109
+ ### Edge cases (real ones)
110
+
111
+ ```
112
+ prop-cli 1 x 0 5 # division by zero (c = 0)
113
+ prop-cli x 0 3 2 # division by zero (b = 0)
114
+ prop-cli 1 2 3 x # valid
115
+ ```
116
+
117
+ ---
118
+
119
+ ## How cross-multiplication works
120
+
121
+ Given the proportion:
122
+
123
+ ```
124
+ a : b = c : d
125
+ ```
126
+
127
+ Rule:
128
+
129
+ ```
130
+ a × d = b × c
131
+ ```
132
+
133
+ ### Diagram (horizontal)
134
+
135
+ ```
136
+ a : b = c : d
137
+ | |
138
+ | |
139
+ +---+---+
140
+ |
141
+ Cross-multiplication
142
+ |
143
+ a × d = b × c
144
+ ```
145
+
146
+ ### Diagram (vertical rule-of-three)
147
+
148
+ ```
149
+ a c
150
+ ─── = ───
151
+ b d
152
+
153
+ Cross multiply:
154
+
155
+ a × d = b × c
156
+ ```
157
+
158
+ ---
159
+
160
+ ## Solving when the unknown is in different positions
161
+
162
+ ### Unknown in second position
163
+
164
+ ```
165
+ a : x = c : d
166
+ a × d = x × c
167
+ x = (a × d) / c
168
+ ```
169
+
170
+ ### Unknown in fourth position
171
+
172
+ ```
173
+ a : b = c : x
174
+ a × x = b × c
175
+ x = (b × c) / a
176
+ ```
177
+
178
+ ---
179
+
180
+ ## Error handling
181
+
182
+ - Exactly one unknown `x` is required
183
+ - Other terms must be numeric
184
+ - Division by zero is detected and reported
185
+ - Scientific notation is avoided in output
186
+
187
+ ---
188
+
189
+ ## Project structure
190
+
191
+ ```
192
+ prop-cli/
193
+ ├── pyproject.toml
194
+ ├── README.md
195
+ ├── LICENSE
196
+ ├── CHANGELOG.md
197
+ ├── VERSION
198
+ ├── tests/
199
+ │ └── test_basic.py
200
+ ├── .github/
201
+ │ └── workflows/
202
+ │ ├── test.yml
203
+ │ ├── lint.yml
204
+ │ └── build.yml
205
+ └── proportion_calculator/
206
+ ├── cli.py
207
+ └── __init__.py
208
+ ```
209
+
210
+ ---
211
+
212
+ ## Contributing
213
+
214
+ 1. Fork the repository
215
+ 2. Create a feature branch
216
+ 3. Commit your changes
217
+ 4. Push the branch
218
+ 5. Open a Pull Request
219
+
220
+ ---
221
+
222
+ ## License
223
+
224
+ MIT License
@@ -0,0 +1,212 @@
1
+ # prop-cli
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/prop-cli)](https://pypi.org/project/prop-cli/)
4
+ ![License](https://img.shields.io/badge/license-MIT-blue.svg)
5
+ ![Python Version](https://img.shields.io/pypi/pyversions/prop-cli)
6
+ ![Downloads](https://img.shields.io/pypi/dm/prop-cli)
7
+ ![Tests](https://github.com/Lobko/prop-cli/actions/workflows/test.yml/badge.svg)
8
+ ![Lint](https://github.com/Lobko/prop-cli/actions/workflows/lint.yml/badge.svg)
9
+ ![Build](https://github.com/Lobko/prop-cli/actions/workflows/build.yml/badge.svg)
10
+
11
+ A command-line tool that solves proportions of the form:
12
+
13
+ ```
14
+ a : b = c : d
15
+ ```
16
+
17
+ where one term is unknown (`x`).
18
+ The tool uses classic **cross-multiplication**, also known as the **rule of three**.
19
+
20
+ ---
21
+
22
+ ## Installation
23
+
24
+ ```
25
+ pip install prop-cli
26
+ ```
27
+
28
+ This installs the command:
29
+
30
+ ```
31
+ prop-cli
32
+ ```
33
+
34
+ ### Installing from source (local clone)
35
+
36
+ If you clone this repository manually:
37
+
38
+ ```
39
+ git clone https://github.com/Lobko/prop-cli
40
+ cd prop-cli
41
+ ```
42
+
43
+ You can install the package locally with:
44
+
45
+ ```
46
+ pip install .
47
+ ```
48
+
49
+ Or, if you want to install it in development/editable mode:
50
+
51
+ ```
52
+ pip install -e .
53
+ ```
54
+
55
+ This allows you to modify the source code and use the `prop-cli` command immediately without rebuilding the package.
56
+
57
+ ---
58
+
59
+ ## Usage
60
+
61
+ ```
62
+ prop-cli <a> <b> <c> <d>
63
+ ```
64
+
65
+ Example:
66
+
67
+ ```
68
+ prop-cli 10 12 x 30
69
+ ```
70
+
71
+ Output:
72
+
73
+ ```
74
+ Proportion: 10:12 = 25:30
75
+ x = 25
76
+ ```
77
+
78
+ You can place `x` in any position:
79
+
80
+ ```
81
+ prop-cli x 5 6 12
82
+ prop-cli 2 x 4 8
83
+ prop-cli 3 9 x 27
84
+ prop-cli 4 5 0.1 x
85
+ ```
86
+
87
+ ---
88
+
89
+ ## More Examples
90
+
91
+ ```
92
+ prop-cli 5 20 x 120 # x = 30
93
+ prop-cli x 4 12 48 # x = 1
94
+ prop-cli 3 x 9 15 # x = 5
95
+ ```
96
+
97
+ ### Edge cases (real ones)
98
+
99
+ ```
100
+ prop-cli 1 x 0 5 # division by zero (c = 0)
101
+ prop-cli x 0 3 2 # division by zero (b = 0)
102
+ prop-cli 1 2 3 x # valid
103
+ ```
104
+
105
+ ---
106
+
107
+ ## How cross-multiplication works
108
+
109
+ Given the proportion:
110
+
111
+ ```
112
+ a : b = c : d
113
+ ```
114
+
115
+ Rule:
116
+
117
+ ```
118
+ a × d = b × c
119
+ ```
120
+
121
+ ### Diagram (horizontal)
122
+
123
+ ```
124
+ a : b = c : d
125
+ | |
126
+ | |
127
+ +---+---+
128
+ |
129
+ Cross-multiplication
130
+ |
131
+ a × d = b × c
132
+ ```
133
+
134
+ ### Diagram (vertical rule-of-three)
135
+
136
+ ```
137
+ a c
138
+ ─── = ───
139
+ b d
140
+
141
+ Cross multiply:
142
+
143
+ a × d = b × c
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Solving when the unknown is in different positions
149
+
150
+ ### Unknown in second position
151
+
152
+ ```
153
+ a : x = c : d
154
+ a × d = x × c
155
+ x = (a × d) / c
156
+ ```
157
+
158
+ ### Unknown in fourth position
159
+
160
+ ```
161
+ a : b = c : x
162
+ a × x = b × c
163
+ x = (b × c) / a
164
+ ```
165
+
166
+ ---
167
+
168
+ ## Error handling
169
+
170
+ - Exactly one unknown `x` is required
171
+ - Other terms must be numeric
172
+ - Division by zero is detected and reported
173
+ - Scientific notation is avoided in output
174
+
175
+ ---
176
+
177
+ ## Project structure
178
+
179
+ ```
180
+ prop-cli/
181
+ ├── pyproject.toml
182
+ ├── README.md
183
+ ├── LICENSE
184
+ ├── CHANGELOG.md
185
+ ├── VERSION
186
+ ├── tests/
187
+ │ └── test_basic.py
188
+ ├── .github/
189
+ │ └── workflows/
190
+ │ ├── test.yml
191
+ │ ├── lint.yml
192
+ │ └── build.yml
193
+ └── proportion_calculator/
194
+ ├── cli.py
195
+ └── __init__.py
196
+ ```
197
+
198
+ ---
199
+
200
+ ## Contributing
201
+
202
+ 1. Fork the repository
203
+ 2. Create a feature branch
204
+ 3. Commit your changes
205
+ 4. Push the branch
206
+ 5. Open a Pull Request
207
+
208
+ ---
209
+
210
+ ## License
211
+
212
+ MIT License
@@ -0,0 +1,224 @@
1
+ Metadata-Version: 2.4
2
+ Name: prop-cli
3
+ Version: 1.0.2
4
+ Summary: A command-line tool to solve proportions using the rule of three
5
+ Author-email: "Domenico Bruno \"Lobkowitz\"" <blobkowitz@gmail.com>
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: OS Independent
8
+ Requires-Python: >=3.6
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Dynamic: license-file
12
+
13
+ # prop-cli
14
+
15
+ [![PyPI version](https://img.shields.io/pypi/v/prop-cli)](https://pypi.org/project/prop-cli/)
16
+ ![License](https://img.shields.io/badge/license-MIT-blue.svg)
17
+ ![Python Version](https://img.shields.io/pypi/pyversions/prop-cli)
18
+ ![Downloads](https://img.shields.io/pypi/dm/prop-cli)
19
+ ![Tests](https://github.com/Lobko/prop-cli/actions/workflows/test.yml/badge.svg)
20
+ ![Lint](https://github.com/Lobko/prop-cli/actions/workflows/lint.yml/badge.svg)
21
+ ![Build](https://github.com/Lobko/prop-cli/actions/workflows/build.yml/badge.svg)
22
+
23
+ A command-line tool that solves proportions of the form:
24
+
25
+ ```
26
+ a : b = c : d
27
+ ```
28
+
29
+ where one term is unknown (`x`).
30
+ The tool uses classic **cross-multiplication**, also known as the **rule of three**.
31
+
32
+ ---
33
+
34
+ ## Installation
35
+
36
+ ```
37
+ pip install prop-cli
38
+ ```
39
+
40
+ This installs the command:
41
+
42
+ ```
43
+ prop-cli
44
+ ```
45
+
46
+ ### Installing from source (local clone)
47
+
48
+ If you clone this repository manually:
49
+
50
+ ```
51
+ git clone https://github.com/Lobko/prop-cli
52
+ cd prop-cli
53
+ ```
54
+
55
+ You can install the package locally with:
56
+
57
+ ```
58
+ pip install .
59
+ ```
60
+
61
+ Or, if you want to install it in development/editable mode:
62
+
63
+ ```
64
+ pip install -e .
65
+ ```
66
+
67
+ This allows you to modify the source code and use the `prop-cli` command immediately without rebuilding the package.
68
+
69
+ ---
70
+
71
+ ## Usage
72
+
73
+ ```
74
+ prop-cli <a> <b> <c> <d>
75
+ ```
76
+
77
+ Example:
78
+
79
+ ```
80
+ prop-cli 10 12 x 30
81
+ ```
82
+
83
+ Output:
84
+
85
+ ```
86
+ Proportion: 10:12 = 25:30
87
+ x = 25
88
+ ```
89
+
90
+ You can place `x` in any position:
91
+
92
+ ```
93
+ prop-cli x 5 6 12
94
+ prop-cli 2 x 4 8
95
+ prop-cli 3 9 x 27
96
+ prop-cli 4 5 0.1 x
97
+ ```
98
+
99
+ ---
100
+
101
+ ## More Examples
102
+
103
+ ```
104
+ prop-cli 5 20 x 120 # x = 30
105
+ prop-cli x 4 12 48 # x = 1
106
+ prop-cli 3 x 9 15 # x = 5
107
+ ```
108
+
109
+ ### Edge cases (real ones)
110
+
111
+ ```
112
+ prop-cli 1 x 0 5 # division by zero (c = 0)
113
+ prop-cli x 0 3 2 # division by zero (b = 0)
114
+ prop-cli 1 2 3 x # valid
115
+ ```
116
+
117
+ ---
118
+
119
+ ## How cross-multiplication works
120
+
121
+ Given the proportion:
122
+
123
+ ```
124
+ a : b = c : d
125
+ ```
126
+
127
+ Rule:
128
+
129
+ ```
130
+ a × d = b × c
131
+ ```
132
+
133
+ ### Diagram (horizontal)
134
+
135
+ ```
136
+ a : b = c : d
137
+ | |
138
+ | |
139
+ +---+---+
140
+ |
141
+ Cross-multiplication
142
+ |
143
+ a × d = b × c
144
+ ```
145
+
146
+ ### Diagram (vertical rule-of-three)
147
+
148
+ ```
149
+ a c
150
+ ─── = ───
151
+ b d
152
+
153
+ Cross multiply:
154
+
155
+ a × d = b × c
156
+ ```
157
+
158
+ ---
159
+
160
+ ## Solving when the unknown is in different positions
161
+
162
+ ### Unknown in second position
163
+
164
+ ```
165
+ a : x = c : d
166
+ a × d = x × c
167
+ x = (a × d) / c
168
+ ```
169
+
170
+ ### Unknown in fourth position
171
+
172
+ ```
173
+ a : b = c : x
174
+ a × x = b × c
175
+ x = (b × c) / a
176
+ ```
177
+
178
+ ---
179
+
180
+ ## Error handling
181
+
182
+ - Exactly one unknown `x` is required
183
+ - Other terms must be numeric
184
+ - Division by zero is detected and reported
185
+ - Scientific notation is avoided in output
186
+
187
+ ---
188
+
189
+ ## Project structure
190
+
191
+ ```
192
+ prop-cli/
193
+ ├── pyproject.toml
194
+ ├── README.md
195
+ ├── LICENSE
196
+ ├── CHANGELOG.md
197
+ ├── VERSION
198
+ ├── tests/
199
+ │ └── test_basic.py
200
+ ├── .github/
201
+ │ └── workflows/
202
+ │ ├── test.yml
203
+ │ ├── lint.yml
204
+ │ └── build.yml
205
+ └── proportion_calculator/
206
+ ├── cli.py
207
+ └── __init__.py
208
+ ```
209
+
210
+ ---
211
+
212
+ ## Contributing
213
+
214
+ 1. Fork the repository
215
+ 2. Create a feature branch
216
+ 3. Commit your changes
217
+ 4. Push the branch
218
+ 5. Open a Pull Request
219
+
220
+ ---
221
+
222
+ ## License
223
+
224
+ MIT License
@@ -7,4 +7,5 @@ prop_cli.egg-info/dependency_links.txt
7
7
  prop_cli.egg-info/entry_points.txt
8
8
  prop_cli.egg-info/top_level.txt
9
9
  proportion_calculator/__init__.py
10
- proportion_calculator/cli.py
10
+ proportion_calculator/cli.py
11
+ tests/test_basic.py
@@ -1,5 +1,5 @@
1
1
  # ============================================
2
2
  # File: proportion_calculator/__init__.py
3
3
  # ============================================
4
- """Calcolatore di proporzioni."""
5
- __version__ = "1.0.0"
4
+ """Proportion calculator."""
5
+ __version__ = "1.0.2"
@@ -11,19 +11,29 @@ def fmt(value: float) -> str:
11
11
  return s if s != "-0" else "0"
12
12
 
13
13
 
14
- def solve_proportion(a_str: str, b_str: str, c_str: str, d_str: str) -> Optional[float]:
14
+ def solve_proportion(
15
+ a_str: str,
16
+ b_str: str,
17
+ c_str: str,
18
+ d_str: str
19
+ ) -> Optional[float]:
15
20
  """
16
21
  Solves a proportion a:b = c:d given as strings.
17
22
  One of the four values must be 'x'.
18
23
  """
24
+
19
25
  terms = [a_str, b_str, c_str, d_str]
20
26
 
21
27
  # Find position of the unknown 'x'
22
- x_positions = [i for i, term in enumerate(terms) if term.lower() == "x"]
28
+ x_positions = [
29
+ i for i, term in enumerate(terms)
30
+ if term.lower() == "x"
31
+ ]
23
32
 
24
33
  if len(x_positions) == 0:
25
34
  print("Error: No 'x' found. One term must be the unknown.")
26
35
  return None
36
+
27
37
  if len(x_positions) > 1:
28
38
  print("Error: Only one unknown 'x' is allowed.")
29
39
  return None
@@ -32,7 +42,10 @@ def solve_proportion(a_str: str, b_str: str, c_str: str, d_str: str) -> Optional
32
42
 
33
43
  try:
34
44
  # Convert numeric values
35
- a, b, c, d = [None if i == x_pos else float(term) for i, term in enumerate(terms)]
45
+ a, b, c, d = [
46
+ None if i == x_pos else float(term)
47
+ for i, term in enumerate(terms)
48
+ ]
36
49
 
37
50
  # Compute depending on the unknown position
38
51
  if x_pos == 0:
@@ -40,16 +53,19 @@ def solve_proportion(a_str: str, b_str: str, c_str: str, d_str: str) -> Optional
40
53
  print("Error: Division by zero (d = 0).")
41
54
  return None
42
55
  x = (b * c) / d
56
+
43
57
  elif x_pos == 1:
44
58
  if c == 0:
45
59
  print("Error: Division by zero (c = 0).")
46
60
  return None
47
61
  x = (a * d) / c
62
+
48
63
  elif x_pos == 2:
49
64
  if b == 0:
50
65
  print("Error: Division by zero (b = 0).")
51
66
  return None
52
67
  x = (a * d) / b
68
+
53
69
  else: # x_pos == 3
54
70
  if a == 0:
55
71
  print("Error: Division by zero (a = 0).")
@@ -59,7 +75,11 @@ def solve_proportion(a_str: str, b_str: str, c_str: str, d_str: str) -> Optional
59
75
  result = [a, b, c, d]
60
76
  result[x_pos] = x
61
77
 
62
- print(f"Proportion: {fmt(result[0])}:{fmt(result[1])} = {fmt(result[2])}:{fmt(result[3])}")
78
+ print(
79
+ "Proportion: "
80
+ f"{fmt(result[0])}:{fmt(result[1])} = "
81
+ f"{fmt(result[2])}:{fmt(result[3])}"
82
+ )
63
83
  print(f"x = {fmt(x)}")
64
84
 
65
85
  return x
@@ -81,9 +101,15 @@ def main() -> int:
81
101
  print_usage()
82
102
  return 1
83
103
 
84
- result = solve_proportion(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
104
+ result = solve_proportion(
105
+ sys.argv[1],
106
+ sys.argv[2],
107
+ sys.argv[3],
108
+ sys.argv[4]
109
+ )
110
+
85
111
  return 0 if result is not None else 1
86
112
 
87
113
 
88
114
  if __name__ == "__main__":
89
- sys.exit(main())
115
+ sys.exit(main())
@@ -4,8 +4,9 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "prop-cli"
7
- version = "1.0.0"
8
- description = "A simple command-line proportion solver (rule of three)"
7
+ version = "1.0.2"
8
+ description = "A command-line tool to solve proportions using the rule of three"
9
+ readme = "README.md"
9
10
  authors = [
10
11
  { name = "Domenico Bruno \"Lobkowitz\"", email = "blobkowitz@gmail.com" }
11
12
  ]
@@ -0,0 +1,2 @@
1
+ def test_placeholder():
2
+ assert True
prop_cli-1.0.0/PKG-INFO DELETED
@@ -1,10 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: prop-cli
3
- Version: 1.0.0
4
- Summary: A simple command-line proportion solver (rule of three)
5
- Author-email: "Domenico Bruno \"Lobkowitz\"" <blobkowitz@gmail.com>
6
- Classifier: Programming Language :: Python :: 3
7
- Classifier: Operating System :: OS Independent
8
- Requires-Python: >=3.6
9
- License-File: LICENSE
10
- Dynamic: license-file
prop_cli-1.0.0/README.md DELETED
@@ -1,122 +0,0 @@
1
- # prop-cli
2
-
3
- A simple command-line tool that solves proportions of the form:
4
-
5
- a : b = c : d
6
-
7
- where one of the terms is unknown (`x`).
8
- This is the classic **rule of three**, a fundamental arithmetic technique for solving proportions by cross-multiplication.
9
-
10
- ---
11
-
12
- ## Installation
13
-
14
- Clone the repository and install locally:
15
-
16
- pip install .
17
-
18
- This will install the `prop-cli` command.
19
-
20
- ---
21
-
22
- ## Usage
23
-
24
- prop-cli <a> <b> <c> <d>
25
-
26
- Example:
27
-
28
- prop-cli 10 12 x 30
29
-
30
- Output:
31
-
32
- Proportion: 10:12 = 25:30
33
- x = 25
34
-
35
- You can put `x` in any of the four positions:
36
-
37
- prop-cli x 5 6 12
38
- prop-cli 2 x 4 8
39
- prop-cli 3 9 x 27
40
- prop-cli 4 5 0.1 x
41
-
42
- ---
43
-
44
- ## How cross-multiplication works
45
-
46
- To solve a proportion of the form:
47
-
48
- a : b = c : d
49
-
50
- we use **cross-multiplication**, which states that:
51
-
52
- a × d = b × c
53
-
54
- This is the fundamental property of proportions.
55
-
56
- ### Visual ASCII diagram
57
-
58
- a : b = c : d
59
- │ │
60
- │ │
61
- └───┬───┘
62
- │
63
- Cross-multiplication
64
- │
65
- a × d = b × c
66
-
67
- ### Solving for an unknown (example)
68
-
69
- If one term is unknown (`x`), we isolate it using the cross-multiplication identity.
70
-
71
- Case: the unknown is in the second position (`x`):
72
-
73
- a : x = c : d
74
- │ │
75
- │ │
76
- └───┬───┘
77
- │
78
- a × d = x × c
79
- │
80
- └──→ x = (a × d) / c
81
-
82
- Another case: unknown in the fourth position (`x`):
83
-
84
- a : b = c : x
85
- │ │
86
- │ │
87
- └───┬───┘
88
- │
89
- a × x = b × c
90
- │
91
- └──→ x = (b × c) / a
92
-
93
- This tool automatically:
94
- - identifies where the `x` is,
95
- - applies the correct formula,
96
- - prints the solved proportion and the computed value.
97
-
98
- ---
99
-
100
- ## Error handling
101
-
102
- The tool validates:
103
- - only one unknown term (`x`)
104
- - all other terms must be valid numbers
105
- - division by zero is caught with clear error messages
106
-
107
- ---
108
-
109
- ## Project structure
110
-
111
- prop-cli/
112
- ├── pyproject.toml
113
- ├── README.md
114
- └── proportion_calculator/
115
- ├── cli.py
116
- └── __init__.py
117
-
118
- ---
119
-
120
- ## License
121
-
122
- MIT License
@@ -1,10 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: prop-cli
3
- Version: 1.0.0
4
- Summary: A simple command-line proportion solver (rule of three)
5
- Author-email: "Domenico Bruno \"Lobkowitz\"" <blobkowitz@gmail.com>
6
- Classifier: Programming Language :: Python :: 3
7
- Classifier: Operating System :: OS Independent
8
- Requires-Python: >=3.6
9
- License-File: LICENSE
10
- Dynamic: license-file
File without changes
File without changes