Python challenge_14

Up and down

simple challenge

Define a function named up_down that takes a single number
As its parameter.

Your function return a tuple containing two numbers
The first should be one lower than the parameter,
And the second should be on…


This content originally appeared on DEV Community and was authored by Mahmoud EL-kariouny

Up and down

simple challenge

Define a function named up_down that takes a single number
As its parameter.

Your function return a tuple containing two numbers
The first should be one lower than the parameter,
And the second should be one higher.

For example:

calling up_down(5) should return (4, 6)

My Solution

def up_down(number):
    down = number - 1
    up = down + 2
    return (down, up)

Another Solution

def up_down(x):
    return (x-1, x+1)

All the best to you.


This content originally appeared on DEV Community and was authored by Mahmoud EL-kariouny


Print Share Comment Cite Upload Translate Updates
APA

Mahmoud EL-kariouny | Sciencx (2022-01-19T22:47:55+00:00) Python challenge_14. Retrieved from https://www.scien.cx/2022/01/19/python-challenge_14/

MLA
" » Python challenge_14." Mahmoud EL-kariouny | Sciencx - Wednesday January 19, 2022, https://www.scien.cx/2022/01/19/python-challenge_14/
HARVARD
Mahmoud EL-kariouny | Sciencx Wednesday January 19, 2022 » Python challenge_14., viewed ,<https://www.scien.cx/2022/01/19/python-challenge_14/>
VANCOUVER
Mahmoud EL-kariouny | Sciencx - » Python challenge_14. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/01/19/python-challenge_14/
CHICAGO
" » Python challenge_14." Mahmoud EL-kariouny | Sciencx - Accessed . https://www.scien.cx/2022/01/19/python-challenge_14/
IEEE
" » Python challenge_14." Mahmoud EL-kariouny | Sciencx [Online]. Available: https://www.scien.cx/2022/01/19/python-challenge_14/. [Accessed: ]
rf:citation
» Python challenge_14 | Mahmoud EL-kariouny | Sciencx | https://www.scien.cx/2022/01/19/python-challenge_14/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.