PYTHON

PYTHON

Create a folder that identifies you and Assignment 2 such as smith_asst2 or asst2_jones. Save all Python programs to this folder. Zip the folder. No .rar files allowed. Upload the zip to the Assignment 2 drop box.

 

1.    Alphabetic Telephone Number Translator

 

 

Many companies use telephone numbers like 555-GET-FOOD so the number is easier for their customers to remember.  On a standard telephone, the alphabetic letters are mapped to numbers in the following fashion.

A, B and C = 2

D, E, and F = 3

G, H, and I = 4

J, K, and L = 5

M, N, and O= 6

P, Q, R, and S = 7

T, U, and V = 8

W, X, Y, and Z = 9

Write a program that asks the user to enter a 10-character telephone number in the format xxx-xxx-xxxx. The application should display the telephone number with any alphabetic characters that appeared in the original translated to their numeric equivalent. For example, if the user enter 555-GET-FOOD the application should display 555-438-3663

 

 

1.     Word separator

Write a program that accepts as input a sentence in which all of the words are run together but the first character of each word is uppercase. Convert the sentence to a string in which the words are separated by space and only the first word starts with an uppercase letter. For example the string “ StopAndSmellTherRoses.” Would be converted to “Stop and smell the roses.”

 

2.    Pig Latin

Write a program that accepts a sentence as input and converts each word to “Pig Latin.” In one version, to convert a word to Pig Latin you remove the first letter and place that letter at the end of the word. Then you append the string ”ay” to the word. Here is an example:

 

English:      I SLEPT MOST OF THE NIGHT

Pig Latin:   IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY

 

 

 

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply