Write a function that determines if two strings are anagrams. The function should not be case sensitive and should disregard any punctuation or spaces. Two strings are anagrams if the letters can be rearranged to form each other. For example, “Eleven plus two” is an anagram of “Twelve plus one.” Each string contains one “v”, three “e’s”, two “l’s”, etc. Test your function with several strings that are anagrams and non-anagrams. You may use either the string class or a C-style string.
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Database Concepts (8th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out with Python (4th Edition)
SURVEY OF OPERATING SYSTEMS
Degarmo's Materials And Processes In Manufacturing
Starting Out With Visual Basic (8th Edition)
- please code in python Write a function that receives a string and a number (n) as parameters and returns a new string that contains only every nth letter from the given string. print(everyNth('banana', 2)) # should return aaaprint(everyNth('carrot', 3)) # should return rtprint(everyNth('pear', 1)) # should return peararrow_forward1. Complete the function char_cycle. This function takes two parameters - a string (s) and an integer (n). char_cycle should print the first character from s; after that, it should print every nth character. For example, if the string is "abcdefghijklmn" and the integer is 3, char_cycle should print "adgjm". Use a loop - do not use string slicing. Do not change anything outside char_cycle. Save & Run Load History Show CodeLens 1 def char_cycle(s, n): '''Use a loop to print the first character in string s; after that, print every nth character''' 3 4 pass 5 6 user_string 7 char_cycle(user_string, 2) 8 char_cycle(user_string, 3) 9 char_cycle(user_string, 5) input("Please enter a string: ") 10arrow_forwardYou may assume that both of the input strings are 5 letters and all lowercase. Problem D. Durdle Game Using the function from the previous problem, write a function durdle_game(target) which takes in as an argument a single string that will be the target to guess, and lets the user attempt to guess the target word. Each time the user makes a guess, the function will print out the result of the previous function to tell the user how close they are. If the user guesses correctly, then the game is over. Have the function return the number of guesses that it took the user to get the correct answer.arrow_forward
- 4 Write a program that prompts the user to input a string. The program then use the function substr to remove all the vowels from the string. For example if str = "There", then after removing all the vowels, str = "Thr". After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel.arrow_forwardFor each function, describe what it actually does when called with a string argument. If it does not correctly check for lowercase letters, give an example argument that produces incorrect results, and describe why the result is incorrect. # 1 def any_lowercase1(s): for c in s: if c.islower(): return True else: return False # 2 def any_lowercase2(s): for c in s: if 'c'.islower(): return 'True' else: return 'False' # 3 def any_lowercase3(s): for c in s: flag = c.islower() return flag # 4 def any_lowercase4(s): flag = False for c in s: flag = flag or c.islower() return flag # 5 def any_lowercase5(s): for c in s: if not c.islower(): return False return True The code and its output must be explained technically whenever asked. The explanation can be provided before or after the code, or in the form of code comments within…arrow_forwardin c programing with User-Defined Functions Remove all non-alphabetic characters Write a program that removes all non-alphabetic characters from the given input. Assume the input string will not exceed 50 characters. Ex: If the input is: -Hello, 1 world$! the output is: Helloworld The program must define and call a function named RemoveNonAlpha that takes two strings as parameters: userString and userStringAlphaOnly. userString is the user specified string from the program input. Function RemoveNonAlpha() then assigns userStringAlphaOnly with the user specified string without any non-alphabetic characters.void RemoveNonAlpha(char userString[], char userStringAlphaOnly[])arrow_forward
- In C language, Write a function that gets a string containing a positive integer. The function subtracts 1 fromthat integer and puts the obtained value in the string. void str_subtract_one(char* num); For example:- if before we call str_subtract_one(str) we have str==“1997”, then after return str will be “1996”.- if before we call str_subtract_one(str) we have str==“12345678987650”, then after return str will be “12345678987649”.- if before we call str_subtract_one(str) we have str==“100”, then after return str will be “99”. 1. You may assume that the input is always legal, i.e., the string is a positive integer correctly formatted.2. Note that the numbers may be larger than the maximum of int or long. That is, you should not try to convert string to intarrow_forwarduse c code to Develop a function that gets two same length strings as parameters and reports the number of characters that they have different. For example, if the two strings are Str1: “Hello world! Happy Friday”Str2: “Hello Johny! happy friday” The function should return: Your strings are different in 7 places However, if the strings are exactly equal, it should just say Your strings are the same If the strings are not of the same length, the code should just say: The two strings are not of the same length! Hint: 1.compare the two strings character by character and report the differences 2.answer must have and show the outputarrow_forwardWrite a isPalindrome Function Write a function isPalindrome($str) that returns true if the parameter string is a palindrome (a palindrome is a word or sentence that reads the same forward and backward at the character level). You should ignore non-letter characters when determining if the string is a palindrome. Thus, isPalindrome("A man, a plan, a canal, Panama!") should return true.arrow_forward
- Instructions Write a program that uses the function is Palindrome given in Example 6-6 (Palindrome). Test your program on the following strings: madam, abba, 22, 67876, 444244, trymeuemyrt Modify the function isPalindrome of Example 6-6 so that when determining whether a string is a palindrome, cases are ignored, that is, uppercase and lowercase letters are considered the same. The isPalindrome function from Example 6-6 has been included below for your convenience. bool isPalindrome (string str) { int length = str.length(); for (int i = 0; i < length / 2; i++) { if (str[i] != str[length - 1 - i]) { return false; } // if } // for loop return true; }// isPalindrome Your program should print a message indicating if a string is a palindrome: madam is a palindromearrow_forwardPlease help I cant do it ,pleasearrow_forwardEx. 8.4) The following functions are all intended to check whether a string contains any lowercase letters, but at least some of them are wrong. For each function, describe what the function actually does (assuming that the parameter is a string).arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning