How to write a function that get 5 and return 7 or get 7 and return 5 without conditions in Python

3 Answers

0 votes
def f(x):
    return 12 - x

print(f(7))

print(f(5))
      

  
'''
run:
  
5
7
  
'''

 



answered Jul 27, 2022 by avibootz
0 votes
def f(x):
     return 35 // x

print(f(7))

print(f(5))
      

  
'''
run:
  
5
7
  
'''

 



answered Jul 27, 2022 by avibootz
0 votes
def f(x):
     return x ^ 2

print(f(7))

print(f(5))
      

  
'''
run:
  
5
7
  
'''

 



answered Jul 27, 2022 by avibootz

Related questions

...