mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-12-18 09:10:16 +00:00
README.md: sumab() --> sum_ab() for consistancy (#1855)
* README.md: sumab() --> sum_ab() for consistancy consistency * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
parent
c775baf55f
commit
8bf380ce7d
|
@ -82,7 +82,7 @@ We want your work to be readable by others; therefore, we encourage you to note
|
||||||
```python
|
```python
|
||||||
def sum_ab(a, b):
|
def sum_ab(a, b):
|
||||||
"""
|
"""
|
||||||
Returns the sum of two integers a and b
|
Return the sum of two integers a and b
|
||||||
>>> sum_ab(2, 2)
|
>>> sum_ab(2, 2)
|
||||||
4
|
4
|
||||||
>>> sum_ab(-2, 3)
|
>>> sum_ab(-2, 3)
|
||||||
|
@ -116,8 +116,8 @@ We want your work to be readable by others; therefore, we encourage you to note
|
||||||
The use of [Python type hints](https://docs.python.org/3/library/typing.html) is encouraged for function parameters and return values. Our automated testing will run [mypy](http://mypy-lang.org) so run that locally before making your submission.
|
The use of [Python type hints](https://docs.python.org/3/library/typing.html) is encouraged for function parameters and return values. Our automated testing will run [mypy](http://mypy-lang.org) so run that locally before making your submission.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def sumab(a: int, b: int) --> int:
|
def sum_ab(a: int, b: int) --> int:
|
||||||
pass
|
return a + b
|
||||||
```
|
```
|
||||||
|
|
||||||
- [__List comprehensions and generators__](https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions) are preferred over the use of `lambda`, `map`, `filter`, `reduce` but the important thing is to demonstrate the power of Python in code that is easy to read and maintain.
|
- [__List comprehensions and generators__](https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions) are preferred over the use of `lambda`, `map`, `filter`, `reduce` but the important thing is to demonstrate the power of Python in code that is easy to read and maintain.
|
||||||
|
|
|
@ -8,14 +8,14 @@ class LinkedList:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.head = None
|
self.head = None
|
||||||
|
|
||||||
def push(self, new_data:int) -> int:
|
def push(self, new_data: int) -> int:
|
||||||
new_node = Node(new_data)
|
new_node = Node(new_data)
|
||||||
new_node.next = self.head
|
new_node.next = self.head
|
||||||
self.head = new_node
|
self.head = new_node
|
||||||
return self.head.data
|
return self.head.data
|
||||||
|
|
||||||
def middle_element(self) -> int:
|
def middle_element(self) -> int:
|
||||||
'''
|
"""
|
||||||
>>> link = LinkedList()
|
>>> link = LinkedList()
|
||||||
>>> link.middle_element()
|
>>> link.middle_element()
|
||||||
No element found.
|
No element found.
|
||||||
|
@ -44,7 +44,7 @@ class LinkedList:
|
||||||
>>> link.middle_element()
|
>>> link.middle_element()
|
||||||
12
|
12
|
||||||
>>>
|
>>>
|
||||||
'''
|
"""
|
||||||
slow_pointer = self.head
|
slow_pointer = self.head
|
||||||
fast_pointer = self.head
|
fast_pointer = self.head
|
||||||
if self.head:
|
if self.head:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user