The Code Fix

🐍 شرح Python

النصوص (Strings)

إنشاء نص

text = "تعلّم البرمجة"
text2 = 'بايثون رائعة'

يمكن استخدام علامتي تنصيص مفردة أو مزدوجة — لا فرق.

دمج النصوص

first = "The"
second = "Code Fix"
full = first + " " + second
print(full)   # The Code Fix

دوال مفيدة على النصوص

text = "Python"
print(len(text))        # 6  (الطول)
print(text.upper())     # PYTHON
print(text.lower())     # python
print(text.replace("P", "J"))  # Jython

التقطيع (Slicing)

نأخذ جزءًا من النص بالفهارس (تبدأ من 0):

word = "Programming"
print(word[0])    # P  (أول حرف)
print(word[0:4])  # Prog  (من 0 إلى ما قبل 4)
print(word[-1])   # g  (آخر حرف)

التحقّق من المحتوى

email = "test@mail.com"
print("@" in email)        # True
print(email.startswith("test"))  # True

🎯 التالي: الشروط واتخاذ القرارات.