***PYTHON CODING QUESTION*** I'm not sure how to do this question... Here are some test cases: I have no clue where to b

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

***PYTHON CODING QUESTION*** I'm not sure how to do this question... Here are some test cases: I have no clue where to b

Post by answerhappygod »

***PYTHON CODING QUESTION***
I'm not sure how to do this question...
Python Coding Question I M Not Sure How To Do This Question Here Are Some Test Cases I Have No Clue Where To B 1
Python Coding Question I M Not Sure How To Do This Question Here Are Some Test Cases I Have No Clue Where To B 1 (33.5 KiB) Viewed 25 times
Here are some test cases:
Python Coding Question I M Not Sure How To Do This Question Here Are Some Test Cases I Have No Clue Where To B 2
Python Coding Question I M Not Sure How To Do This Question Here Are Some Test Cases I Have No Clue Where To B 2 (14.38 KiB) Viewed 25 times
I have no clue where to begin! Can someone please help me write
this code?
We also might want to look at only valid words in our data set. A word will be a valid word if all three of the following conditions are true: • The word contains only letters, hyphens, and/or punctuation* (no digits). • There is at most one hyphen '-'. If present, it must be surrounded by characters ("a-b" is valid, but"-ab" and "ab-" are not valid). • There is at most one punctuation mark. If present, it must be at the end of the word ("ab,", "cd!", and "." are valid, but "a!b" and "c.," are not valid). NB: for this question, the 3rd condition will also apply to apostrophes despite "valid" words containing them. Write a function valid_words_mask(sentence) that takes an input parameter sentence (type string) and returns the tuple: (int, list[]), where: • int is the number of valid words found. • list[] contains the booleans True or False for each word in sentence (in sequence) depending on whether that word is valid. *Assume that a punctuation mark is any character that is not an alphanumeric (except for hyphens, which are handled separately as per the instructions).
For example: Test Result (4, [True, True, True, True]) sentence = "these are valid words" print(valid_words_mask(sentence)) (0, (False, False, False]) sentence = "!this 1-5 b8d!" print(valid_words_mask(sentence)) (2, [True, True, False]) sentence = "mciheal mnefiodonvass? W-0-" print(valid_words_mask(sentence)) sentence = "it's Minecraft, not Mine-Craft!!" (2, (False, True, True, False]) print(valid_words_mask(sentence))
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply