Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This function must have the following header: def conv _ num ( num _ str ) . This function takes in a string and converts
This function must have the following header: def convnumnumstr This function takes in a string and converts it into a base number, and returns it It has the following specifications:
Must be able to handle strings that represent integers
Must be able to handle strings that represent floatingpoint numbers
Must be able to handle hexadecimal numbers with the prefix x
Must be case insensitive both the prefix and what follows
Negative numbers are indicated with a like xFF
Only integers are valid inputs for hexadecimal numbers ie no xFF
The type returned must match the type sent. For example, if a string of an integer is passed in convnum must return an int.
Invalid formats should return None nb this is not a string, but the actual None value including, but not limited to:
strings with multiple decimal points
strings with alpha that aren't part of a hexadecimal number
strings with a hexadecimal number without the proceeding x
values for numstr that are not strings or are empty strings
Some examples:
convnum returns
convnum returns
convnum returns
convnum returns
convnumxAD returns
convnumXad returns
convnumxAZ returns None
convnumA returns None
convnum returns None
You are not permitted to use any of the following:
int
float
hex
eval
literaleval
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