18.3k views
5 votes
Write a functiongetNumber()that takes an upper case letter and returns thenumber according to the international standard above.Write a test program that prompts the user to enter a phone number as a string.The input number may contain letters. The program translates a letter (uppercaseor lowercase) to a digit and leaves all other characters intact.Here are sample runs of the program:Enter a string: 1-800- Flowers1 -800 -3569377Enter a string: 1800 flower

User Nitika
by
4.7k points

1 Answer

4 votes

Answer / Explanation:

To properly answer this question, we will utilize the python programming language.

The Python programming language is a general purpose and high level programming language. You can use Python for developing desktop GUI applications, websites and web applications. Also, it allows you to focus on core functionality of the application by taking care of common programming tasks.

Now, moving forward to write the program, we have:

def string_test(s):

d={"UPPER_CASE":0, "LOWER_CASE":0}

for c in s:

if c.isupper():

d["UPPER_CASE"]+=1

elif c.islower():

d["LOWER_CASE"]+=1

else:

pass

print ("Original String : ", s)

print ("No. of Upper case characters : ", d["UPPER_CASE"])

print ("No. of Lower case Characters : ", d["LOWER_CASE"])

string_test('Enter Phone Number')

User Matt Price
by
5.8k points