Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a function common_strings which takes two lists of strings and returns a list of common strings. For example, list1 = [ B, A,C

image text in transcribed
1. Write a function common_strings which takes two lists of strings and returns a list of common strings. For example, list1 = [ "B", "A","C" ], list2 = ["C", "B", "D" ), your function should compare items in these two lists and return a new list = ["B", "C"](the order doesn't matter), because both String "B" and "C" are present in list1 and list2. Run some test cases to verify correctness of your function. def common_strings( list1, list2): 2. Based on the first question, could you write another function to get the difference, ie, find all strings in list1 but not in list2, and all strings in list2 but not in list1? let us say L1 represents the list of all strings in list1 but not in list2, L2 represents the list of all strings in list2 but not in list1, you should return (L1, L2]. There are definitely different algorithms to implement such diff function, please choose a more efficient algorithm if possible. def my_diff( list1, list2): 3. As we know, each public company has a symbol for its stock trading in the financial market. For instance, AAPL is the symbol for Apple Inc., GOOG is the symbol for the company Google etc. Here we have two files symbols 1.txt and symbols2.txt, each file contains many symbols of public companies in Nasdaq. Please write a program to read these two files, use your my_diff function in the question 2 to find out the difference, you can either save the results to file/files or just print them out. Please convert each symbol to upper case before doing comparison

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are psychologys major levels of analysis?

Answered: 1 week ago

Question

Find the derivative. f(x) 8 3 4 mix X O 4 x32 4 x32 3 -4x - x2

Answered: 1 week ago