Python Test 1c

You have until test end time (see below) to submit as many answers as you can.
Put your code files if more than one into a .zip and submit to judge with USB drive.

Naming and other rules:

  • the ZIP should be named <your first name>_1c.zip
  • the solution files in the ZIP should be named <Q#>.py
  • If your code uses outside files, name them <Q#>.txt
  • Submit code as zip copied to USB drive
  • Submissions must be made before 5:30pm
  • Turn on Airplane Mode after loading the test page, and turn it off ONLY to submit your work.
  • Do not use cheat sheets printed or otherwise. You should start up IDLE, open a new file, and start typing!

Really old phones looked like this:

Then phones looked like:

Then:

Eventually the mess we have today…

From even the rotary phones we always had letters assigned to numbers. But since there are 26 letters in English alphabet and only 10 digits we had to do some compression to make sure we can fit all/most letters – notice the difference in letter mapping from old to newer phone…

Today’s mobiles, if you look at keypads under phone app look a lot like that last image on a 25 year old Nokia.

Here is some examples in Singapore of how people use letters to publizise their numbers as mnemonics (things people can easily remember):

  • Examples of Singapore Vanity Phone Numbers
  • 1800-LAW-HELP (Legal Firm)
  • 1800-CLEANUP (Service Industry)
  • 1800-BIZHELP (Consultancy/Support)
  • 1800-DINE-OUT or 1800-FOOD (Restaurant/F&B)
  • 1800-FLOWERS (Retail)
  • 1800-CONTACTS (Retail/Health) [1, 2, 3, 4, 5]
  • 6-DENTAL (6336-825): Frequently used for localized business, such as clinics or F&B outlets.

We are going to write software that helps companies, stores, government agencies, and people come up with vanity listings like above. The basic function should be generic so as to make a long number like pi to 40 digits a sentence easy to remember…

Given a (+65) 8-digit phone number, or (1800-) 7 digit phone number, or any length of digits really, your code should spit out aphanumeric (can mix numbers and words) strings that exist in an english dictionary of words (like this one), to come up with cool mnemonic and vanity numbers that use english words and sentences to code the priginal number.

Q1. Basics

Write the main code which gets the user to enter their number.

Then write a skeleton function declaration for the function that will take the input and spit back a list of alphanumeric string options.

The main code should also take this list of strings and display them.

Make the function for now just return a list of hard-coded strings to make sure the skeleton code works.

Q2. Get Letters

We need a function, that given a number, will return the possible letters it can encode. For instance get_letters(1) should return empty string “” or list []. But get_letters(2) should return “ABC”, or [‘A’, ‘B’, ‘C’]

Q3. Make Words

Let’s try this with a few numbers only. Make a function that takes a 3-digit number and spits back all the 3-letter words you can find in english language from the provided dictionary.

Q4. Recursion

You don’t know necessarily how big the phone number is. Different people in different countries use different size phone numbers. Or they might only want to use part of their phone num ber like they already have some lucky part that doesnt need conversion 888_____. So you want to make your combo-making function recursive so that it can return words for any size phone number.

Q5. Make Vanity Sentences

The phone number can be broken up into words especially if there are 0’s which translate to space… But also in between sections like 2 4-letter words in common (+65) numbers or 3 and 4 letter words in 1800 numbers. Give the user a way to enter different cut ups of their number, and spit out sentences made up of possible word combinations.