Complete the function ratio_similarity, which computes the ratio of "similarity" between two non-empty strings. The ratio is computed as follows: 2* (the number of matches of characters) / (total number of characters in both strings) The matches are determined in pairwise fashion. For example, consider the strings abcdef and abdce. The three characters at indexes 0, 1 and 4 match. Therefore, the similarity ratio is 2 * 3/(6+5) = 0.5454.... Examples: Function Call string similarity('abcdef', 'abdce') string similarity('dragon', 'flagon') string similarity('stony', 'stony') string similarity('Stony Brook University', 'WolfieNet Secure'). string_similarity('yabba dabba doo', 'bippity boppity boo') string_similarity('Wolfie the Seawolf', "What's...a Seawolf?") [ ] Return Value 5# Test cases 6 print (string_similarity('abcdef', 7 print (string_similarity('dragon', 0.5454545454545454 'abdce')) 'flagon')) 'stony')) 0.6666666666666666 1.0 0.0 1 def string_similarity (str1, str2): 2 return 'Error' # DELETE THIS LINE and start coding here. 0.058823529411764705 0.4864864864864865 3 # Remember: end all of your functions with a return statement, not a print statement! 4 8 print (string_similarity('stony', 9 print (string_similarity('Stony Brook University', 'WolfieNet Secure'))
Complete the function ratio_similarity, which computes the ratio of "similarity" between two non-empty strings. The ratio is computed as follows: 2* (the number of matches of characters) / (total number of characters in both strings) The matches are determined in pairwise fashion. For example, consider the strings abcdef and abdce. The three characters at indexes 0, 1 and 4 match. Therefore, the similarity ratio is 2 * 3/(6+5) = 0.5454.... Examples: Function Call string similarity('abcdef', 'abdce') string similarity('dragon', 'flagon') string similarity('stony', 'stony') string similarity('Stony Brook University', 'WolfieNet Secure'). string_similarity('yabba dabba doo', 'bippity boppity boo') string_similarity('Wolfie the Seawolf', "What's...a Seawolf?") [ ] Return Value 5# Test cases 6 print (string_similarity('abcdef', 7 print (string_similarity('dragon', 0.5454545454545454 'abdce')) 'flagon')) 'stony')) 0.6666666666666666 1.0 0.0 1 def string_similarity (str1, str2): 2 return 'Error' # DELETE THIS LINE and start coding here. 0.058823529411764705 0.4864864864864865 3 # Remember: end all of your functions with a return statement, not a print statement! 4 8 print (string_similarity('stony', 9 print (string_similarity('Stony Brook University', 'WolfieNet Secure'))
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY