Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

REALLY Need Help !!!! I do not how to start! Thanks a lot!!!!! Really need how to do it !!!!Python In the starter code provided

REALLY Need Help !!!! I do not how to start! Thanks a lot!!!!! Really need how to do it !!!!Pythonimage text in transcribed

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

In the starter code provided on CANVAS, there are 3 functions (partially written), you must code the empty segments so the three functions work according to the following requirements: findNextOpr(txt) 130 ptsl .txt is a non-empty string that contains an arithmetic expression that may include numeric values, five arithmetic operators (and and extra spaces. An example of such expression is"-4.755 -2.01 /3* 7+ 2A5" It returns the position of the leftmost operator in txt,-1 if no operator was found. findNextOpr( 356") returns- findNextOpr("3 *4 - 5 ") returns 4 txt 0 23 4 567 8910 4 5 isNumber(txt) 120 ptsl txt is a non-empty string . It returns a boolean value, True if txt is a string convertible to float, otherwise False. Note that " -25.22222 " is a string convertible to float but " -22 33 " and "122; 45" are not An easy way to check if str to float is possible is with a try-except block isNumber Hello") returns False isNumber"2658 "returns True isNumber("2 8 ") returns False getNextNumber(expr, pos) [50 pts] getNextNumber returns the operator position in expr[pos:] returnsa boolean value findNextOpr isNumber expr is a non-empty string, pos is an integer greater than or equal to 0 It returns 3 values: e . 1st returned value: the next number (as float) after pos and before the next operator (If there is no single number in it, return None) o getNextNumber returns the operator position in expr[pos:] call returns a boolean value findNextOpr isNumber expr is a non-empty string, pos is an integer greater than or equal to 0 It returns 3 values: e . o 1st returned value: the next number (as float) after pos and before the next operator (If there is no single number in it, return None) 2nd returned value: the next operator (If no such operator return None) 3rd returned value: the next operator position (If no such operator return None) o o The next number must account for negative numbers (see examples in the doctest) The next operator position is its position in exp.r It MUST use the functions findNextOpr and isNumber effectively, otherwise, no credit is given to this function getNextNumber(" 356", 0) returns (356.0, None, None) getNextNumber(" 3 *4-5", 5) returns (4.0, '-', 8) 3rd returned value pos 0 2 345 6 78 9 10 11 4 2nd returned 1st returned value value getNextNumber("3 *4-5", 2) returns (None, "*", 4) pos 3rd returned value 0 2 3 45 6 78 9 10 11 4 1st returned value (None) 2nd returned value getNextNumber(" 3 *-4+5", 5) returns (-4.0, '+', 9) 3rd returned value pos 02345 6 78 9 10 1 12 le 4 2nd returned value 1st returned value (-4.0) Testing and Debugging are important! Check the first two functions individually first Input some parameters and check the returned value(s) Use the Python debugger discussed on Module 2 to help you debug your code Use Python's unittest module to run extensive cases on your code to ensure full credit def findNextOpr (txt): >>> findNextOpr ('89 4 5') if not isinstance (txt, str) or len (txt)=0: return "error: findNextOpr" YOU CODE STARTS HERE def isNumber (txt): False >>> isNumber (' False isNumber (' True 156.3) 29.99999999 5.9999x ') False if not isinstance (txt, str) or len (txt)--0: return "error: isNumber" YOU CODE STARTS HERE def getNextNumber (expr, pos): H11 11 >>>getNextNumber '85 2',0) >>>getNextNumber('8 5-2',4) ., 13) >>>getNextNumber ('4.5 3.15 (5.0, None, None) >>> getNextNumber ('4.5 + 3.15 (None, 'I', 19) -5',20) 5',10) if not isinstance (expr, str) or not isinstance (pos, int) or len (expr) 0 or pos-len (expr) return None, None, "error: getNextNumber" # YOU CODE STARTS HERE

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

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

Describe some variables used to measure the value added of HRM

Answered: 1 week ago

Question

Critically evaluate research on the HRMperformance relationship

Answered: 1 week ago