Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ashishantil07/codingbuiltins.py
Coding some built-in functions in Python.
https://github.com/ashishantil07/codingbuiltins.py
Last synced: about 1 month ago
JSON representation
Coding some built-in functions in Python.
- Host: GitHub
- URL: https://github.com/ashishantil07/codingbuiltins.py
- Owner: AshishAntil07
- License: mit
- Created: 2022-05-01T14:04:42.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-15T06:47:11.000Z (over 2 years ago)
- Last Synced: 2023-03-09T08:46:04.659Z (almost 2 years ago)
- Language: Python
- Size: 21.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Coding Built-in Functions
Coding some built-in functions in Python.
Here, you will get reduce function, replace function, format method(as a function), and many more!
## How to use :
### Replace function
```python
MyString = 'They are fighting in the table in the floor.'
MyString = replace(MyString, 'in', 'on') # 4th parameter will state whether all matches will be replaced or not, by default it is true.
print(MyString)'''
Output:
They are fighting on the table on the floor.
'''
```### Format function
```python
MyString = 'They are {1} on the {0} on the {2}.'
MyString = format(MyString, 'table', 'fighting', 'floor')
# OR
# MyString = format(MyString, ['table', 'fighting', 'floor'])
print(MyString)'''
Output:
They are fighting on the table on the floor.
'''
```### Reduce function
```python
l = [1, 2, 3, 4, 5]
def function(num1, num2):
return num1+num2[0]+num2[1]val = reduce(function, l, 3) # the third argument will state the length of group of elements you want, by default it is 2.
print(val) # if the length is greater than 2, then it will pass the 2nd argument as a list.'''
Output:
22
'''
```### List Flatter
```python
multiDimensional = [
'al;edg',
[289, [420, '29803age4', [2893]], 'glj'],
[2893, ['gj;la', ['28934'], 6903], 90],
2384,
[28347, [58023, [32409783, 532489, [50923, [258709], 198], 59], 7], 20, 59]
]print(multiDimensional)
print(flat(multiDimensional))'''
Output:['al;edg', [289, [420, '29803age4', [2893]], 'glj'], [2893, ['gj;la', ['28934'], 6903], 90], 2384, [28347, [58023, [32409783, 532489, [50923, [258709], 198], 59], 7], 20, 59]]
['al;edg', 289, 420, '29803age4', 2893, 'glj', 2893, 'gj;la', '28934', 6903, 90, 2384, 28347, 58023, 32409783, 532489,
50923, 258709, 198, 59, 7, 20, 59]
'''
```## License :
This repository is licensed under [MIT License](https://github.com/AshishAntil07/CodingBuiltins.py/blob/main/LICENSE)