Question: we are using python [30 marks] Write a function named compress that takes a string as a parameter. This function compresses a string by replacing

we are using python  we are using python [30 marks] Write a function named compress
that takes a string as a parameter. This function compresses a string

[30 marks] Write a function named compress that takes a string as a parameter. This function compresses a string by replacing any sequentially repeated letters with a letter and a number where the number indicates how many times the letter was repeated. The function returns the compressed string. For example: > compress(" ") > compress("abc") ' ab ' \> compress("aabbbbccccccc") ' a2b4c7 ' 2) [ 30 marks] Write a function called expand that takes a string in the compressed format and returns the original string. You may assume that any number in the compressed string is a single-digit number. For example: > expand(" ") expand("abc") ' abc expand("a3b7c2") 'aaabbbbbbbcc' [40 marks] Write a function called Write a function named is_basic_expr. This function must accept a string as a parameter and return a Boolean value that indicates whether that string represents a valid basic expression. For this question, assume that valid expressions consist of one or more positive integers that are separated by basic operators (only the operators +,,, and / ). The string must start and end with an integer. Moreover, a single space must always separate integers and operators in a valid expression. For example: \> is_basic_expr("1") True is_basic_expr("1 + 22") True is_basic_expr("1+22 * 333 ") True is_basic_expr("-1") False is_basic_expr("1++22") False is_basic_expr("1 22 * 333") False is_basic_expr("1 ") False is_basic_expr("1 +") False is_basic_expr("1 + ") False is_basic_expr("1 + 22") False NOTE the spaces, in the last example there are 2 spaces before and after the +

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!