readmes yo
This commit is contained in:
parent
40c5e73f28
commit
bfe83636ef
@ -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.
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user