Created
May 5, 2014 20:49
-
-
Save gregz67/1c9b3ba8ecc63ce9f00c to your computer and use it in GitHub Desktop.
Programming Club functions challenge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'gregz' | |
| # Crazy Name generator | |
| # Write a function that takes two words and a number as parameters and | |
| # outputs them all put together (called concatenated) with the following rules: | |
| # 1. Capitalize the first letter of each word | |
| # 2. Use a dictionary to translate: | |
| # a -> @ | |
| # i -> ! | |
| # o -> 0 | |
| # s -> $ | |
| # Test your function by calling it by asking the user to input: | |
| # 1. What is one word that describes you? | |
| # 2. What is your favorite food? | |
| # 3. What is your lucky number? | |
| # Bonus: Modify your Minecraft dictionary program to create a login name for a | |
| # new user by calling your new crazy name generator | |
| def crazy_name(word1, word2, num): | |
| translations = { | |
| 'a': '@', | |
| 'i': '!', | |
| 'o': '0', | |
| 's': '$' | |
| } | |
| name = word1.capitalize() + word2.capitalize() + str(num) | |
| translated_name = '' | |
| for letter in name: | |
| if letter in translations: | |
| translated_name += translations[letter] | |
| else: | |
| translated_name += letter | |
| return translated_name | |
| print('Your new name is: ' + | |
| crazy_name( | |
| input('What is one word that describes you? '), | |
| input('What is your favorite food? '), | |
| input('What is your lucky number? ') | |
| )) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment