From bfe83636ef4f82db6af1c58a6c5b79c4d32a4c46 Mon Sep 17 00:00:00 2001 From: Armen Vartan Date: Tue, 2 Dec 2014 16:34:40 -0500 Subject: [PATCH] readmes yo --- python/11-factorial/README.md | 10 ++++------ python/12-is-palindrome/README.md | 17 +++++++---------- python/12-is-palindrome/palindrome.py | 8 +++----- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/python/11-factorial/README.md b/python/11-factorial/README.md index f9b0a31..46aebab 100644 --- a/python/11-factorial/README.md +++ b/python/11-factorial/README.md @@ -3,17 +3,15 @@ Factorial! Get the factorial of a given number. Using sys.argv, pass in a number and return it's factorial. -To calculate the factorial of 5, for example, the equation is: +To calculate the factorial of 5, for example, the equation is ```5 * 4 * 3 * 2 * 1 = 120``` - 5 * 4 * 3 * 2 * 1 ###120 - -###Iterative +#### Iterative Write the equation iteratively, using a for or while loop. How to use loops in Python is well documented [here](https://docs.python.org/3.4/tutorial/controlflow.html) -###Recursive +#### Bonus -Now write this function recursively. If you run into difficulty, think about how your stack will develop as your function recurses and remember to define your base case. +Write this function [recursively](http://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python_3/Recursion). If you run into difficulty, think about how your stack will develop as your function recurses and remember to define your base case. Write assert statements to test your code in both cases. diff --git a/python/12-is-palindrome/README.md b/python/12-is-palindrome/README.md index 1b1a85c..aee1a71 100644 --- a/python/12-is-palindrome/README.md +++ b/python/12-is-palindrome/README.md @@ -1,16 +1,13 @@ Sarah Palindrome -============ +================ -Write a function that when given a word or sentence returns True if it is a palindrome and False if it isn't. +Write a function that when given a word or sentence returns True if it is a palindrome and False if it isn't. Your program should accept input using sys.argv. - - python3 palindrome.py Taco Cat ###returns true - -###OOP - -Let's make sure this program adheres to good object oriented design. Your main function should ONLY check if it is a palindrome and return True or False. Any other functions you might need, like string operations - should be seperated. Every function should do only one thing. - +``` +python3 palindrome.py Taco Cat # returns true +``` +You will want to make this case insensitive (Cat == cat). You can do this by make all letters upper or lower case. +You will also want to use strip to remove all non word characters. Make the asserts pass and write more assert statements to test your code. - diff --git a/python/12-is-palindrome/palindrome.py b/python/12-is-palindrome/palindrome.py index 43471b0..88305d3 100644 --- a/python/12-is-palindrome/palindrome.py +++ b/python/12-is-palindrome/palindrome.py @@ -2,13 +2,11 @@ import sys def is_palindrome(string): pass - ##this function should only check validity of the string, and rely on other functions for string operations -#assert statements +#TESTS -assert(is_palindrome('greg is the man') == False), "Presumably random sentence should return false" - -assert(is_palindrome('No Mel Gibson is a casino’s big lemon') == True), "Palindrome should return true" +assert(is_palindrome("greg is the man") == False), "Presumably random sentence should return false" +assert(is_palindrome("No Mel Gibson is a casino's big lemon") == True), "Palindrome should return true"