subject

Python program You are given the following text file called Mytext. txt. Write a Python function called search_file that accepts the name of the file (i. e. filename) and a string to look for in the file (i. e. mystring) as parameters. The function then looks for mystring in the file. Whenever it finds the string in a line, it saves the line number and the text for that line in a dictionary. Finally, it returns the dictionary after reading all the lines in the file and populating the dictionary with all matching line numbers and line text. If an empty string or a blank string is passed as mystring then an empty dictionary is returned.
Sample Input: search_file("Mytext. txt","python")
Sample Input: search_file("Mytext. txt","")
Contents of Mytext. txt
Python is an interpreted, high-level, programming language.
Python is dynamically typed and garbage-collected.
Python was conceived in the late 1980s.
Python 2.0, was released in 2000.
Python 3.0, was released in 2008.
The interpreters are available for many operating systems.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 14:30
Which of the following would not be considered a pc? a. mainframe b. desktop c. tablet pc d. laptop
Answers: 2
question
Computers and Technology, 23.06.2019 17:10
Ac++an of of pi. in , pi is by : pi = 4 – 4/3 + 4/5 – 4/7 + 4/9 - 4/11 + 4/13 - 4/15 + 4/17 . ., to pi (9 ). , if 5 to pi,be as : pi = 4 - 4/3 + 4/5 - 4/7 + 4/9 = 4 – 1. + 0.8 - 0. + 0. = 3.. atoofbe to pi?
Answers: 2
question
Computers and Technology, 24.06.2019 02:00
Read the following scenario, and then answer the question below. you want to send an e-mail to your boss requesting a meeting to discuss a raise. what is the best example of an e-mail to an employer about this meeting? “hey jason. can we chat about getting me more money soon? let me know. peace, meg.” “hello jason. pardon me for sending yet another e-mail today about my need to talk to you about my position and a possible pay increase. i am dying to know when you can talk. sincerely, meg.” “hello jason. i have been with the company for one year and have taken on more responsibilities than outlined in my job description. i would appreciate an opportunity to speak with you about my position. let me know when we can schedule a meeting. you, meg.” “greetings jason! i hope this e-mail finds you well and happy today. i really, really want to talk to you about something important. i am not sure if you have time. i hope you do. get back in touch with me and let me know when we might talk. ever so much for taking the time to read this. sincerely, meg.”
Answers: 3
question
Computers and Technology, 24.06.2019 10:00
Which two technologies support the building of single-page applications?
Answers: 2
You know the right answer?
Python program You are given the following text file called Mytext. txt. Write a Python function c...
Questions
question
Mathematics, 03.12.2020 19:50
Questions on the website: 13722367