Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON PROGRAMMING Imagine a customer in a bank is asked to enter a whole number representing their approximate monetary worth. In that case, some people

PYTHON PROGRAMMING

Imagine a customer in a bank is asked to enter a whole number representing their approximate monetary worth. In that case, some people use commas to separate thousands, millions etc, and some dont. In order to perform a some calculations the bank needs that number as na integer. Write a function, called casual_number(s) that has one parameter, s, as input where s is a string. Function casual_number(s) should return an integer representing a number in s. If s does not look like a number the function should return None. Note that if a string in s looks like a number but with commas, you may assume that commas are in meaningful places i.e. you may assume that s will not be a string like 1, 1, 345.

>>> TESTING CODE:

>>> casual_number("251")

251

>>> casual_number("1,aba,251")

>>> casual_number("1,251")

1251

>>>casual_number("1251")

1251

>>> casual_number("-97,251")

-97251

>>> casual_number("-97251")

-97251

>>> casual_number("-,,,,")

>>> casual_number("--97,251")

>>> casual_number("-")

>>> casual_number("-1,000,001")

-1000001

>>> casual_number("999,999,999,876")

999999999876

>>> casual_number("-2")

-2

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 Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

6. Team members respect and trust each other.

Answered: 1 week ago