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

Python Programming: Variables, Basic Operations and String manipulate

មូលសង្ខេប / Abstract

This document is a brief summary of a Python lesson on variables, basic operations, and string manipulation. It covers how variables store data and their types (int, float, str, bool, list, tuple, dict, set, None), the five basic operation categories (arithmetic, assignment, comparison, logical, membership), and common string methods like concatenation, formatting, slicing, and splitting.

ពាក្យគន្លឹះ
Variables, Basic Operations, and String Manipulation in Python

      This lesson covered the basics of how Python stores and works with data, starting with variables. A variable is basically a container that holds a piece of information so you can use it later in your program. Every variable has a name, a value, and a type, and in Python you create one simply by writing a name, an equals sign, and a value, like x = 42. One thing worth remembering is that Python is case-sensitive, so myVar and myvar are treated as two completely different variables, and variable names are also not allowed to start with a number.
     Python doesn't make you declare what type a variable is — it figures that out automatically
based on the value you give it. The lesson introduced several common types: integers for whole numbers, floats for decimal numbers, strings for text, and booleans for True/False values. It also covered more complex types used to group data together, such as lists (which can be changed after creation), tuples (which cannot be changed), dictionaries (which store information in keyvalue pairs), sets (which only keep unique values), and finally NoneType, which just represents an empty or missing value.
     After variables, the lesson moved into basic operations, which are the actions you can perform using those variables. Arithmetic operations handle math, including addition, subtraction, multiplication, division, floor division (which rounds down), modulus (which gives the remainder), and exponentiation (raising a number to a power). Assignment operations are used to store or update values, including shortcuts like += that let you update a variable without retyping it. Comparison operations check how two values relate to each other, returning either True or False, such as checking equality or whether one number is bigger than another. Logical operations combine multiple conditions using and, or, and not, which are especially useful for decision-making in code. Lastly, membership operations check whether a certain value exists inside a list or sequence using in and not in.
     The final part of the lesson focused specifically on string manipulation, since text is one of the most commonly used data types in programming. This included joining strings together
(concatenation), inserting variables directly into text using formatted strings, and finding the length of a string with the len() function. It also covered how to access individual characters using their position number, how to slice out a portion of a string, and how to convert text between uppercase and lowercase. Other useful string techniques included removing extra spaces with .strip(), replacing specific words using .replace(), checking if a certain word exists inside a string, and splitting a sentence into a list of individual words.
     Overall, this lesson built a solid foundation for working with data in Python. Understanding how variables store information and how these basic operations manipulate that information is essential before moving on to more advanced programming concepts like loops, functions, and conditional statements.
Python Lesson Summary.pdf
PDF ឯកសារ
ទាញយក អាន
ចែករំលែក 4
រក្សាទុក
link: 3 telegram: 1
ការផ្សព្វផ្សាយ
ការផ្សព្វផ្សាយ
មតិយោបល់ 0
ចូលគណនី ដើម្បីបញ្ចេញមតិ