Python Programming | FaceBook Status turned into a Recursive Statement

By corib3ar On 17 Jul, 2012 At 04:51 PM | Categorized As Learning Center, Programming | With 0 Comment

Source code for the aspiring Python Programmer. Python Programming tutorials to help you understand programming languages.

I was lamenting (which I obviously do a lot) about stuff and wrote a facebook status – written below. One of my friends mentioned that it was a recurrence relation that should be tested which I immediately took as a challenge and coded it. This was what I needed after struggling to understand Java syntax which is something I find to be an extreme opposite of Python.
Status:
Completely lost trying to program because I have to miss class because I have to go to work because I have to make money because I have to pay for college because I have to pay for class that I have to miss because I have to go to work because I have to make money because I have to pay for college because I have to pay for class that I have to miss because I have to go to work because I….need a vacation….

def func (var):
if var == "I have to miss class":
return 1
if var == "I have to go to work":
return 2
if var == "I have to make money":
return 3
if var == "I have to pay for college":
return 4
if var == "I have to pay for class":
return 5

def status(variable):
if variable == 5:
return 1
else:
return (variable + 1)

def twice(var):
if var == 1:
return "I have to miss class"
if var == 2:
return "I have to go to work"
if var == 3:
return "I have to make money"
if var == 4:
return "I have to pay for college"
if var == 5:
return "I have to pay for class"

def main():
variable = 1
while 1>0:
variable = input("Completely lost in programming because ")
because = func(variable)
recur = status(because)
reverse = twice(recur)
print(variable, "because", reverse)

main()

Related posts:

About - Blogger, Programmer, Zombie Survivalist Expert, Girl Gamer, Pianist, Super Geek, the Epitome of Awesome. Saying the things your mind tells you not to.

Leave a comment

You must be Logged in to post comment.