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
| def recursive(n): | |
| if n == 0: | |
| return 0 | |
| elif n == 1: | |
| return 1 | |
| else : | |
| return n * recursive(n-1) | |
| print(recursive(5)) |
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
| def reverseStr(s): | |
| print(s[::-1]) | |
| x = input("Write a word to reverse : ") | |
| reverseStr(x.lower()) |
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
| #Prints even characters | |
| def printEven(text): | |
| result = "" | |
| for i in range(len(text)): | |
| if i%2==0: | |
| result = result + text[i] | |
| return result | |
| #Prints Odd characters | |
| def printOdd(text): |
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
| def remove_duplicate(text): | |
| # container to receive unique values from text | |
| allowed_string = [] | |
| # # | |
| # this loop adds character to the allowed_string array | |
| # only if it is unique | |
| # # |
NewerOlder