Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

8 . Implement iseurofloat Read the specification for the function iseurofloat. This is a function to check if a string represents a floating point number

8. Implement iseurofloat
Read the specification for the function iseurofloat. This is a function to check if a string represents a floating point number in European format. This format uses a comma in place of a decimal point. This type of float is formatted integer, comma, integer, where the second integer cannot be negative. Implement this function with a try-except statement. You are not allowed to use conditionals (statements or expressions) anywhere in your code.
Look at the sample code in unit2 for guidance on how to do this. You need to use functions that are guaranteed to crash if they do not find what they expect. For example, you may find the function index_str in the introcs module to be helpful. Look at the documentation in the string functions for the IntroCS API (accessible from the Read page in the Using Conditional Statements module).
The hardest test case to address will be the input '12,-5. You will not be able to crash on this input without crashing on other inputs that should return True. You will be tempted to use a conditional here (e.g. return False if the number after the comma is negative and True otherwise). But while we said you could not use conditionals, you can still use boolean expressions.
When you are done with the implementation, run the test script. If you are successful, you should pass all tests.

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

Sql All In One For Dummies 7 Books In One

Authors: Allen G Taylor ,Richard Blum

4th Edition

1394242298, 978-1394242290

More Books

Students also viewed these Databases questions