Knowee
Questions
Features
Study Tools

Check whether the given two numbers are Anagram or not. Two numbers are said to be as anagram if both numbers formed with same digits.Input Format:Accept two integers from the userOutput Format:Anagram or Not

Question

Check whether the given two numbers are Anagram or not. Two numbers are said to be as anagram if both numbers formed with same digits.Input Format:Accept two integers from the userOutput Format:Anagram or Not

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a step by step guide to check whether two numbers are anagrams or not:

  1. First, take the two numbers as input from the user. Let's say the numbers are num1 and num2.

  2. Convert both numbers to strings. This can be done using the str() function in Python. For example: str_num1 = str(num1) and str_num2 = str(num2).

  3. Sort both strings. This can be done using the sorted() function in Python. For example: sorted_str_num1 = "".join(sorted(str_num1)) and sorted_str_num2 = "".join(sorted(str_num2)).

  4. Finally, compare the sorted strings. If they are equal, then the numbers are anagrams of each other. Otherwise, they are not. This can be done using an if statement in Python. For example:

if sorted_str_num1 == sorted_str_num2:
    print("Anagram")
else:
    print("Not Anagram")

This is a simple way to check if two numbers are anagrams or not. Note that this method assumes that the numbers do not have leading zeros, as leading zeros are usually not considered when determining if two numbers are anagrams.

This problem has been solved

Similar Questions

Write a program to check two strings are anagram or not.

Given 2 strings, check if they are anagrams. An anagram is a rearrangement of the letters of one word to form another word. In other words, some permutations of string A must be the same as string B.Input FormatThe first line of input contains T - the number of test cases. It's followed by T lines, each line containing 2 space-separated strings.Output FormatFor each test case, print True/False, separated by a new line.Constraints10 points1 <= T <= 1001 <= len(S) <= 103'a' <= S[i] <= 'z'40 points1 <= T <= 1001 <= len(S) <= 105'a' <= S[i] <= 'z'ExampleInput4iamlordvoldemort tommarvoloriddleb hstop posthi heyOutputTrueFalseTrueFalse

Create a Python script that will compare two (2) numbers entered by the user. Refer to the attached image and to the following algorithm.

You are to write a function called `isAnagram2` that takes two strings and returns `True` if they are anagrams. You can assume that the strings are made up of lowercase alphabets. `isAnagram2` should not use the `sorted` function.- **Hints/Guide**: - `ord` gives you the numeric representation of a character. `ord('a') = 97`, `ord('b') = 98`, `ord('c') = 99`, ..., `ord('y') = 121`, `ord('z') = 122`. - You can only use concepts we have treated in class so far up to lists. No dictionaries. - You cannot import any library. - You cannot use more than 10 variables in your function.

Given 2 integer input check whether the 2 input are "Equal" or "Not Equal" and print the corresponding message.Input Format:Accept two integers as  inputOutput Format:Print the output as "Equal" or "Not Equal"Constraints:1 <= INPUT <= 10^15

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.