Variables & Data TypesVariables.
មូលសង្ខេប / Abstract
This text provides a foundational overview of core Python programming concepts, structured into three main areas:
Variables & Data Types: Covers the rules for case-sensitive variable naming, Python's dynamic typing system, and the distinction between primitive types (integers, floats, strings, booleans, and NoneType) and collection types (lists, tuples, dictionaries, and sets).
Basic Operations: Outlines the operators used for arithmetic calculations, variable assignment, value comparisons, logical evaluations, and sequence membership checking.
String Manipulation: Details essential text-processing techniques, including concatenation, f-string formatting, length retrieval, indexing, slicing, case conversion, and utility methods for cleaning, replacing, and splitting strings.
ពាក្យគន្លឹះ
1. Variables & Data TypesVariables: Containers for storing data, created using the assignment operator (=). Variable names are case-sensitive (e.g., myVar $\neq$ myvar) and cannot start with a number.Dynamic Typing: Python automatically infers the data type based on the assigned value.Primitive Types:int: Whole numbers (e.g., 42)float: Decimal numbers (e.g., 3.14)str: Text wrapped in quotesbool: Truth values (True / False)NoneType: Represents a null, missing, or empty value (None)Collection Types:list: Mutable (changeable) ordered sequencetuple: Immutable (unchangeable) ordered sequencedict: Key-value pairsset: Unordered collection of unique items2. Basic OperationsCategoryPurpose & ExamplesArithmeticMath calculations: addition (+), subtraction (-), multiplication (*), division (/), floor division (//), modulus (%), exponentiation (**).AssignmentStoring or updating values: basic (=) or shorthand updates (+=, -=, *=).ComparisonComparing values (returns True/False): equality (==), inequality (!=), strictly greater/less than (>, <).LogicalCombining boolean conditions: and, or, not.MembershipChecking existence inside sequences: in, not in.3. String ManipulationConcatenation & Formatting: Joining strings (+) and inserting variables using f-strings.Length: Retreiving character count using len().Indexing & Slicing: Accessing individual characters by position or extracting substrings.Case Conversion: Converting text via .upper() and .lower().Clean-up & Splitting:.strip() to remove leading/trailing whitespace..replace(old, new) to substitute substrings..split() to break a string into a list of words.
ការផ្សព្វផ្សាយ
មតិយោបល់ 0