Reverse order commands / upper / switch [closed]

-4

I'm doing a job (Python 3) and I need help completing the codes.

  • I need to know how to reverse the order, for example 2345 in and out of 5432.

  • I also need to know how I leave only one uppercase letter and the smallest case, such as: stackoverflow?

  • And finally I need to know how I change x by y and vice versa. For example: y = 23x^2 - 2x + 1 (input) and x = 23y^2 - 2y + 1 (output).

Thank you in advance.

    
asked by anonymous 22.08.2018 / 22:17

1 answer

-1

Invert number (in a function):

def reverse_number(n):
  r = 0
  while n > 0:
    r *= 10
    r += n % 10
    n /= 10
  return r

Leave a capital letter:

u"stackoverflow".title()

Replace x with y and vice versa:

"y = 23x^2 - 2x + 1".upper().replace("X", "y").replace("Y","x")

All lowercase letters except the letter a:

"NAISNDFOAISOASID".lower().replace("a","A")
    
23.08.2018 / 01:39