Each number read, except the final 0, is appended to a new list (initially empty) created by the function. The function should return the accumulated list.
The function get_pos_input takes no parameters. Instead, it reads integers one at a time from standard input until a positive integer is read.Β Once a positive integer has been read, that integer is returned.
The function sum_nonneg_input takes no parameters. Instead, it reads integersone at a time from standard input, maintaining a running sum of numbers entered, until a negative integer is read.Β Once a negative integer is read, the function returns the current sum. Note: the negative number is not included in the sum.
The function max_float_input takes no parameters. Instead, it reads strings from standard input, one at a time, until the string "stop" is read.
If the string is not "stop", the string is converted to a floating point value (type float) and compared to the largest previous float value entered (if any).
The function multiplication_quiz(a, b) takes two integer parameters, a and b. The function prompts the user (just once) to enter the product of a times b, and uses a loop to keep checking the input for the correct answer.
Write a definition for the function has_repeat(L). The parameter L is a list of immutable items. The function returns True if L has at least one repeated item, otherwise it returns False.
Implement the function num_distinct_elements(C). The function takes the parameter C, a collection of type list, string, or tuple, and returns the number of distinct items in C. For example, if C is the list [1, 2, 3, 3, 2, 1, 2, 3, 3, 10], the return value would be 4 (since 1, 2, 3, 10 are the "distinct" elements).
Write a definition for the function get_distinct_from_nested(C), where the parameter C is a sequence of sequences (e.g.,Β a list of strings or a list of lists of integers). The job of the function is to use set operations to find and return the sortedlist of unique elements in the nested collection C.
Write the definition for a function string_intersection(str1, str2), which takes two string parameters and returns a sorted list of the characters the two strings have in common.
Write the code to read two strings (str1, str2) from standard input and print a message regarding whether or not the strings are anagrams (rearrangements) of each other.
In addition, if the strings are NOT anagrams of each other, give one of the following explanations: "They do not have the same character sets.", or "They do not have the same character frequencies."
For example, "DOGS" and "GODS" are anagrams. "DOGS" and "HANOVER" do not have the same character sets, while "HANOVER" and "HANOOOVER" do not have the same character frequencies.
Use set operations to determine if two non-anagrams have the same character set; if they do share the same set of characters, then you may conclude that their character frequencies are the only difference.