示例#1
0
def factorial(num):
    # Every recursive function must contain a condition
    # when it ceases to call itself
    if num <= 1:
        return 1
    else:

        result = num * factorial(num - 1)
        return result
示例#2
0
    # when it ceases to call itself
    if num <= 1:
        return 1
    else:

        result = num * factorial(num - 1)
        return result


# 1st : result = 4 * factorial(3) = 4 * 6 = 24
# 2nd : result = 3 * factorial(2) = 3 * 2 = 6
# 3rd : result = 2 * factorial(1) = 2 * 1 = 2

# ——— MODULES ———
import myfunc
print(myfunc.factorial(4))

# OR

from myfunc import factorial
print(factorial(4))

# ——— GUI DEVELOPMENT WITH TKINTER ———

from tkinter import *
from tkinter import ttk


class Calculator:

    # Stores the current value to display in the entry