Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python question Question 2 An anagram is a word or phrase that's formed by rearranging the letters of another word or phrase. Thus two words

python questionimage text in transcribed

Question 2 An anagram is a word or phrase that's formed by rearranging the letters of another word or phrase. Thus two words are anagrams if and only if they contain the exact same letters with the exact same frequency (for example, "name" and "mean" and "listen" and "silent" are anagrams, but "red" and "deer", and "ideal" and "delis" are not). Write a program which asks for a series of strings, two at a time, and uses user-defined functions to determine if each set of strings are anagrams of each other or not. The case (uppercase/lowercase) of the string's characters should not be a factor when checking for anagram's in this program, so you may convert both strings to all lowercase by using the built-in string function lower() (e.g., string_var.lower()). You may also use the built-in sorting function sorted (string parameter), if you wish. Your program should include two functions: function isAnagram that returns True if the two given words are anagrams, otherwise it returns False. function main that allows the user to enter any number of sets of two words and, using the function isAnagram, prints if the two given words are anagrams or not. If the words are different lengths, then the main function should report this right away without calling i sAnagram. Sample input and output from the program is: Enter the first word: Name Enter the second word: mean The two words Name and mean are anagrams. Do you wish to check for more anagram words? (yes or no) yes Enter the first word: delis Enter the second word: Ideal The two words delis and Ideal are not anagrams. Do you wish to check for more anagram words? (yes or no) yes Enter the first word: Pete Enter the second word: Pet The two words Pete and Pet are not the same length, hence cannot be anagrams. Do you wish to check for more anagram words? (yes or no) yes Enter the first word: Listen Enter the second word: Silent The two words Listen and Silent are anagrams. Do you wish to check for more anagram words? (yes or no) yes Enter the first word: noon Enter the second word: moon The two words noon and moon are not anagrams. Do you wish to check for more anagram words? (yes or no) no Call the file containing your program anagram.py

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions

Question

Will you be able to pay your bills?

Answered: 1 week ago

Question

How are values illustrated in the case?

Answered: 1 week ago

Question

Describe S. Truett Cathys self-concept and self-efficacy.

Answered: 1 week ago