CSCI-UA.2 - Introduction to Programming (Python) - Department of Computer Science, New York University


General Review Problems - Python

  1. Given a single word, print it backwards. (For discussion: How many ways can you do that?)
  2. Your program requests a list of names as user input and prints the list in reverse alphabetical order.
  3. Your program takes a list of numbers as input and prints the average.
  4. Your program prompts the user for a series of numbers (or they are randomly generated as you prefer.) Your function receives that list as an argument and returns a new list which contains the squares of all of the respective numbers in the first list. (For example, if list1[3] has a value of 2, then list2[3] should have a value of 4.)
  5. Your program requests a list of words as input and prints out the list in the order they were given, but your program uses a function to print every individual word spelled backwards.
  6. Your function receives a date in the format mm/dd/yyyy (e.g. 05/08/2013) and returns a the date spelled out (e.g. May 8, 2013)
  7. Your program requests the user to input his/her entire name (e.g. Samuel Langhorne Clemens) and a function prints out only the initials (e.g. S.L.C.)
  8. Your program requests the user to input a word; then "encrypts" the word by using a scrambled alphabet to repeat the word. Finally the program decrypts the word by spelling it corectly. Use functions to encrypt and decrypt the input.
  9. Generating a lottery number: Your program should randomly generate 7 numbers from 0-9 and then randomly assign each number to a list element to create a random lottery number which is seven digits long.
  10. Morse code: Using Wikipedia's chart for Morse code at http://en.wikipedia.org/wiki/Morse_code, write a program to prompt the user for a sentence and then print it out in Morse code.

Please see your instructor with any questions and for solutions.