Answered step by step
Verified Expert Solution
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
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 tryexcept statement. You are not allowed to use conditionals statements or expressions anywhere in your code.
Look at the sample code in unit 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 indexstr 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 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 eg 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started