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
A personal phone directory contains room for first names and phone numbers for 30 people. Assign names and phone numbers for the
Fynjy0 [20]

Answer:

# include <iostream.h>

# include <stdio.h>

# include <string.h>

using namespace std;

class citizen

{      

    int i;

    public string name[30];

    public long int phonenumber[30];

    public void addindividual(string name1)

     {      

           If (i<=30)

            {     int flag=0;

                  for(int j=0; j<=i;j++)

                  {

                     if (strcmp(name[i], name1)

                      {

                          flag=1;

                      }

                     else

                     {  

                           flag=0;

                     }

                  }

                  If (flag)

                 {

                  if (i<30)

                  {

                  for(j=i+1;j<=30; j++)

                  {

                        cout<<"Enter the name:"; getchar(name[j]);

                        cout<<"Enter the phone number:"; cin>>phonenumber[j];

                         i++;

                   }

                  else  

                   {

                        cout<<"The person already exists";

                        exit();

                   }

              }

            else

             {

                 cout<<"array is full:";

                 exit();

             }

     }

}

Void main()

{

     string str;

    cout<<" Enter name:";

    getline(cin, str); ;

     citizen c1=new citizen();

     c1.addindividual(name1);

}

Explanation:

With a little more effort you can make the program allow the user to enter any number of details, but less than 30 overall. We have used here flag, and as a programmer we know why we use the Flag. It is used to check whether certain Boolean condition is fulfilled or not. Here, we are checking whether a given name is present in the array of names, and if it is not present, we add that to the list. And if the name is present, we print, it already exist.

4 0
3 years ago
After configuring the role services on the Remote Desktop server, Jabez creates a collection for the Marketing group in the orga
lawyer [7]

The option that  is true is option C: Jabez created a shared folder that is accessible to remote servers in the collection.

<h3>What are servers?</h3>

A server is known to be a form a computer program or device that helps to give a service to a given computer program and its user.

Note that in the case above, The option that  is true is option C: Jabez created a shared folder that is accessible to remote servers in the collection.

Learn more about servers from

brainly.com/question/17062016

#SPJ1

8 0
2 years ago
Which is a method used to determine database requirement?
Ivahew [28]

Answer:

I think it would be A, good luck!

8 0
3 years ago
Do u like five nights at Freddy's? and is it good or bad?​
Murljashka [212]

Answer:

its bad

Explanation:

6 0
3 years ago
Read 3 more answers
Evaluating sorts given the following array: 41, 32, 5, 8, 7, 50, 11 show what the array looks like after the first swap of a bub
irga5000 [103]

The way that  the array will looks like after the first swap of a bubble sort in ascending order is   {5,32,41, 8,7,50,11}.

<h3>Who do you Write sort code in JAVA?</h3>

It will be:

class SSort

{

  void sort(int array[])

  {

      int n = array.length;

      for (int i = 0; i < 2; i++)

      {

          int minimum_index = i;

          for (int j = i+1; j < n; j++)

              if (array[j] < array[minimum_index])

                  minimum_index = j;

           int temp = array[minimum_index];

          array[minimum_index] = array[i];

          array[i] = temp;

      }

  }

   void printArray(int array[])

  {

      int n = array.length;

      for (int i=0; i<n; ++i)

          System.out.print(array[i]+" ");

      System.out.println();

  }

  public static void main(String args[])

  {

      SSort s = new SSort();

      int array[] = {41, 32, 5, 8, 7, 50, 11};

      s.sort(array);

      System.out.println("After first two iteration of Selection sort:");

      s.printArray(array);

  }

}

Therefore, The way that  the array will looks like after the first swap of a bubble sort in ascending order is   {5,32,41, 8,7,50,11}.

Learn more about array  from

brainly.com/question/26104158

#SPJ1

8 0
2 years ago
Other questions:
  • Assume that a kernel is launched with 1000 thread blocks each of which has 512 threads. If a variable is declared as a shared me
    6·1 answer
  • What are vertical sets of cells called
    5·2 answers
  • How is typing speed measured
    12·2 answers
  • Which social network site has 1.5 billion actives users per month?
    15·1 answer
  • What is the difference between "What I ought to do?" and "What kind of person should I be"?
    12·1 answer
  • Select the correct answer.
    9·1 answer
  • Quick!! Im taking a timed test so pls hurry!! Ill even mark as brainliets!!
    5·2 answers
  • Is it a way to get robuc 4 free
    6·2 answers
  • Which programming scenario would most likely involve this array block?<br><br>SOMEONE PLEASE HELPPP​
    9·1 answer
  • Can you help me solve this challenging activity?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!