def contains_song(title: str, filename: str) -> bool:
''' Return True iff title (the name of a song as a string) is included in the file with of the given filename.
'''
def contains_song(title: str, filename: str) -> bool: """ Return True iff title (the name of a song as a string) is included in the file with of the given filename. """ with open(filename) as f: for line in f: if line.startswith(title): return True return False
def contains_song(title: str, filename: str) -> bool: ''' Return True iff title (the name of a...
COMPLETE THE FOLLOWING QUESTION def find_favourite_artist(filename: str) -> str: ''' Return the name of the artist that occurs most frequently in the song file of the given filename. If there are more than one artists that occur most frequently, just return any of them. Note: Feel free to create helper functions for this if you need to. Hint: You may want to use the "sorted" function. ''' pass THE SONG FILE IS: Title, Singer, Release Year Let it go, Idina...
Python help def palindrome_word: ''' (str) -> bool The parameter is a string consisting only of lowercase alphabetic letters. It may or may not be a palindrome. Return True if and only if the parameter is a palindrome. The empty string is considered to be a palindrome. ''' def palindrom_phrase: ''' (str) -> bool The parameter is a string that may or may not be a palindrome. Return True if and only if the parameter is a palindrome, independent of...
def contains_hashtag(valid_tweet: str, tweet_word:str) -> bool: '''Return True if the valid tweet contains the tweet word, with a hashtag at the beginning. Tweet can contain multiple tweet words. >>>contains_hashtag('I like #csc108', 'csc108') True >>>contains_hashtag('I like #csc108', 'csc') False >>>contains_hashtag('I like #csc108, #mat137, and #phl101', 'csc108') True pls finish this function by using python string method(do not use advance methods)
Implement and test the following function://bool ispalindrome(string s)//return true iff s is a palindrome//For example: ispalindrome("RADAR") return true, //ispalindrome("ABCD") returns false. Enter word to find if the word is palindrome: RADAR The word is RADAR a palindrome Press any key to continue .. Enter word to find if the word is palindrome: ABCDEF The word is ABCDEF is not a palindrome Press any key to continue......
def add_mention_exclusive(valid_tweet: str, tweet_word: str) -> str: ""Return if the potential tweet is valid, the original tweet contains the given tweet word, and the original tweet does not mention the given tweet word, the function should return the potential tweet. Otherwise, the function should return the original tweet. >>>add_mention_exclusive ('Go Raptors!', 'Raptors') 'Go Raptors! @Raptors' >>>add_mention_exclusive('Go @Raptors!', 'Raptors') 'Go @Raptors! if
12. (10 pts) Fill in the blanks according to the documentation: def readAndStrip (fileName, charsToRemove) : ""This function will take in a fileName and characters to remove. It will read everything from the fileName and return a lis of all the words with given chars ToRemove removed.""" #Open the file file = #Read the file #Close the file #Create the list #Strip all the charsToRemove for #return the clean list return
def most_expensive_item(price_list: List[list]) -> str: """Return the name of the most expensive item in price_list. Precondition: price_list is a list of lists in the following format: [ [str, int], [str, int], ... ] where each 2-element list represents a name (str) and a price (int) of an item. price_list has at least one element. >>> price_list = [["apple", 1], ["sugar", 5], ["mango", 3], ... ["coffee", 9], ["trail mix", 6]] >>> most_expensive_item(price_list) """ please complete the function body in Python
In Python
4. outputWordPointPairs(pointWordList, filename, toFile) NO return (just prints a formatted list or writes it to file). NOTE: Your function should add the .txt extension to the filename before opening a file with that name. Write a function which will output the (pointValue, word) pairs in pointWordList to the shell or to a file depending on the bool value toFile. Note the order of elements of the tuple is (pointValue, word) not (word, pointValue). Find out why this specific...
Can someone help me put the string removee the return to an outfile and fix?? prompt: CS 575 LabEx14: no e’s Let the user specify an input file and an output file (text files). Read the input file and write the output file; the output file should be the same as the input file, except that it has no e’s. For example, if the input file had the line. Streets meet in the deep. Then the output file would have...
Python 3 Monster = {"name": str, "kind": str, "spookiness": int, "undead?": bool} ''' M5. Define a function `count_spooky_monsters` that consumes a list of monsters and produces an integer indicating how many monsters have a spookiness of 2 or more. ''' ''' M6. Define the function `count_vampires` that consumes a list of monsters and produces an integer indicating how many monsters are of the kind "vampire". '''