in python Complete the function compare_files(fn1,fn2) so that it takes two file names and if their content is exactly the same return True, otherwise return False. Note: Capitalization, punctuation and spacing must also be the same. Example: compare_files("myf1.txt", "myf3.txt") returns True
def compare_files(fn1, fn2):
try:
f1 = open(fn1)
f2 = open(fn2)
data1 = f1.read()
data2 = f2.read()
f1.close()
f2.close()
return data1 == data2
except FileNotFoundError:
return False
in python Complete the function compare_files(fn1,fn2) so that it takes two file names and if their...
Complete a Python function compare_files(fn1,fn2) to compare file1 and file2, if their content are same return True, otherwise return False. should start with def compare_files(f1,f2): myf3.txt contains: a b c d myf2.txt contains: A B C D myf1.txt contains: a b c d
in python
A. Define a function called contains_only_integers() that takes a tuple, returns True if all the items in the tuple are integers(2), and returns False otherwise. For example, contains_only_integers (3, 5, 17, 257, 65537) ), contains_only_integers( (-1,) ), and contains_only_integers( ) should all return True, but contains_only_integers (2.0,4.0)) and contains_only_integers (8, 4, "2", 1)) should both return false. Your function should use a while loop to do this calculation. 121 Hint: the is instance() built-in function provides the most...
Complete the Python function read_third_line() so that it takes a filename and returns the third line of the file as a string.
Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. Write a function named capital_letter that accepts a string as an argument and checks if each word in the string begins with a capital letter. If so, the function will return true, otherwise, return false. Please see the outcome below: Outcome number 1: Enter a string: Python Is Really Fun! True Sample run number 2: Enter a string: i Love Python False Note: Try to keep this...
In python Complete the function mostCommonCount() so that will accept a list of names as a parameter, and return the count of the most common name in the list. Examples: mostCommonCount( ['marquard', 'zhen', 'csev', 'zhen', 'cwen', 'marquard', 'zhen', 'csev', 'cwen', 'zhen', 'csev', 'marquard', 'zhen'] ) returns 5 mostCommonCount( ['Jacob', 'Michael', 'Joshua', 'Matthew', 'Emily', 'Madison', 'Emma', 'Olivia', 'Hannah'] ) returns 1
Please use python 3 programming language Write a function that gets a string representing a file name and a list. The function writes the content of the list to the file. Each item in the list is written on one line. Name the function WriteList. If all goes well the function returns true, otherwise it returns false. Write another function, RandomRange that takes an integer then it returns a list of length n, where n is an integer passed as...
Write a function that takes two string parameters which represent the names of two people and returns True if the people are a "match" and False if they are not. Determining Love Total all the ‘L’s ‘O’s ‘V’s and ‘E’s (uppercase and lowercase) found in each of their names. If the number of LOVE letters combined between both their names is odd, return True. If the number of LOVE letter combined between both their names is even, return False. *...
pythonComplete the below function that takes the name of two files, inFilename andoutFilename as arguments and reads the text from the inFilename. In this fileeach line contains the Turkish Republic Identity Number (TCNO), name, surnameand telephone number of a person. Your function should sort all personsaccording to their TCNO, write the sorted data into outFilename. If the fileinFilename does not exist, then the function must create an empty file namedoutFilename.For example, if the function is called such asreadText("in.txt", "out.txt")and in.txt...
in python Complete the function search_file(fname, wd) to take a filename and a word. If the the word is found in the file contents, the function should return True, otherwise it should return False.
In
python
Write a function called removeExtensión that is given the name of a file as a string and returns the same string without the extension (the last "" and any following characters); if the given string has no extension, return the given string without changing it. For example, removeExtension"Chapter 3.9.txt") should return "Chapter 3.9" while removeExtension("Hello") should return "Hello"