Reverse order commands/upper/ switch

Asked

Viewed 142 times

-4

I am doing a job (Python 3) and need help to complete the codes.

  • I need to know how I 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 rest lowercase, for example: stackoverflow (leave only the letter uppercase)?

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

Thank you in advance.

  • 2

    Hello Mrx, this site is intended to help users to answer their specific questions. Hardly anyone here will give you the ready answer, especially when it comes to a job like you said. Post the code you’ve tried so far and clarify your doubt, you could start by saying if what you’re trying to do is in Javascript or Phyton.

  • In the description you quote Phyton, however mark Javascript as tag.

  • The tag had no Phyton....

  • Another problem, too, even had a question previously addressing the case, how would a code know which "the" of the word "stackoverflow" would be capitalized? It would take a dictionary.

  • 2

    The tag is Python, and not Phyton.

  • 1

    The first thing you need to learn is to type the language name correctly.

  • the exercise asks for all "a" to be capitalized and so far no one helps me

Show 2 more comments

1 answer

-1


Invert number (in one 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 for y and vice versa:

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

All lower case letters except the letter a:

"NAISNDFOAISOASID".lower().replace("a","A")
  • A very crude exercise that I can not solve Make a program that given a word, turn all your letters into lower case letters. Except the letter 'a'. ...

  • The vice versa is not only for the equation is for general, that is, exchange of variables.... follows the exercise: Make a program that given the algebraic expression of a second-degree equation, change x by y and vice versa. The equation will always be arranged in the form: y=ax2+bx+c

  • Avoid asking multiple questions in one, I advise you to ask another question, if the doubt is of a different implementation of this.

  • In the case of the equation just replace the string fixed by its equation (which can be any one)

  • If this question has helped you, don’t forget to mark as right and vote positively :)

  • The forum provides 1 question every 40 minutes and I have 1 hour to solve these 3 exercises. Could you help me?

  • I edited the answer and solved this other 'a' exception, the others are done.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.