Close
Close

How do I swap two numbers and two digits.

   heavycodes , DPS

How can I make one python program in which I will enter two numbers one by one they will tell me the entered number and the swapped number.

Example – if entered 23, then it will show The entered number is 23, The swapped number is 32, then if i enter 32 it will show me 23.

I have two numbers to input.

The count of variables should not be 3 or exceeding 3.

  • Please Tell.
    - heavycodes
  • x=int(input("Enter the number)) first_digit=x//10 second_digit=x%10 swapped_number=(second_digit*10)+first_digit print(swapped_number)
    - tanyatyagi01
  • in this way you will get your answers. try the numbers in the code
    - tanyatyagi01

Answers

  •   

    x=int(input("Enter the number))

    first_digit=x//10

    second_digit=x%10

    swapped_number=(second_digit*10)+first_digit

    print(swapped_number)



  •    Prutuja

    It is a well-known cloud computing firm that offers CRM as its primary area of expertise and operates on the Software as a Service (SaaS) model (Customer Relationship Management). To put it another way, it is an integrated CRM platform that has as its primary goal the provision of all of your work divisions with a single as well as a shared and comprehensive perspective of each individual client.

    Visit: Salesforce Training in Pune    



  •    dylancazaly

    America has been home to some of the most famous criminals in history. The most infamous is Charles Manson, who inspired his followers to commit the murders of pregnant actress Sharon Tate and he's offering to visit this webpage to gather more info. Another example would be Al Capone, who became one of America's most notorious gangsters in Chicago during the Prohibition era.



  •    Yarainlus

    I usually watch them to learn more, then play stumble guys for fun; it's a good knockout game. question the scholastic aptitude of young males



  •    seoexpertim

    Well, to be honest this is an amazing site with updated information. It was very interesting to know about eSignature for HR. I will for sure post a review about the content here.



  •    Borenica

    We appreciate your willingness to provide us with information. We will always be grateful for everything you have done for us since I know how much you love us. Visit my game octordle



  •    halfreading

    If the number is 12, after reversing, it will become 21. As you can see, its digits (first and last) are interchanged dinosaur game.



  •    Lilycolins

    Create two temporary variables to store the values of A and B. For example, you can create variables called temp1 and temp2. Assign the value of A to temp1. This will store the value of A temporarily. temp1 = A Assign the value of B to temp2. This will store the value of B temporarily. temp2 = B Assign the value of temp1 to B. This will swap bitlife the value of A with B. B = temp1 Assign the value of temp2 to A. This will assign the original value of B to A. A = temp2,



  •    Larry Martin

    IBRA Taxi Services ensures smooth transfers between airports. Experience comfortable and timely journeys with their taxi services from Quebec City airport to Montreal airport, allowing you to travel with ease and confidence.



  •    IT Education Centre

    Thanks for the answer. It is quite useful.

    Python Classes in Pune

    Online Python training in Pune



  •    johnmic

     This is a great inspiring article. I am pretty much pleased with your good work. You put really very helpful information. John Dutton Yellowstone Vest John Dutton Yellowstone Vest   



  •    patricajohnson51

    # Take input of two numbers

    num1 = int(input("Enter the first number: "))

    num2 = int(input("Enter the second number: "))

    # Display the entered numbers

    print("The entered number is", num1, "and", num2)

    # Swapping the digits

    num1_swapped = (num1 % 10) * 10 + (num1 // 10)

    num2_swapped = (num2 % 10) * 10 + (num2 // 10)


    # Display the swapped numbers

    print("The swapped number for", num1, "is", num1_swapped)

    print("The swapped number for", num2, "is", num2_swapped) 


    Seeking assistance from online resources can be beneficial. Get the best Python assignment help at ProgrammingHomeworkHelp.com can provide immediate solutions




Ask Yours
Post Yours
Write your answer