1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
harkovskaia [24]
3 years ago
13

Write a function that checks whether two words are anagrams. Two words are anagrams if they contain the same letters. For exampl

e, silent and listen are anagrams. The header of the function is:
def isAnagram(s1, s2):

(Hint: Obtain two lists for the two strings. Sort the lists and check if two lists are identical.)

Write a test program that prompts the user to enter two strings and checks whether they are anagrams.

Sample Run 1

Enter a string s1: silent

Enter a string s2: listen

silent and listen are anagrams

Sample Run 2

Enter a string s1: split

Enter a string s2: lisp

split and lisp are not anagrams

Computers and Technology
1 answer:
Masteriza [31]3 years ago
4 0

Answer:

def isAnagram(s1, s2):

   list1=s1

   list2=s2

   sortedlist1 = sorted(list1)

   sortedlist2 = sorted(list2)

   if sortedlist1 == sortedlist2:

       print(list1+ " and "+list2+ " are anagram")

   else:

       print(list1+ " and "+list2+ " are not anagram")

Explanation:

Here is a call to the function isAnagram():

list1 =input("Enter String1 ")

list1 =input("Enter String2 ")

isAnagram(list1,list2)

Attached is the run and output for this program

You might be interested in
Write a program that asks the user to enter a series of numbers separated by commas. Here is an example of valid input: 7,9,10,2
alex41 [277]

Answer:

Here is the JAVA program. Let me know if you need the program in some other programming language.

import java.util.Scanner; // used for taking input from user

public class Main{ //Main class

public static void main(String[] args) {//start of main() function body

  Scanner scan = new Scanner(System.in); // creates a Scanner type object

   String input; // stores input series

    int sum = 0; //stores the sum of the series

    System.out.println("Enter a series of numbers separated by commas: "); //prompts user to enter a series of numbers separated by comma

     input = scan.nextLine(); //reads entire input series

     String[] numbers = input.split("[, ]"); //breaks the input series based on delimiter i.e. comma and stores the split sub strings (numbers) into the numbers array

   for (int i = 0; i < numbers.length; i++) { //loops through each element of numbers array until the length of the numbers reaches

          sum += Integer.parseInt(numbers[i]); } // parses the each String element of numbers array as a signed decimal integer object and takes the sum of all the integer objects

     System.out.println("Sum of all the numbers: " + sum);  } } //displays the sum of all the numbers

Explanation:

The program prompts the user to enter a series separated by commas.

Then split() method is used to split or break the series of numbers which are in String form, into sub strings based on comma (,) . This means the series is split into separate numbers. These are stored in numbers[] array.

Next the for loop iterate through each sub string i.e. each number of the series, converts each String type decimal number to integer using Integer.parseInt and computes the sum of all these integers. The last print statement displays the sum of all numbers in series.  

If the input is 7,9,10,2,18,6

Then the output is: 7+9+10+2+18+6

sum = 52

The program and its output is attached.

8 0
3 years ago
12. What was the trade Howard offered to Death?​
Pachacha [2.7K]

Answer:

His life

Explanation:

5 0
2 years ago
HOW CAN A PERSON GET BENEFITTED BY THE ICT BASEDSERVICES PROVIDED BY GOVERNMENT
BARSIC [14]

Answer:

Explanation:

It aims to transform the entire ecosystem of public services through the use of information technology.ICT holds particular promise in areas of governance and public participation.  Age can use information to reduce corruption and increase government transparency, accountability, efficiency and so finally gud night guys and take care.

plz mark as brainliest

5 0
3 years ago
WILL GIVE BRAINLIES!!!The command simplify is used if you only want the first two digits of a decimal to appear in the interpret
Marina CMI [18]

Answer:

hai i here

Explanation:

twue

3 0
3 years ago
How do a Tip Calculator in Visual Studios?
luda_lava [24]
Sorry but I don’t know?
7 0
3 years ago
Other questions:
  • Jessie has received a contract to build a real-time application for a baker. However, the baker doesn't want to invest too much
    11·2 answers
  • Which type of cause and effect organizer would be best for alisha to understand how crude oil becomes gasoline?
    6·2 answers
  • A voltage measurement error is caused by the integration time window of a digital volt-meter. This is a _____________error.
    7·1 answer
  • In these weeks readings, we learned about the CIA Triad and how each exhibits dependence on the other. Give examples of how fail
    12·1 answer
  • Not everything is a success all of the time! So do you know which version of Windows was the least popular?
    7·1 answer
  • Which questions should you ask yourself when performing research online?
    9·1 answer
  • Hard and soft skills can both be transferable skills. *<br><br> True<br><br> False
    5·2 answers
  • What is the relationship between agile teams and project requirements
    9·1 answer
  • A cookie is.... a. an illegal use of information about a customer b. a feature of a Web site designed to attract children c. a f
    15·1 answer
  • Ginny faced an application error while executing the recorder in opera. Which web browser is generally recommended to use with r
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!