Python:
def symmetricDiff(set1, set2): result = [] for x in set1: if not(x in set2): result.append(x) for x in set2: if not(x in set1): result.append(x) return set(result) # Testing set1 = set([4,2,0,7,9]) set2 = set([1,2,8,6,9]) print(symmetricDiff(set1,set2))
Python: Write a function symmetricDiff that has two parameters of type set and returns a new...
Write a function named words_in_both that takes two strings as parameters and returns a set of the words contained in both strings. You can assume all characters are letters or spaces. Capitalization shouldn't matter: "to", "To", "tO", and "TO" should all count as the same word. The words in the set should be all lower-case. For example, if one string contains "To", and the other string contains "TO", then the set should contain "to". The file must be named: words_in_both.py...
Write a function named words_in_both that takes two strings as parameters and returns a set of the words contained in both strings. You can assume all characters are letters or spaces. Capitalization shouldn't matter: "to", "To", "tO", and "TO" should all count as the same word. The words in the set should be all lower-case. For example, if one string contains "To", and the other string contains "TO", then the set should contain "to". You can use Python's split() funciton,...
Python 1 Write a function called sum_odd that takes two parameters, then calculates and returns the sum of the odd numbers between the two given integers. The sum should include the two given integers, if they are odd. You can assume the arguments will always be positive integers, and the first smaller than or equal to the second. 3 To get full credit on this problem, you must define at least 1 function, use at least 1 loop, and use...
Python Write a function (named largest_of_three) that takes three parameters and returns the largest. You can assume the parameters are either floats or ints.
in python Write a function, named max_of_two, that takes two numbers as arguments and returns the largest of the two values. (Note, this function is actually already provided in Python as max. Do not use the provided function; reason through the logic yourself).
Language: Python Function name : findwaldo Parameters : string Returns: int Description: Write a recursive function that takes in a string containing some combination of letters, numbers, and spaces, and return the starting index of the first instance of “waldo” contained in that string. If the string does not contain “waldo”, return -1. This function IS case sensitive, so “waldo” is not the same as “WALDO”. Code using string functions such as .index() and .find() that oversimplify the problem will...
Using python, write a function that expects two parameters, one will be the amount of the dinner check (a float), and the other one will be the percentage of the tip expressed as an integer(20 for 20 percent). The user will give as input these two values. The function will return to the amount that the tip should be. Output the results.
In Python: Write the definition for a function named avg which accepts two int parameters, and returns the average of the two values Write a statement that calls this function to print out the average of values 11 and 25.
Python 3: Write a function called every_other_character() that takes in a string and returns a new string with every other character removed. That is, the new string will include the first, third, fifth, etc. letters of the given string. Must use a while or for loop in the solution.
Write a Python function that will take a string and a list as its only parameters. The function needs to return a new string that is the original string with all of the characters appearing in the list parameter replaced with an asterisk(*). The returned string needs to have the remaining characters appear in the same location as the characters they replaced. Hint/Reminder: Note you can make a string out of characters optimally without repeatedly using the concatenation operator.