メインコンテンツにスキップ

Cookieの設定

このサイトは、ウェブサイトの基本的な機能を確保し、ユーザーのオンライン体験を向上させるためにクッキーを使用しています。 Cookieの使用を設定および承認したり、同意オプションを変更することはいつでもできます。

必須

設定

分析と統計

マーケティング

Django Preview.

Over the past week with my Django task, I find it necessary to go on with Python classes and functions review before exploring Django.

Prerequisite: Python Refresher (3-7 Days)

  1. Functions:

    • Practice: Write a function that calculates factorial or filters lists.

    • Resource: Python Functions (W3Schools).

      • Solution Factorial:

        # A function that calculates factorials or filters lists.

        def factorial(n):

        if n < 0:

        return "Factorial is not defined for negative numbers."

        elif n == 0 or n == 1:

        return 1

        else:

        result = 1

        for i in range(2, n + 1):

        result *= i

        return result

        # Example usage:

        print(factorial(5)) # Output: 120

        print(factorial(0)) # Output: 1

        print(factorial(-3)) # Output: "Factorial is not defined for negative numbers."

      • OUTPUT:
        return factorial(data)

        NameError: name 'factorial' is not defined

        >>> %Run 'factorial(n).py'

        120

        1

        Factorial is not defined for negative numbers.

  2. OOP:

    • Build a Student class with attributes (name, grade) and methods (update_grade).

    • Watch:

I have installed Django on my local machine and am beginning to explore the MVC implementation.

コメント

確定

ログインしてください

パスワードが短すぎます。

共有