0 Members and 1 Guest are viewing this topic.

>>> print('hello')hello

>>> print(variable1)23

>>> print('hello', variable1)('hello', '23')

a=(1,2,3,4,5)print aprint a[1]a[1]=9

a=[1,2,3,4,5]print aprint a[1]a[1]=9

#Add an additional digit to a tuple;a=(1,2,3)a+4 # will not worka+(4) # will not worka+(4,) , will work and yields (1,2,3,4)

a=('a','b','c')"-".join(a)

def factorial(n): return 1 if n==1 else n*factorial(n-1)

int factorial(int n) { return n==1 ? n : n*factorial(n-1); }

1. uh it finds the factorial which is what you get if you multiply every number up to and including the number in question.2. Wasn't really sure what you were aiming for. Recursive function? Integer function?3. fact.factorial(-3) OR fact.factorial(9.3) blah blah blah blah ... RuntimeError: maximum recursion depth exceeded.4. (AHH one thing at a time! :p) *googles* *looks extremely confused*UHHH, given I know nothing about this topic and when I tried google I found impenetrable things I hereby declare that if you void all rights to laugh at me if this is completely wrong.int factorial(int n){ if (n == 1) return 1 else return 1 * factorial(n-1)}

int FAC (int iIn){ if ((iIn == 0) || (iIn == 1)) return 1; else if (iIn == 2) return 2; else if (iIn == 3) return 6; else if (iIn == 4) return 24; else if (iIn == 5) return 120;/* etc. */