py-simple-wrap 0.1.0__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.
- py_simple_wrap-0.1.0/LICENSE.md +21 -0
- py_simple_wrap-0.1.0/PKG-INFO +192 -0
- py_simple_wrap-0.1.0/README.md +142 -0
- py_simple_wrap-0.1.0/py_simple_package/src/py_simple/__init__.py +32 -0
- py_simple_wrap-0.1.0/py_simple_package/src/py_simple/easy_converter.py +302 -0
- py_simple_wrap-0.1.0/py_simple_package/src/py_simple/easy_date_formatter.py +139 -0
- py_simple_wrap-0.1.0/py_simple_package/src/py_simple/easy_file_manager.py +240 -0
- py_simple_wrap-0.1.0/py_simple_package/src/py_simple/easy_numbers.py +151 -0
- py_simple_wrap-0.1.0/py_simple_package/src/py_simple/easy_strings.py +62 -0
- py_simple_wrap-0.1.0/py_simple_package/src/py_simple/easy_validator.py +139 -0
- py_simple_wrap-0.1.0/py_simple_package/src/py_simple/easy_web.py +39 -0
- py_simple_wrap-0.1.0/py_simple_package/src/py_simple_wrap.egg-info/PKG-INFO +192 -0
- py_simple_wrap-0.1.0/py_simple_package/src/py_simple_wrap.egg-info/SOURCES.txt +28 -0
- py_simple_wrap-0.1.0/py_simple_package/src/py_simple_wrap.egg-info/dependency_links.txt +1 -0
- py_simple_wrap-0.1.0/py_simple_package/src/py_simple_wrap.egg-info/requires.txt +5 -0
- py_simple_wrap-0.1.0/py_simple_package/src/py_simple_wrap.egg-info/top_level.txt +1 -0
- py_simple_wrap-0.1.0/pyproject.toml +53 -0
- py_simple_wrap-0.1.0/setup.cfg +4 -0
- py_simple_wrap-0.1.0/tests/test_converter.py +174 -0
- py_simple_wrap-0.1.0/tests/test_date_formatter.py +169 -0
- py_simple_wrap-0.1.0/tests/test_file_manager.py +254 -0
- py_simple_wrap-0.1.0/tests/test_numbers.py +189 -0
- py_simple_wrap-0.1.0/tests/test_strings.py +67 -0
- py_simple_wrap-0.1.0/tests/test_validator.py +81 -0
- py_simple_wrap-0.1.0/tests/test_web.py +79 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sara Czasak
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: py_simple_wrap
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A package to make complex python functionality simple
|
|
5
|
+
Author-email: Sara Czasak <sara.p.czasak.m@gmail.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Sara Czasak
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
Project-URL: Homepage, https://github.com/sara-czasak/py_simple
|
|
28
|
+
Project-URL: Repository, https://github.com/sara-czasak/py_simple
|
|
29
|
+
Project-URL: Bug Tracker, https://github.com/sara-czasak/py_simple/issues
|
|
30
|
+
Keywords: python,beginner-friendly,wrapper,education
|
|
31
|
+
Classifier: Development Status :: 4 - Beta
|
|
32
|
+
Classifier: Intended Audience :: Developers
|
|
33
|
+
Classifier: Intended Audience :: Education
|
|
34
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
35
|
+
Classifier: Operating System :: OS Independent
|
|
36
|
+
Classifier: Programming Language :: Python :: 3
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
40
|
+
Classifier: Topic :: Education
|
|
41
|
+
Classifier: Topic :: Utilities
|
|
42
|
+
Requires-Python: >=3.10
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
License-File: LICENSE.md
|
|
45
|
+
Requires-Dist: requests>=2.25.0
|
|
46
|
+
Requires-Dist: beautifulsoup4>=4.9.0
|
|
47
|
+
Provides-Extra: test
|
|
48
|
+
Requires-Dist: pytest>=7.0; extra == "test"
|
|
49
|
+
Dynamic: license-file
|
|
50
|
+
|
|
51
|
+
# Py_simple 🚀
|
|
52
|
+
|
|
53
|
+
Making Python feel like plain English.
|
|
54
|
+
|
|
55
|
+
Py_simple is a beginner-friendly Python wrapper package designed to help beginners and developers perform common tasks using simple, intuitive functions.
|
|
56
|
+
|
|
57
|
+
The goal of this project is to remove the need for memorizing complex syntax or writing repetitive boilerplate code, making Python more accessible and enjoyable for everyone.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 🛠️ Module Menu
|
|
62
|
+
|
|
63
|
+
Py_simple provides simple modules designed to make common Python tasks easier.
|
|
64
|
+
|
|
65
|
+
### 📂 Easy File Manager
|
|
66
|
+
|
|
67
|
+
Simplify everyday file operations with beginner-friendly utilities.
|
|
68
|
+
|
|
69
|
+
Features include:
|
|
70
|
+
|
|
71
|
+
- File management helpers
|
|
72
|
+
- Easier file operations
|
|
73
|
+
- Cleaner Python workflows
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
### 🕰️ Easy Date Formatter
|
|
78
|
+
|
|
79
|
+
Make working with dates simpler and more readable.
|
|
80
|
+
|
|
81
|
+
Features include:
|
|
82
|
+
|
|
83
|
+
- Date formatting utilities
|
|
84
|
+
- Easier date manipulation
|
|
85
|
+
- Simple date-related functions
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### 🔢 Easy Numbers
|
|
90
|
+
|
|
91
|
+
Perform common number operations using simple and readable functions.
|
|
92
|
+
|
|
93
|
+
Features include:
|
|
94
|
+
|
|
95
|
+
- Number utilities
|
|
96
|
+
- Beginner-friendly calculations
|
|
97
|
+
- Cleaner mathematical operations
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
### 🔤 Easy Strings
|
|
101
|
+
|
|
102
|
+
Handle common string operations using clear, beginner-friendly functions.
|
|
103
|
+
|
|
104
|
+
Features include:
|
|
105
|
+
|
|
106
|
+
- Removing repeated spaces
|
|
107
|
+
- Converting text to `snake_case`
|
|
108
|
+
- Converting text to `kebab-case`
|
|
109
|
+
- Checking whether text is a palindrome
|
|
110
|
+
|
|
111
|
+
### 🔄 Easy Converter
|
|
112
|
+
|
|
113
|
+
Convert values easily using simple utility functions.
|
|
114
|
+
|
|
115
|
+
Features include:
|
|
116
|
+
|
|
117
|
+
- Simple conversions
|
|
118
|
+
- Easy-to-use helpers
|
|
119
|
+
- Less repetitive code
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
### ✅ Easy Validator
|
|
124
|
+
|
|
125
|
+
Validate common input formats using simple, readable functions.
|
|
126
|
+
|
|
127
|
+
Features include:
|
|
128
|
+
|
|
129
|
+
- Email, username, and URL validation
|
|
130
|
+
- US zip code validation
|
|
131
|
+
- Password strength validation
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### 🌐 Easy Web
|
|
136
|
+
[Easy Web Documentation](docs/easy_web.md)
|
|
137
|
+
|
|
138
|
+
Make getting data from the web less complex.
|
|
139
|
+
|
|
140
|
+
Features include:
|
|
141
|
+
|
|
142
|
+
- Checking if website is up
|
|
143
|
+
- Getting page content
|
|
144
|
+
|
|
145
|
+
More examples and documentation will be added as the project grows.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## 🤝 Contributing
|
|
150
|
+
|
|
151
|
+
I would love to have your help in making Python simpler for everyone!
|
|
152
|
+
|
|
153
|
+
Contributions of all sizes are welcome:
|
|
154
|
+
|
|
155
|
+
- Fix documentation
|
|
156
|
+
- Improve existing modules
|
|
157
|
+
- Suggest new features
|
|
158
|
+
- Add new functionality
|
|
159
|
+
- Improve examples
|
|
160
|
+
|
|
161
|
+
Please check [CONTRIBUTING.md](CONTRIBUTING.md) before submitting changes.
|
|
162
|
+
|
|
163
|
+
Every contribution helps make Py_simple better for beginners and developers.
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 🌟 Hall of Fame
|
|
168
|
+
|
|
169
|
+
A huge thank you to the wonderful people who have helped build Py_simple:
|
|
170
|
+
|
|
171
|
+
- **Sara Czasak** (Creator)
|
|
172
|
+
- **ghostfix-pm** (Major features & Refactoring)
|
|
173
|
+
- **jagjitkaur0000** (Added tests for easy_numbers module)
|
|
174
|
+
- **Onion0121** (Improved documentation)
|
|
175
|
+
- **averyquinnhq** (Added tests for easy_converter.py)
|
|
176
|
+
- **gaoharimran29-glitch** (Added tests for easy_validator.py)
|
|
177
|
+
- **mmaxjr** (Improved documentation)
|
|
178
|
+
- **sol4nki** (Expanded easy_converter.py module)
|
|
179
|
+
- **shivams786** (Added easy_strings.py)
|
|
180
|
+
- **HeaTTap** (Added tests for easy_web module)
|
|
181
|
+
|
|
182
|
+
See the full list of contributions in [CONTRIBUTORS.md](CONTRIBUTORS.md).
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## ⚖️ License
|
|
187
|
+
|
|
188
|
+
This project is licensed under the MIT License.
|
|
189
|
+
|
|
190
|
+
You are free to use, modify, and distribute it.
|
|
191
|
+
|
|
192
|
+
See the [LICENSE.md](LICENSE.md) file for the full legal text.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Py_simple 🚀
|
|
2
|
+
|
|
3
|
+
Making Python feel like plain English.
|
|
4
|
+
|
|
5
|
+
Py_simple is a beginner-friendly Python wrapper package designed to help beginners and developers perform common tasks using simple, intuitive functions.
|
|
6
|
+
|
|
7
|
+
The goal of this project is to remove the need for memorizing complex syntax or writing repetitive boilerplate code, making Python more accessible and enjoyable for everyone.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 🛠️ Module Menu
|
|
12
|
+
|
|
13
|
+
Py_simple provides simple modules designed to make common Python tasks easier.
|
|
14
|
+
|
|
15
|
+
### 📂 Easy File Manager
|
|
16
|
+
|
|
17
|
+
Simplify everyday file operations with beginner-friendly utilities.
|
|
18
|
+
|
|
19
|
+
Features include:
|
|
20
|
+
|
|
21
|
+
- File management helpers
|
|
22
|
+
- Easier file operations
|
|
23
|
+
- Cleaner Python workflows
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
### 🕰️ Easy Date Formatter
|
|
28
|
+
|
|
29
|
+
Make working with dates simpler and more readable.
|
|
30
|
+
|
|
31
|
+
Features include:
|
|
32
|
+
|
|
33
|
+
- Date formatting utilities
|
|
34
|
+
- Easier date manipulation
|
|
35
|
+
- Simple date-related functions
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
### 🔢 Easy Numbers
|
|
40
|
+
|
|
41
|
+
Perform common number operations using simple and readable functions.
|
|
42
|
+
|
|
43
|
+
Features include:
|
|
44
|
+
|
|
45
|
+
- Number utilities
|
|
46
|
+
- Beginner-friendly calculations
|
|
47
|
+
- Cleaner mathematical operations
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
### 🔤 Easy Strings
|
|
51
|
+
|
|
52
|
+
Handle common string operations using clear, beginner-friendly functions.
|
|
53
|
+
|
|
54
|
+
Features include:
|
|
55
|
+
|
|
56
|
+
- Removing repeated spaces
|
|
57
|
+
- Converting text to `snake_case`
|
|
58
|
+
- Converting text to `kebab-case`
|
|
59
|
+
- Checking whether text is a palindrome
|
|
60
|
+
|
|
61
|
+
### 🔄 Easy Converter
|
|
62
|
+
|
|
63
|
+
Convert values easily using simple utility functions.
|
|
64
|
+
|
|
65
|
+
Features include:
|
|
66
|
+
|
|
67
|
+
- Simple conversions
|
|
68
|
+
- Easy-to-use helpers
|
|
69
|
+
- Less repetitive code
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
### ✅ Easy Validator
|
|
74
|
+
|
|
75
|
+
Validate common input formats using simple, readable functions.
|
|
76
|
+
|
|
77
|
+
Features include:
|
|
78
|
+
|
|
79
|
+
- Email, username, and URL validation
|
|
80
|
+
- US zip code validation
|
|
81
|
+
- Password strength validation
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
### 🌐 Easy Web
|
|
86
|
+
[Easy Web Documentation](docs/easy_web.md)
|
|
87
|
+
|
|
88
|
+
Make getting data from the web less complex.
|
|
89
|
+
|
|
90
|
+
Features include:
|
|
91
|
+
|
|
92
|
+
- Checking if website is up
|
|
93
|
+
- Getting page content
|
|
94
|
+
|
|
95
|
+
More examples and documentation will be added as the project grows.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 🤝 Contributing
|
|
100
|
+
|
|
101
|
+
I would love to have your help in making Python simpler for everyone!
|
|
102
|
+
|
|
103
|
+
Contributions of all sizes are welcome:
|
|
104
|
+
|
|
105
|
+
- Fix documentation
|
|
106
|
+
- Improve existing modules
|
|
107
|
+
- Suggest new features
|
|
108
|
+
- Add new functionality
|
|
109
|
+
- Improve examples
|
|
110
|
+
|
|
111
|
+
Please check [CONTRIBUTING.md](CONTRIBUTING.md) before submitting changes.
|
|
112
|
+
|
|
113
|
+
Every contribution helps make Py_simple better for beginners and developers.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 🌟 Hall of Fame
|
|
118
|
+
|
|
119
|
+
A huge thank you to the wonderful people who have helped build Py_simple:
|
|
120
|
+
|
|
121
|
+
- **Sara Czasak** (Creator)
|
|
122
|
+
- **ghostfix-pm** (Major features & Refactoring)
|
|
123
|
+
- **jagjitkaur0000** (Added tests for easy_numbers module)
|
|
124
|
+
- **Onion0121** (Improved documentation)
|
|
125
|
+
- **averyquinnhq** (Added tests for easy_converter.py)
|
|
126
|
+
- **gaoharimran29-glitch** (Added tests for easy_validator.py)
|
|
127
|
+
- **mmaxjr** (Improved documentation)
|
|
128
|
+
- **sol4nki** (Expanded easy_converter.py module)
|
|
129
|
+
- **shivams786** (Added easy_strings.py)
|
|
130
|
+
- **HeaTTap** (Added tests for easy_web module)
|
|
131
|
+
|
|
132
|
+
See the full list of contributions in [CONTRIBUTORS.md](CONTRIBUTORS.md).
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## ⚖️ License
|
|
137
|
+
|
|
138
|
+
This project is licensed under the MIT License.
|
|
139
|
+
|
|
140
|
+
You are free to use, modify, and distribute it.
|
|
141
|
+
|
|
142
|
+
See the [LICENSE.md](LICENSE.md) file for the full legal text.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from .easy_file_manager import (
|
|
2
|
+
make_blank_file, is_file_there, add_a_line, read_file_to_list,
|
|
3
|
+
remove_file, rename_file, list_files, copy_file,
|
|
4
|
+
)
|
|
5
|
+
from .easy_date_formatter import (
|
|
6
|
+
get_pretty_date, get_past_pretty_date, get_future_pretty_date,
|
|
7
|
+
dd_mm_yyyy, past_dd_mm_yyyy, future_dd_mm_yyyy,
|
|
8
|
+
mm_dd_yyyy, past_mm_dd_yyyy, future_mm_dd_yyyy,
|
|
9
|
+
slash_dd_mm_yyyy, past_slash_dd_mm_yyyy, future_slash_dd_mm_yyyy,
|
|
10
|
+
slash_mm_dd_yyyy, past_slash_mm_dd_yyyy, future_slash_mm_dd_yyyy,
|
|
11
|
+
list_available_formats,
|
|
12
|
+
)
|
|
13
|
+
from .easy_converter import (
|
|
14
|
+
seconds_to_hh_mm_ss, miles_to_km, km_to_mile, fluid_oz_to_ml,
|
|
15
|
+
ml_to_fluid_oz, celsius_to_fahrenheit, fahrenheit_to_celsius, kg_to_lb,
|
|
16
|
+
lb_to_kg, meters_to_feet, feet_to_meters, cm_to_inches, inches_to_cm,
|
|
17
|
+
sq_feet_to_sq_meters, sq_meters_to_sq_feet
|
|
18
|
+
)
|
|
19
|
+
from .easy_numbers import (
|
|
20
|
+
is_even, is_odd, is_evenly_divisible, is_negative, is_positive,
|
|
21
|
+
average, is_prime, percentage_of
|
|
22
|
+
)
|
|
23
|
+
from .easy_validator import (
|
|
24
|
+
is_valid_email, is_valid_username, is_valid_zipcode, is_valid_url,
|
|
25
|
+
is_password_secure,
|
|
26
|
+
)
|
|
27
|
+
from .easy_web import (
|
|
28
|
+
get_page_content, is_page_up,
|
|
29
|
+
)
|
|
30
|
+
from .easy_strings import (
|
|
31
|
+
is_palindrome, remove_extra_spaces, to_kebab_case, to_snake_case,
|
|
32
|
+
)
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
"""
|
|
2
|
+
easy_converter is built to simplify different types of conversions
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from datetime import timedelta
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def seconds_to_hh_mm_ss(seconds: int) -> str:
|
|
9
|
+
"""
|
|
10
|
+
Returns seconds in HH:MM:SS format.
|
|
11
|
+
|
|
12
|
+
Arguments:
|
|
13
|
+
seconds (int) -- number of seconds to convert
|
|
14
|
+
|
|
15
|
+
Example:
|
|
16
|
+
seconds_to_hh_mm_ss(90)
|
|
17
|
+
(00:01:30)
|
|
18
|
+
"""
|
|
19
|
+
return str(timedelta(seconds=seconds))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def hh_mm_ss_to_seconds(hours: int = 0, minutes: int = 0, seconds: int = 0) \
|
|
23
|
+
-> int:
|
|
24
|
+
"""
|
|
25
|
+
Returns hours, minutes and seconds converted to seconds.
|
|
26
|
+
|
|
27
|
+
Arguments:
|
|
28
|
+
hours (int) -- number of hours to convert. Defaults to 0.
|
|
29
|
+
minutes (int) -- number of minutes to convert. Defaults to 0.
|
|
30
|
+
seconds (int) -- number of seconds to convert. Defaults to 0.
|
|
31
|
+
|
|
32
|
+
Example:
|
|
33
|
+
hh_mm_ss_to_seconds(1, 1, 1)
|
|
34
|
+
(3661)
|
|
35
|
+
"""
|
|
36
|
+
total_seconds = seconds
|
|
37
|
+
total_seconds += hours * 3600
|
|
38
|
+
total_seconds += minutes * 60
|
|
39
|
+
return total_seconds
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def km_to_mile(km: float) -> float:
|
|
43
|
+
"""
|
|
44
|
+
Converts kilometers to miles. Returns miles as a float.
|
|
45
|
+
|
|
46
|
+
Arguments:
|
|
47
|
+
km (float) -- kilometers
|
|
48
|
+
|
|
49
|
+
Example:
|
|
50
|
+
km_to_mile(100)
|
|
51
|
+
(62.13)
|
|
52
|
+
"""
|
|
53
|
+
return float(f"{km * 0.621371:.2f}")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def miles_to_km(miles: float) -> float:
|
|
57
|
+
"""
|
|
58
|
+
Converts miles to kilometers. Returns kilometers as a float.
|
|
59
|
+
|
|
60
|
+
Arguments:
|
|
61
|
+
miles (float) -- miles
|
|
62
|
+
|
|
63
|
+
Example:
|
|
64
|
+
miles_to_km(100)
|
|
65
|
+
(160.93)
|
|
66
|
+
"""
|
|
67
|
+
return float(f"{miles * 1.60934:.2f}")
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def fluid_oz_to_ml(oz: float, standard = 'us') -> float | None:
|
|
71
|
+
"""
|
|
72
|
+
Converts fluid ounces to milliliters. Returns milliliters as a float.
|
|
73
|
+
|
|
74
|
+
:param:
|
|
75
|
+
oz (float) -- fluid ounces
|
|
76
|
+
standard -- us or uk
|
|
77
|
+
|
|
78
|
+
Example:
|
|
79
|
+
standard = 'us'
|
|
80
|
+
fluid_oz_to_ml(1)
|
|
81
|
+
(29.6)
|
|
82
|
+
standard = 'uk'
|
|
83
|
+
fluid_oz_to_ml(1)
|
|
84
|
+
(28.4)
|
|
85
|
+
|
|
86
|
+
"""
|
|
87
|
+
match standard:
|
|
88
|
+
case "uk":
|
|
89
|
+
return float(f"{oz * 28.4:.2f}")
|
|
90
|
+
case "us":
|
|
91
|
+
return float(f"{oz * 29.6:.2f}")
|
|
92
|
+
return None
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def ml_to_fluid_oz(milliliters: float, standard = 'us') -> float | None:
|
|
96
|
+
"""
|
|
97
|
+
Converts milliliters to fluid ounces. Returns fluid ounces as a
|
|
98
|
+
float.
|
|
99
|
+
|
|
100
|
+
:param:
|
|
101
|
+
milliliters (float) -- milliliters
|
|
102
|
+
standard -- us or uk
|
|
103
|
+
|
|
104
|
+
Example:
|
|
105
|
+
standard = 'us'
|
|
106
|
+
ml_to_fluid_oz(1)
|
|
107
|
+
(0.03)
|
|
108
|
+
standard = 'uk'
|
|
109
|
+
ml_to_fluid_oz(1)
|
|
110
|
+
(0.04)
|
|
111
|
+
|
|
112
|
+
"""
|
|
113
|
+
match standard:
|
|
114
|
+
case "uk":
|
|
115
|
+
return float(f"{milliliters * 0.035:.2f}")
|
|
116
|
+
case "us":
|
|
117
|
+
return float(f"{milliliters * 0.034:.2f}")
|
|
118
|
+
return None
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def celsius_to_fahrenheit(temp_celsius: float) -> float:
|
|
122
|
+
"""
|
|
123
|
+
Converts temperature in Celsius to temperature in Fahrenheit.
|
|
124
|
+
Returns degrees Fahrenheit as float.
|
|
125
|
+
|
|
126
|
+
:param:
|
|
127
|
+
temp_celsius (float) -- temperature in Celsius
|
|
128
|
+
|
|
129
|
+
Example:
|
|
130
|
+
celsius_to_fahrenheit(40)
|
|
131
|
+
(104.0)
|
|
132
|
+
|
|
133
|
+
"""
|
|
134
|
+
return float(f"{((temp_celsius * 9 / 5) + 32):.2f}")
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def fahrenheit_to_celsius(temp_fahrenheit: float) -> float:
|
|
138
|
+
"""
|
|
139
|
+
Converts temperature in Fahrenheit to temperature in Celsius.
|
|
140
|
+
Returns degrees Celsius as float.
|
|
141
|
+
|
|
142
|
+
:param:
|
|
143
|
+
temp_fahrenheit (float) -- temperature in Fahrenheit
|
|
144
|
+
|
|
145
|
+
Example:
|
|
146
|
+
fahrenheit_to_celsius(104)
|
|
147
|
+
(40.0)
|
|
148
|
+
"""
|
|
149
|
+
return float(f"{((temp_fahrenheit - 32) * 5 / 9):.2f}")
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def kg_to_lb(kg: float) -> float:
|
|
153
|
+
"""
|
|
154
|
+
Converts kilograms to pounds.
|
|
155
|
+
Returns pounds as float.
|
|
156
|
+
|
|
157
|
+
:param:
|
|
158
|
+
kg (float) -- kilograms
|
|
159
|
+
|
|
160
|
+
Example:
|
|
161
|
+
kg_to_lb(50)
|
|
162
|
+
(110.23)
|
|
163
|
+
"""
|
|
164
|
+
return float(f"{kg * 2.20462:.2f}")
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def lb_to_kg(lb: float) -> float:
|
|
168
|
+
"""
|
|
169
|
+
Converts pounds to kilograms.
|
|
170
|
+
Returns kilograms as float.
|
|
171
|
+
|
|
172
|
+
:param:
|
|
173
|
+
lb (float) -- pounds
|
|
174
|
+
|
|
175
|
+
Example:
|
|
176
|
+
lb_to_kg(110.23)
|
|
177
|
+
(50.0)
|
|
178
|
+
"""
|
|
179
|
+
return float(f"{(lb * 0.453592):.2f}")
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def meters_to_feet(meters: float) -> float:
|
|
183
|
+
"""
|
|
184
|
+
Converts meters to feet.
|
|
185
|
+
Returns feet as float.
|
|
186
|
+
|
|
187
|
+
Arguments:
|
|
188
|
+
meters (float) -- meters to be converted to feet.
|
|
189
|
+
|
|
190
|
+
Example:
|
|
191
|
+
meters_to_feet(100)
|
|
192
|
+
(328.08)
|
|
193
|
+
"""
|
|
194
|
+
return float(f"{(meters * 3.28084):.2f}")
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def feet_to_meters(feet: float) -> float:
|
|
198
|
+
"""
|
|
199
|
+
Converts feet to meters.
|
|
200
|
+
Returns meters as float.
|
|
201
|
+
|
|
202
|
+
Arguments:
|
|
203
|
+
feet (float) -- feet to be converted to meters.
|
|
204
|
+
|
|
205
|
+
Example:
|
|
206
|
+
feet_to_meters(328.08)
|
|
207
|
+
(100.0)
|
|
208
|
+
"""
|
|
209
|
+
return float(f"{(feet * 0.3048):.2f}")
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def cm_to_inches(cm: float) -> float:
|
|
213
|
+
"""
|
|
214
|
+
Converts centimeters to inches.
|
|
215
|
+
Returns inches as float.
|
|
216
|
+
|
|
217
|
+
Arguments:
|
|
218
|
+
cm (float) -- centimeters to be converted to inches.
|
|
219
|
+
|
|
220
|
+
Example:
|
|
221
|
+
cm_to_inches(100)
|
|
222
|
+
(39.37)
|
|
223
|
+
"""
|
|
224
|
+
return float(f"{(cm / 2.54):.2f}")
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def inches_to_cm(inches: float) -> float:
|
|
228
|
+
"""
|
|
229
|
+
Converts centimeters to inches.
|
|
230
|
+
Returns inches as float.
|
|
231
|
+
|
|
232
|
+
Arguments:
|
|
233
|
+
inches (float) -- inches to be converted to centimeters.
|
|
234
|
+
|
|
235
|
+
Example:
|
|
236
|
+
inches_to_cm(39.37)
|
|
237
|
+
(100.0)
|
|
238
|
+
"""
|
|
239
|
+
return float(f"{(inches * 2.54):.2f}")
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def sq_meters_to_sq_feet(sq_meters: float) -> float:
|
|
243
|
+
"""
|
|
244
|
+
Converts square meters to square feet.
|
|
245
|
+
Returns square feet as float.
|
|
246
|
+
|
|
247
|
+
Arguments:
|
|
248
|
+
sq_meters (float) -- square meters to be converted to
|
|
249
|
+
square feet.
|
|
250
|
+
|
|
251
|
+
Example:
|
|
252
|
+
sq_meters_to_sq_feet(10)
|
|
253
|
+
(107.64)
|
|
254
|
+
"""
|
|
255
|
+
return float(f"{(sq_meters * 10.7639):.2f}")
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def sq_feet_to_sq_meters(sq_feet: float) -> float:
|
|
259
|
+
"""
|
|
260
|
+
Converts square feet to square meters.
|
|
261
|
+
Returns square meters as float.
|
|
262
|
+
|
|
263
|
+
Arguments:
|
|
264
|
+
sq_feet (float) -- square feet to be converted to
|
|
265
|
+
square meters.
|
|
266
|
+
|
|
267
|
+
Example:
|
|
268
|
+
sq_feet_to_sq_meters(107.64)
|
|
269
|
+
(10.0)
|
|
270
|
+
"""
|
|
271
|
+
return float(f"{(sq_feet * 0.092903):.2f}")
|
|
272
|
+
|
|
273
|
+
def mph_to_kph(mph):
|
|
274
|
+
"""
|
|
275
|
+
Converts mph speed to kph speed.
|
|
276
|
+
Returns kph speed as float.
|
|
277
|
+
|
|
278
|
+
Arguments:
|
|
279
|
+
mph (float) -- mph speed to be converted to
|
|
280
|
+
kph speed.
|
|
281
|
+
|
|
282
|
+
Example:
|
|
283
|
+
mph_to_kph(0.621371)
|
|
284
|
+
(1.0)
|
|
285
|
+
"""
|
|
286
|
+
return float(f"{(mph * 1.60934):.2f}")
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def kph_to_mph(kph):
|
|
290
|
+
"""
|
|
291
|
+
Converts kph speed to mph speed.
|
|
292
|
+
Returns mph speed as float.
|
|
293
|
+
|
|
294
|
+
Arguments:
|
|
295
|
+
kph (float) -- kph speed to be converted to
|
|
296
|
+
kph speed.
|
|
297
|
+
|
|
298
|
+
Example:
|
|
299
|
+
kph_to_mph(1.60934)
|
|
300
|
+
(1.0)
|
|
301
|
+
"""
|
|
302
|
+
return float(f"{(kph * 0.621371):.2f}")
|