Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

TEST: def check(num_string): print(num_string, end=' is ') if not valid_float(num_string): print(end='not ') print('valid') test_values = 0.6 00.6 .6 -0.6.split() for number in test_values: check(number) RESULT:

image text in transcribed

TEST:

def check(num_string): print(num_string, end=' is ') if not valid_float(num_string): print(end='not ') print('valid') test_values = "0.6 00.6 .6 -0.6".split() for number in test_values: check(number)

RESULT:

0.6 is valid 00.6 is not valid .6 is not valid -0.6 is valid

The function has this signature def valid float (number_string) Check whether a string consists only of decimal digits (of any length) and the "- and"." characters and matches the following requirements. The function returns True if the string is valid, and False otherwise. The string must start with a decimal digit or "-". The"-" can only occur as the first character if it appears at all. If the first decimal digit is a "O" the next character must be".". The string does not have to include a"." There can be only one". in the string. If the string includes a." there must be a string of 1 or more decimal digits before the"."and there must be 1 or more decimal digits after the"." These strings are valid: 1234 -1234 12.4 -1234567890.123456789 These strings are invalid: +123 123 00.6 12-.6335

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

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

What are the attributes of a technical decision?

Answered: 1 week ago

Question

How do the two components of this theory work together?

Answered: 1 week ago