លំហសិក្សាកម្ពុជា លំហសិក្សាកម្ពុជា V1.0
ចូល ចុះឈ្មោះ

Python summary note

 Python Study Notes

By MoeunRithi Sreylompong

🔹 Variables

  • Store data values in memory.

  • Defined by: name, value, type, scope, mutability.

  • Created with = operator.

  • Python is dynamically typed → type inferred automatically.

  • Common types:

    • int → whole numbers

    • float → decimals

    • str → text

    • bool → True/False

    • list → [1,2,3] (mutable)

    • tuple → (1,2,3) (immutable)

    • dict → {"key":"value"}

    • set → {1,2,3}

🔹 Basic Operations

  • Arithmetic: + - * / // % **

  • Assignment: = += -= *= /=

  • Comparison: == != > < >= <=

  • Logical: and or not

  • Membership: in, not in

🔹 Strings

  • Concatenation: "Hello" + "World" → "HelloWorld"

  • f‑strings: f"My name is {name}"

  • Length: len("Python") → 6

  • Indexing & slicing:
    python
    text = "Python"

text[0]     # "P"

text[0:3]   # "Pyt"

text[::-1]  # "nohtyP"

  • Methods:

    • "hello".upper() → "HELLO"

    • "HELLO".lower() → "hello"

    • " hi ".strip() → "hi"

    • "Java".replace("Java","Python") → "Python"

  • Splitting: "This is a sentence".split() → ['This','is','a','sentence']


blockchain.pdf
PDF ឯកសារ
ទាញយក អាន
ចែករំលែក
រក្សាទុក
ការផ្សព្វផ្សាយ
ការផ្សព្វផ្សាយ
មតិយោបល់ 0
ចូលគណនី ដើម្បីបញ្ចេញមតិ