fa
Feedback
Python3 Programming 💡

Python3 Programming 💡

رفتن به کانال در Telegram

كل ما يخص البرمجة بلغة python : -كورسات -مشاريع -ادوات -..الخ

نمایش بیشتر
691
مشترکین
اطلاعاتی وجود ندارد24 ساعت
-17 روز
-930 روز
آرشیو پست ها
السلام عليكم ورحمه الله وبركاته معليش توقفنا لفترة من اليوم ان شاءالله نواصل كورس بايثون :)

شباب كيف حالكم ان شاءالله بخير اليوم نتكلم عن مواضوع مهم جدا جدا ❕❕❕ حظر واتساب 💔🥲 المشكلة مؤثرة على معظم الاجهزة ومعظم الناس.. وللاسف الحل معقد جدا غالبا م يتم حل المشكلة ويكون المستخدم زهج.. المهم الحظر ليه اسباب كثيرة جدا اولا في الفترة الاخيرة لاحظنا تواجد عدد كبير من عمليات الاحتيال و scams وغيرها وللاسف ناس كثيرة وقعت ضحيتها .. شركة واتساب تقوم بمعاينة اي رسالة. وعندها عدة تصنيفات للرسائل فاذا تم تصنيف رسالتك ك scam تقوم الشركة مباشرة بحظر حسابك .. طيب كيف يكون تصنيف رسالتك ك scam في الفترة الاخيرة ظهور بوتات ومواقع وتطبيقات تجعل المستخدم يقوم بمهام مقابل جوائز مالية ومن ضمن المهم ما يعرف بالاحالات طيب الروابط الي تقوم بنسخها وارسالها لكل متابعينك ليقومو بعمل احالات ليك معظم الروابط يتم تصنيفها في بعض التطبيقات كروابط خبية فيقوم الواتساب مباشرة بحظرك .. وفي انواع اخرى من الرسائل الخبيثة ممكن في شكل صور او فيدو او غيره فرجاء ابتعدو منها لعدم التضرر وغالبا يقومو صاحب الرباط باختراق حسابك والاسواء انه يقوم بالنصب عليك❕❕ حاولو تجنب هذه الأشياء بالءات في تطبيق واتساب :)

##### Other escape characters: - \' for a single quote. - \\ for a backslash. - \n for a new line. - \t for a tab. --- #### Python - String Methods ##### String Methods Python has a set of built-in methods that you can use on strings. ##### Some of these methods: - capitalize(): Converts the first character to upper case. - lower(): Converts a string into lower case. - replace(): Replaces a specified value with another value in the string. - split(): Splits the string into a list, based on a specified separator. - strip(): Removes whitespace from the beginning and the end. :)

Python3 Programming #post_10 #### Python - تنسيق السلاسل النصية (Strings) ##### تنسيق السلسلة النصية كما تعلمنا في فصل متغيرات بايثون، لا يمكننا دمج النصوص مع الأرقام بهذه الطريقة:
age = 36
txt = "اسمي جون، وعمري " + age
print(txt)
لكن يمكننا دمج النصوص مع الأرقام باستخدام f-strings أو باستخدام الطريقة format(). ##### F-Strings تم تقديم الـ F-Strings في بايثون 3.6، وأصبحت الآن الطريقة المفضلة لتنسيق السلاسل النصية. لتحديد سلسلة نصية كـ F-String، ضع حرف f قبل السلسلة النصية، واستخدم الأقواس {} كأماكن مخصصة للمتغيرات والعمليات الأخرى. ##### مثال: إنشاء F-String:
age = 36
txt = f"اسمي جون، وعمري {age}"
print(txt)
##### العناصر المخصصة والتعديلات يمكن أن يحتوي المكان المخصص على متغيرات أو عمليات أو دوال أو تعديلات لتنسيق القيمة. ##### مثال: إضافة مكان مخصص لمتغير السعر:
price = 59
txt = f"السعر هو {price} دولار"
print(txt)
يمكن أن يحتوي المكان المخصص على تعديل لتنسيق القيمة. يتم تضمين التعديل بإضافة نقطتين : متبوعًا بنوع التنسيق المناسب، مثل .2f الذي يعني رقم بنقطة عشرية ثابتة مع 2 منازل عشرية. ##### مثال: عرض السعر بمنزلتين عشريتين:
price = 59
txt = f"السعر هو {price:.2f} دولار"
print(txt)
##### يمكن أن يحتوي المكان المخصص على عمليات رياضية، مثل:
txt = f"السعر هو {20 * 59} دولار"
print(txt)
##### تمرين: إذا كان x = 9، ما هو الصياغة الصحيحة لطباعة 'السعر هو 9.00 دولار'؟
print(f'السعر هو {x:.2f} دولار')
--- #### Python - حروف الهروب (Escape Characters) ##### حروف الهروب لاستخدام أحرف غير قانونية في سلسلة نصية، نستخدم حرف الهروب \. ##### مثال:
txt = "نحن المسمى \"Vikings\" من الشمال."
##### أحرف الهروب الأخرى: - \' لعلامة الاقتباس الفردية. - \\ للشرطة المائلة العكسية. - \n لسطر جديد. - \t لعلامة التبويب. --- #### Python - الدوال المدمجة للسلاسل النصية (String Methods) ##### دوال السلاسل النصية بايثون تحتوي على مجموعة من الدوال المدمجة التي يمكنك استخدامها مع السلاسل النصية. ##### بعض هذه الدوال: - capitalize(): يحول الحرف الأول إلى حرف كبير. - lower(): يحول النص إلى أحرف صغيرة. - replace(): يستبدل قيمة معينة بأخرى في السلسلة النصية. - split(): يقسم السلسلة إلى قائمة بناءً على محدد معين. - strip(): يزيل الفراغات من البداية والنهاية. --- #### Python - Format - Strings ##### String Format As we learned in the Python Variables chapter, we cannot combine strings and numbers like this:
age = 36
txt = "My name is John, I am " + age
print(txt)
But we can combine strings and numbers by using f-strings or the format() method. ##### F-Strings F-String was introduced in Python 3.6, and is now the preferred way of formatting strings. To specify a string as an f-string, simply put an f in front of the string literal, and use curly brackets {} as placeholders for variables and other operations. ##### Example: Create an f-string:
age = 36
txt = f"My name is John, I am {age}"
print(txt)
##### Placeholders and Modifiers A placeholder can contain variables, operations, functions, and modifiers to format the value. ##### Example: Add a placeholder for the price variable:
price = 59
txt = f"The price is {price} dollars"
print(txt)
A placeholder can include a modifier to format the value. A modifier is included by adding a colon : followed by a legal formatting type, like .2f which means fixed-point number with 2 decimals. ##### Example: Display the price with 2 decimals:
price = 59
txt = f"The price is {price:.2f} dollars"
print(txt)
A placeholder can contain Python code, like math operations:
txt = f"The price is {20 * 59} dollars"
print(txt)
##### Exercise: If x = 9, what is the correct syntax to print 'The price is 9.00 dollars'?
print(f'The price is {x:.2f} dollars')
--- #### Python - Escape Characters ##### Escape Character To insert characters that are illegal in a string, use an escape character. ##### Example:
txt = "We are the so-called \"Vikings\" from the north."

#### الفهرسة السلبية يمكنك أيضًا استخدام **الفهرسة السلبية لبدء التقطيع من نهاية النص. الفهارس السلبية تعد بالعكس من نهاية النص. ##### مثال: لإرجاع الأحرف من الفهرس -5 إلى -2 (غير شامل):
b = "Hello, World!"
print(b[-5:-2])  # النتيجة: "orl"
--- #### تمرين: ما هي النتيجة المتوقعة من الكود التالي؟
x = 'Welcome'
print(x[3:5])
الخيارات: - lcome - come - com - co --- ### Python - تعديل النصوص تقدم بايثون عدة طرق مدمجة لتعديل النصوص. دعونا نستكشف بعض الطرق الأكثر استخدامًا: #### الأحرف الكبيرة تقوم دالة upper() بتحويل جميع الأحرف في النص إلى أحرف كبيرة. ##### مثال:
a = "Hello, World!"
print(a.upper())  # النتيجة: "HELLO, WORLD!"
--- #### الأحرف الصغيرة تقوم دالة lower() بتحويل جميع الأحرف في النص إلى أحرف صغيرة. ##### مثال:
a = "Hello, World!"
print(a.lower())  # النتيجة: "hello, world!"
--- #### إزالة المسافات تقوم دالة strip() بإزالة أي مسافات زائدة من بداية أو نهاية النص. ##### مثال:
a = " Hello, World! "
print(a.strip())  # النتيجة: "Hello, World!"
--- #### استبدال النص تقوم دالة replace() باستبدال جزء من النص بآخر. ##### مثال:
a = "Hello, World!"
print(a.replace("H", "J"))  # النتيجة: "Jello, World!"
--- #### تقسيم النص تقوم دالة split() بتقسيم النص إلى قائمة من النصوص الفرعية بناءً على فاصل محدد (في هذا المثال هو الفاصلة). ##### مثال:
a = "Hello, World!"
print(a.split(","))  # النتيجة: ['Hello', ' World!']
--- ### Python - دمج النصوص #### دمج النصوص لدمج (أو جمع) نصين، يمكنك استخدام عامل +. ##### مثال: دمج المتغير a مع المتغير b في المتغير c:
a = "Hello"
b = "World"
c = a + b
print(c)  # النتيجة: "HelloWorld"
##### مثال: لإضافة مسافة بين a و b، قم بإضافة مسافة بينهما:
a = "Hello"
b = "World"
c = a + " " + b
print(c)  # النتيجة: "Hello World"
--- #### تمرين: ما هو الصياغة الصحيحة لدمج المتغيرين x و y في z؟ - z = x, y - z = x = y - z = x + y :)

Python3 Programming #post_9 ### Python - Slicing Strings #### Slicing In Python, slicing allows you to extract a specific portion of a string by defining a range of indices. You can use the slice syntax, which involves specifying a start and end index, separated by a colon (:), to return part of the string. ##### Example: To get the characters from position 2 to position 5 (excluding 5): b = "Hello, World!" print(b[2:5]) # Output: "llo" Note: The first character has an index of 0. --- #### Slice From the Start If you leave out the start index, slicing will begin from the very first character in the string. ##### Example: To get the characters from the start up to position 5 (excluding 5): b = "Hello, World!" print(b[:5]) # Output: "Hello" --- #### Slice to the End If you leave out the end index, the slicing will continue to the end of the string. ##### Example: To get the characters from position 2 to the end: b = "Hello, World!" print(b[2:]) # Output: "llo, World!" --- #### Negative Indexing You can also use negative indexing to slice a string from the end. Negative indices count backward from the end of the string. ##### Example: Get the characters from position -5 to -2 (excluding -2): b = "Hello, World!" print(b[-5:-2]) # Output: "orl" --- #### Exercise: What will be the result of the following code? x = 'Welcome' print(x[3:5]) Options: - lcome - come - com - co --- ### Python - Modify Strings Python offers several built-in methods to modify strings. Let’s explore some of the most commonly used methods: #### Upper Case The upper() method converts all the characters in a string to uppercase. ##### Example: a = "Hello, World!" print(a.upper()) # Output: "HELLO, WORLD!" --- #### Lower Case The lower() method converts all the characters in a string to lowercase. ##### Example: a = "Hello, World!" print(a.lower()) # Output: "hello, world!" --- #### Remove Whitespace The strip() method removes any leading and trailing whitespace (spaces before and after the text). ##### Example: a = " Hello, World! " print(a.strip()) # Output: "Hello, World!" --- #### Replace String The replace() method replaces a part of the string with another string. ##### Example: a = "Hello, World!" print(a.replace("H", "J")) # Output: "Jello, World!" --- #### Split String The split() method splits a string into a list of substrings based on a specified separator (in this case, a comma). ##### Example: a = "Hello, World!" print(a.split(",")) # Output: ['Hello', ' World!'] --- ### Python - String Concatenation #### String Concatenation To concatenate (or combine) two strings, you can use the + operator. ##### Example: Merge variables a and b into variable c: a = "Hello" b = "World" c = a + b print(c) # Output: "HelloWorld" ##### Example: To add a space between a and b, include a space in between: a = "Hello" b = "World" c = a + " " + b print(c) # Output: "Hello World" --- #### Exercise: What is the correct syntax to merge variables x and y into z? - z = x, y - z = x = y - z = x + y --- ### النسخة العربية: Python - تقطيع النصوص #### التقطيع في بايثون، يمكنك استخدام التقطيع لاستخراج جزء محدد من النص عن طريق تحديد نطاق من الفهارس. يمكنك استخدام صيغة التقطيع، والتي تتضمن تحديد فهرس البداية وفهرس النهاية مفصولين بنقطتين (:) لإرجاع جزء من النص. ##### مثال: لإرجاع الأحرف من الفهرس 2 إلى 5 (غير شامل): b = "Hello, World!" print(b[2:5]) # النتيجة: "llo" ملحوظة: أول حرف في النص يحتوي على الفهرس 0. --- #### التقطيع من البداية إذا لم تحدد فهرس البداية**، فسيبدأ التقطيع من أول حرف في النص. ##### مثال: لإرجاع الأحرف من البداية حتى الفهرس 5 (غير شامل): b = "Hello, World!" print(b[:5]) # النتيجة: "Hello" --- #### التقطيع إلى النهاية إذا لم تحدد فهرس النهاية، فسيستمر التقطيع حتى نهاية النص. ##### مثال: لإرجاع الأحرف من الفهرس 2 حتى النهاية: b = "Hello, World!" print(b[2:]) # النتيجة: "llo, World!" ---

Python3 Programming #post_8 ### Python Strings (Beginner Guide) #### Strings in Python In Python, strings are sequences of characters enclosed in either single quotes (' ') or double quotes (" "). Both are valid and interchangeable. print("Hello") print('Hello') #### Quotes Inside Strings You can use quotes inside a string as long as they don't match the surrounding quotes. print("It's alright") print('He is called "Johnny"') #### Assigning Strings to Variables You can assign a string to a variable by using an equal sign (=): a = "Hello" print(a) #### Multiline Strings For strings spanning multiple lines, use triple quotes (""" or '''). a = """This is a multiline string example""" print(a) a = '''Another way to do a multiline string''' print(a) --- ### Strings as Arrays In Python, strings are arrays of characters. You can access individual characters using square brackets []. a = "Hello, World!" print(a[1]) # Outputs 'e' #### Looping Through Strings Since strings are arrays, you can iterate over them using a loop. for char in "banana": print(char) #### String Length To get the length of a string, use the len() function. a = "Hello, World!" print(len(a)) # Outputs 13 --- ### Checking Substrings You can check if a substring is present within a string using the in keyword. txt = "The best things in life are free!" print("free" in txt) # Outputs True You can also use this in an if statement: if "free" in txt: print("Yes, 'free' is present.") #### Check if NOT Present To check if a substring is not present, use not in: txt = "The best things in life are free!" print("expensive" not in txt) # Outputs True if "expensive" not in txt: print("No, 'expensive' is NOT present.") --- #### Exercise: What will be the output of the following code? x = 'Welcome' print(x[3]) The answer is c, because indexing starts at 0, so x[3] refers to the fourth character. --- ### السلاسل النصية في بايثون (دليل للمبتدئين) #### السلاسل النصية في بايثون في بايثون، السلاسل النصية هي تسلسل من الأحرف ويمكن كتابتها باستخدام علامات التنصيص الفردية (' ') أو علامات التنصيص المزدوجة (" ")**، وكلاهما صحيح.
print("مرحباً")
print('مرحباً')
#### علامات الاقتباس داخل السلاسل يمكنك استخدام علامات الاقتباس داخل السلسلة النصية طالما أنها لا تتطابق مع علامات الاقتباس المحيطة بالنص.
print("إنه بخير")
print('يُدعى "جوني"')
#### تعيين سلسلة نصية لمتغير لتعيين سلسلة نصية لمتغير، نستخدم علامة المساواة (=):
a = "مرحباً"
print(a)
#### السلاسل متعددة الأسطر يمكنك كتابة سلسلة نصية متعددة الأسطر باستخدام ثلاثة علامات اقتباس (""" أو ''').
a = """هذا مثال
على سلسلة نصية متعددة الأسطر"""
print(a)
```python a = '''طريقة أخرى لكتابة سلسلة نصية متعددة الأسطر''' print(a)
---

### السلاسل النصية كمصفوفات
في بايثون، السلاسل النصية هي مصفوفات من الأحرف. يمكنك الوصول إلى كل حرف باستخدام الأقواس المربعة `[]`.
python a = "مرحباً، أيها العالم!" print(a[1]) # يظهر 'ر'
#### التكرار عبر السلاسل النصية
بما أن السلاسل النصية هي مصفوفات، يمكنك التكرار عبرها باستخدام حلقة `for`.
python for char in "موز": print(char)
#### طول السلسلة النصية
للحصول على طول سلسلة نصية، استخدم دالة `len()`.
python a = "مرحباً، أيها العالم!" print(len(a)) # يظهر 13
---

### التحقق من وجود سلسلة فرعية
يمكنك التحقق مما إذا كانت سلسلة فرعية موجودة داخل سلسلة نصية باستخدام الكلمة المفتاحية `in`.
python txt = "أفضل الأشياء في الحياة مجانية!" print("مجانية" in txt) # يظهر True
يمكنك أيضًا استخدامه داخل جملة `if`:
python if "مجانية" in txt: print("نعم، 'مجانية' موجودة.") ` #### التحقق من عدم الوجود للتحقق مما إذا كانت سلسلة فرعية **غير موجودة، استخدم not in: txt = "أفضل الأشياء في الحياة مجانية!" print("مكلفة" not in txt) # يظهر True if "مكلفة" not in txt: print("لا، 'مكلفة' ليست موجودة.") --- #### تمرين: ما هو ناتج الكود التالي؟ x = 'أهلاً' print(x[3]) الجواب هو 'اً' لأن الترقيم يبدأ من 0، وبالتالي x[3] يشير إلى الحرف الرابع. :)

Python3 Programming #post_7 ### تحويل البيانات في بايثون (Python Casting) #### تحديد نوع المتغير في بعض الأحيان، قد ترغب في تحديد نوع معين لمتغير. يمكن القيام بذلك باستخدام التحويل. بايثون هي لغة موجهة للكائنات، وبالتالي تستخدم الفئات (Classes) لتعريف أنواع البيانات، بما في ذلك أنواعها الأساسية. يتم تنفيذ التحويل في بايثون باستخدام دوال الإنشاء (Constructor Functions) التالية: - **int()** - تقوم بإنشاء عدد صحيح (Integer) من قيمة صحيحة، أو عدد عشري (مع إزالة الأجزاء العشرية)، أو من سلسلة نصية بشرط أن تمثل السلسلة عددًا صحيحًا. - **float()** - تقوم بإنشاء عدد عشري (Float) من قيمة صحيحة أو سلسلة نصية بشرط أن تمثل السلسلة عددًا عشريًا أو عددًا صحstr()*str()** - تقوم بإنشاء سلسلة نصية (String) من مجموعة واسعة من أنواع البيانات مثل النصوص، الأعداد الصحيحة، والأعداد العشرية. #### الأعداد الصحيحة (Integers):gers):**
x = int(1)   # x سيكون 1
y = int(2.8) # y سيكون 2
z = int("3") # z سيكون 3
**الأعداد العشرية (Floats):**
x = float(1)     # x سيكون 1.0
y = float(2.8)   # y سيكون 2.8
z = float("3")   # z سيكون 3.0
w = float("4.2") # w سيكون 4.2
**السلاسل النصية (Strings):**
x = str("s1")  # x سيكون 's1'
y = str(2)     # y سيكون '2'
z = str(3.0)   # z سيكون '3.0'
#### تمرين: ما هي نتيجة الكود التالي؟
print(int(35.88))
- 35 - 35.88 -Python CastingPython Casting** #### Specify a Variable Type There may be times when you want to specify a particular type for a variable. This cacastingsing **casting**. Python is an object-oriented language, and as such, it uses classes to define data types, including its primitive types. Casting in Python is done using the following constructoint()ns: - **int()** - constructs an integer from an integer literal, a float literal (by removing all decimals), or a string literal (as long as the string represents a wfloat()). - **float()** - constructs a float from an integer literal, a float literal, or a string literal (as long as the string represents a float orstr()er). - **str()** - constructs a string from a wide range of data types, including strings, integer literals, and float literals. Integers:: **Integers:**
x = int(1)   # x will be 1
y = int(2.8) # y will be 2
z = int("3") # z will be 3
**Floats:**
x = float(1)     # x will be 1.0
y = float(2.8)   # y will be 2.8
z = float("3")   # z will be 3.0
w = float("4.2") # w will be 4.2
**Strings:**
x = str("s1")  # x will be 's1'
y = str(2)     # y will be '2'
z = str(3.0)   # z will be '3.0'
#### Exercise: What will be the result of the following code?
print(int(35.88))
- 35 - 35.88 - 36 :)

You can learn more about the random module in the Random Module Reference. ### Exercise: Which is NOT a legal numeric data type in Python? - int - long - float > Note: In modern Python versions, the long data type no longer exists and has been merged with int. :)

Python3 Programming #post_6 #### شرح للمبتدئين حول تحديد نوع البيانات في بايثون (Setting the Specific Data Type) في بايثون، يمكنك تحديد نوع البيانات باستخدام دوال الإنشاء (Constructor Functions) المخصصة لكل نوع. إليك بعض الأمثلة التي توضح كيفية تحديد أنواع البيانات المختلفة: | المثال | نوع البيانات | التوضيح | |--------|--------------|---------| | x = str("Hello World") | str (سلسلة نصية) | يتم تعيين "Hello World" كنص. | | x = int(20) | int (عدد صحيح) | يتم تعيين 20 كعدد صحيح. | | x = float(20.5) | float (عدد عشري) | يتم تعيين 20.5 كعدد عشري. | | x = complex(1j) | complex (عدد مركب) | يتم تعيين العدد المركب 1j. | | x = list(("apple", "banana", "cherry")) | list (قائمة) | يتم تعيين قائمة تحتوي على "apple"، "banana"، "cherry". | | x = tuple(("apple", "banana", "cherry")) | tuple (قائمة ثابتة) | يتم تعيين قائمة ثابتة. | | x = range(6) | range (نطاق) | يتم تعيين نطاق من 0 إلى 5. | | x = dict(name="John", age=36) | dict (قاموس) | يتم تعيين قاموس يحتوي على اسم وعمر. | | x = set(("apple", "banana", "cherry")) | set (مجموعة) | يتم تعيين مجموعة غير مرتبة. | | x = frozenset(("apple", "banana", "cherry")) | frozenset (مجموعة ثابتة) | يتم تعيين مجموعة ثابتة غير مرتبة. | | x = bool(5) | bool (قيمة منطقية) | يتم تعيين قيمة منطقية بناءً على الرقم. | | x = bytes(5) | bytes (بايتات) | يتم تعيين تسلسل من البايتات بطول 5. | | x = bytearray(5) | bytearray (مصفوفة بايتات) | يتم تعيين مصفوفة من البايتات بطول 5. | | x = memoryview(bytes(5)) | memoryview (ذاكرة) | يتم إنشاء عرض للذاكرة من البايتات. | ### إنشاء أرقام عشوائية باستخدام وحدة random بايثون لا يحتوي على دالة مدمجة تسمى random() لإنشاء أرقام عشوائية، ولكن يمكنك استخدام وحدة مدمجة تسمى random لتوليد أرقام عشوائية. #### مثال: لإدخال وحدة random وعرض رقم عشوائي بين 1 و 9:
import random

print(random.randrange(1, 10))
يمكنك معرفة المزيد عن وحدة random في مرجع الوحدة. ### تمرين: ما هو النوع الرقمي الذي ليس نوع بيانات قانونيًا في بايثون؟ - int - long - float > ملاحظة: في إصدارات بايثون الحديثة، لم يعد هناك نوع بيانات باسم long، حيث تم دمجه مع int. --- #### Beginner's Guide to Setting Data Types in Python In Python, you can specify the data type by using the constructor functions. Here are some examples that show how to assign specific data types: | Example | Data Type | Explanation | |---------|-----------|-------------| | x = str("Hello World") | str (string) | Assigns "Hello World" as a string. | | x = int(20) | int (integer) | Assigns 20 as an integer. | | x = float(20.5) | float (decimal) | Assigns 20.5 as a decimal number. | | x = complex(1j) | complex (complex number) | Assigns the complex number 1j. | | x = list(("apple", "banana", "cherry")) | list (list) | Assigns a list containing "apple", "banana", "cherry". | | x = tuple(("apple", "banana", "cherry")) | tuple (tuple) | Assigns a tuple. | | x = range(6) | range (range) | Assigns a range from 0 to 5. | | x = dict(name="John", age=36) | dict (dictionary) | Assigns a dictionary with name and age. | | x = set(("apple", "banana", "cherry")) | set (set) | Assigns an unordered set. | | x = frozenset(("apple", "banana", "cherry")) | frozenset (frozen set) | Assigns an immutable set. | | x = bool(5) | bool (boolean) | Assigns a boolean value based on the number. | | x = bytes(5) | bytes (bytes) | Assigns a sequence of 5 bytes. | | x = bytearray(5) | bytearray (byte array) | Assigns a byte array of length 5. | | x = memoryview(bytes(5)) | memoryview (memory view) | Creates a memory view from bytes. | ### Generating Random Numbers Using the random Module Python does not have a built-in random() function to generate random numbers, but it has a built-in module called random that you can use to generate random numbers. #### Example: To import the random module and display a random number between 1 and 9:
import random

print(random.randrange(1, 10))

Python3 Programming #post_5 المتغيرات في بايثون (Python Variables)** #### تعيين قيم متعددة للمتغيرات يمكنك في بايثون تعيين قيم متعددة لعدة متغيرات في سطر واحد. مثال:
x, y, z = "Orange", "Banana", "Cherry"
print(x)
print(y)
print(z)
💡 ملاحظة: تأكد من أن عدد المتغيرات يتطابق مع عدد القيم، وإلا ستحدث مشكلة. #### تعيين نفس القيمة لمتغيرات متعددة يمكنك تعيين نفس القيمة لعدة متغيرات في سطر واحد. مثال:
x = y = z = "Orange"
print(x)
print(y)
print(z)
#### تفريغ مجموعة قيم (Unpacking a Collection) إذا كان لديك مجموعة من القيم في قائمة أو مجموعة (tuple)، يمكنك استخراج القيم إلى متغيرات باستخدام التفريغ. مثال:
fruits = ["apple", "banana", "cherry"]
x, y, z = fruits
print(x)
print(y)
print(z)
#### طباعة متغيرات متعددة يمكنك استخدام دالة print() لطباعة متغيرات متعددة مفصولة بفاصلة. مثال:
x = "Python"
y = "is"
z = "awesome"
print(x, y, z)
#### **استخدام عامل الجمع + لدمج المتغيرات** يمكنك أيضًا استخدام عامل الجمع + لدمج متغيرات نصيمثال:ل:**
x = "Python "
y = "is "
z = "awesome"
print(x + y + z)
ملاحظة:ة:** تأكد من وجود مسافة في نهاية السلسلة النصية إذا كنت تحتاج إلى فصل الكلمات، وإلا سيتم دمجها ككلمة واحدة (Pythonisawesome). #### **استخدام + مع الأرقام** بالنسبة للأرقام، يعمل عامل الجمع + كعامل مثال:*مثال:**
x = 5
y = 10
print(x + y)
#### **خلط النصوص مع الأرقام** عند محاولة دمج نص مع رقم باستخدام عامل الجمع +، ستحصمثال:. **مثال:**
x = 5
y = "John"
print(x + y)
أفضل طريقة لطباعة متغيرات من أنواع مختلفة هي استخدامثال:. **مثال:**
x = 5
y = "John"
print(x, y)
#### **استخدام المتغيرات العامة (global)** إذا كنت ترغب في تعديل متغير عام داخل دالة، استخدم الكلمة المفتاحية global. **مثال:**
x = "awesome"

def myfunc():
  global x
  x = "fantastic"

myfunc()

print("Python is " + x)
--- ### **Beginner's Guide: PAssign Multiple Values to Variablesle Values to Variables** Python allows you to assign values to multiple Example: one line. **Example:**
x, y, z = "Orange", "Banana", "Cherry"
print(x)
print(y)
print(z)
💡 **Note:** Make sure the number of variables matches the number of values, or yAssign the Same Value to Multiple Variablesalue to Multiple Variables** You can also assign the same value to multiExample:s in one line. **Example:**
x = y = z = "Orange"
print(x)
print(y)
print(z)
#### **Unpacking a Collection** If you have a collection (like a list or tuple), you can extract its values iExample:s using unpacking. **Example:**
fruits = ["apple", "banana", "cherry"]
x, y, z = fruits
print(x)
print(y)
print(z)
#### **Printing Multiple Variables** You can use the print() function to output multipExample:, separated by commas. **Example:**
x = "Python"
y = "is"
z = "awesome"
print(x, y, z)
#### **Using the + Operator to Concatenate Variables** You can use the + opeExample:catenate string variables. **Example:**
x = "Python "
y = "is "
z = "awesome"
print(x + y + z)
💡 **Note:** Be sure to include spaces after each word to avoid mUsing + for Numbersonisawesome"). #### **Using + for Numbers** For numbers, the + Example:ks as a mathematical operator. **Example:**
x = 5
y = 10
print(x + y)
#### **Mixing Strings and Numbers** If you try to combine a string and a number with the + operator, Python will give an error. **Example:**
x = 5
y = "John"
print(x + y)
The best way to output diffeExample:pes is by separating them with commas. **Example:**
x = 5
y = "John"
print(x, y)
#### **Using Global Variables** If you need to change a globExample:inside a function, use the global keyword. **Example:**
x = "awesome"

def myfunc():
  global x
  x = "fantastic"

myfunc()

print("Python is " + x)
:)

Python3 Programming #post_4 ### شرح للمبتدئين: التعليقات في بايثون (Python Comments) التعليقات في بايثون تُستخدم لشرح الكود. يمكن أن تساعد في جعل الكود أكثر قابلية للفهم أو لإيقاف تنفيذ الكود أثناء الاختبار. #### كيفية إنشاء تعليق في بايثون - تبدأ التعليقات في بايثون بالرمز #، وستتجاهل بايثون أي شيء بعده. مثال:
# هذا تعليق
print("Hello, World!")
- يمكن وضع التعليقات في نهاية السطر، وستتجاهل بايثون ما يأتي بعدها. مثال:
print("Hello, World!")  # هذا تعليق
#### تعطيل الكود باستخدام التعليقات - يمكنك استخدام التعليقات لمنع تنفيذ الكود. مثال:
#print("Hello, World!")
print("Cheers, Mate!")
#### التعليقات متعددة الأسطر - بايثون لا تحتوي على صيغة خاصة للتعليقات متعددة الأسطر. يمكنك إضافة # في بداية كل سطر للتعليق على أكثر من سطر. مثال:
# هذا تعليق
# مكتوب في عدة أسطر
print("Hello, World!")
- أو يمكنك استخدام النصوص متعددة الأسطر (ثلاثة علامات اقتباس) لكتابة تعليق طويل. مثال:
"""
هذا تعليق
مكتوب في
عدة أسطر
"""
print("Hello, World!")
### التعامل مع المتغيرات في بايثون - يمكن تعريف المتغيرات باستخدام علامات الاقتباس المفردة أو المزدوجة. مثال:
x = "John"  # هو نفس تعريف
x = 'John'
#### الحساسية لحالة الأحرف - أسماء المتغيرات حساسة لحالة الأحرف. مثال:
a = 4
A = "Sally"
# A لن تُعيد تعريف a
--- ### Beginner's Guide: Python Comments Comments in Python are used to explain code, making it easier to read or disabling code for testing purposes. #### Creating a Comment in Python - Comments in Python start with #, and Python will ignore the rest of the line. Example:
# This is a comment
print("Hello, World!")
- Comments can be placed at the end of a line. Example:
print("Hello, World!")  # This is a comment
#### Disabling Code with Comments - You can use comments to prevent Python from executing code. Example:
#print("Hello, World!")
print("Cheers, Mate!")
#### Multiline Comments - Python does not have a specific syntax for multiline comments. You can add # at the start of each line for multiple lines of comments. Example:
# This is a comment
# written in multiple lines
print("Hello, World!")
- Alternatively, you can use multiline strings (triple quotes) for long comments, which Python will ignore if not assigned to a variable. Example:
"""
This is a comment
written in multiple lines
"""
print("Hello, World!")
### Working with Variables in Python - Variables can be declared with single or double quotes. Example:
x = "John"  # Same as
x = 'John'
#### Case Sensitivity - Variable names are case-sensitive. Example:
a = 4
A = "Sally"
# A will not overwrite a
:)

Python3 Programming #post_3 ### شرح باللغتين العربية والإنجليزية للمبتدئين: المتغيرات والتعليقات في بايثون #### المتغيرات في بايثون (Python Variables) العربية: في بايثون، يتم إنشاء المتغيرات عندما تعين قيمة لها. يمكنك استخدام المتغيرات لتخزين البيانات واستخدامها لاحقًا في برنامجك. مثال:
x = 5
y = "Hello, World!"
بايثون لا يحتاج إلى أمر خاص لإعلان المتغير. ببساطة، عندما تعين قيمة لمتغير، يتم إنشاؤه تلقائيًا. في المثال أعلاه، x هو متغير عدد صحيح، و y هو متغير نصي. يمكنك معرفة المزيد عن المتغيرات في الفصل الخاص بالمتغيرات في بايثون. --- English: In Python, variables are created when you assign a value to them. You can use variables to store data and use it later in your program. Example:
x = 5
y = "Hello, World!"
Python does not require a specific command to declare a variable. Simply put, when you assign a value to a variable, it is created automatically. In the example above, x is an integer variable, and y is a string variable. You will learn more about variables in the Python Variables chapter. --- #### التعليقات في بايثون (Comments) العربية: تتيح لك بايثون استخدام التعليقات لتوثيق الكود داخل البرنامج. التعليقات تبدأ برمز #، وستعتبر بايثون باقي السطر تعليقًا ولن تنفذه. مثال:
# هذه تعليق.
print("Hello, World!")
في هذا المثال، السطر الذي يبدأ بـ # هو تعليق، وبالتالي لن يؤثر على تنفيذ البرنامج. --- English: Python allows you to use comments for in-code documentation. Comments start with a #, and Python will treat the rest of the line as a comment and will not execute it. Example:
# This is a comment.
print("Hello, World!")
In this example, the line that starts with # is a comment, so it will not affect the execution of the program. :)

Python3 Programming #post_2 ### شرح باللغتين العربية والإنجليزية للمبتدئين: بدء العمل مع بايثون (Python) #### تعلم الأساسيات مع Python ##### تنصيب بايثون (Python Install) العربية: إذا كنت تستخدم جهاز كمبيوتر يعمل بنظام Windows أو Mac، قد يكون بايثون مثبتًا مسبقًا. للتحقق مما إذا كان بايثون مثبتًا على جهاز يعمل بنظام Windows، ابحث عن "Python" في شريط البداية، أو نفذ الأمر التالي في "Command Line" (cmd.exe): C:\Users\اسم المستخدم>python --version للتحقق من وجود بايثون على نظام Linux أو Mac، افتح "Terminal" (التيرمنال) أو "Command Line" (سطر الأوامر) واكتب: python --version إذا لم يكن بايثون مثبتًا، يمكنك تنزيله مجانًا من الموقع الرسمي: [www.python.org](https://www.python.org/). --- English: Many PCs and Macs come with Python pre-installed. To check if Python is installed on a Windows PC, search for "Python" in the Start menu, or run the following command in the Command Line (cmd.exe): C:\Users\Your Name>python --version To check on Linux or Mac, open the command line or Terminal and type: python --version If Python is not installed, you can download it for free from the official website: [www.python.org](https://www.python.org/). --- ##### بداية سريعة مع بايثون (Python Quickstart) العربية: بايثون لغة برمجة مترجمة، مما يعني أنك تكتب ملفات بايثون (.py) باستخدام محرر نصوص، ثم تقوم بتشغيلها من خلال المترجم (Interpreter). لتشغيل ملف بايثون، استخدم هذا الأمر في سطر الأوامر: C:\Users\اسم المستخدم>python helloworld.py دعنا نكتب أول ملف بايثون باسم helloworld.py باستخدام أي محرر نصوص. print("Hello, World!") احفظ الملف. ثم افتح سطر الأوامر، وانتقل إلى المجلد الذي حفظت فيه الملف، وشغل: C:\Users\اسم المستخدم>python helloworld.py النتيجة ستكون: Hello, World! مبروك! لقد قمت بكتابة وتنفيذ أول برنامج بايثون لك. --- English: Python is an interpreted programming language, meaning you write Python (.py) files in a text editor, and then run them using the Python interpreter. To run a Python file, use the following command in the command line: C:\Users\Your Name>python helloworld.py Let's write our first Python file, called helloworld.py, using any text editor. print("Hello, World!") Save the file. Then, open the command line, navigate to the directory where you saved your file, and run: C:\Users\Your Name>python helloworld.py The output should be: Hello, World! Congratulations, you have written and executed your first Python program. --- ##### اختبار الكود على سطر الأوامر (Python Command Line) العربية: في بعض الأحيان، يكون من الأسهل اختبار جزء صغير من الكود مباشرةً على سطر الأوامر بدلاً من كتابة ملف كامل. يمكن تشغيل بايثون من سطر الأوامر نفسه. اكتب التالي في سطر الأوامر على Windows، Mac، أو Linux: C:\Users\اسم المستخدم>python إذا لم يعمل الأمر "python"، جرب "py": C:\Users\اسم المستخدم>py ثم يمكنك كتابة أي كود بايثون، مثل المثال السابق: >>> print("Hello, World!") ستحصل على النتيجة التالية في سطر الأوامر: Hello, World! لإغلاق سطر أوامر بايثون، اكتب الأمر التالي: exit() --- English: Sometimes, it is quicker and easier to test small pieces of code directly in the command line, instead of writing a full file. Python can be run as a command line itself. Type the following on the command line on Windows, Mac, or Linux: C:\Users\Your Name>python If the "python" command doesn't work, try "py": C:\Users\Your Name>py From there, you can write any Python code, like the previous Hello World example: >>> print("Hello, World!") Which will output: Hello, World! To exit the Python command line, type the following command: exit() :)

الدرس التعريفي 3.3 : * بيئة العمل * بيئة العمل او IDE ( Integrated Development Environment ) هي برنامج يوفر مجموعة من الأدوات والميزات المصممة لتسهيل عملية كتابة وتطوير البرمجيات. فيما يلي بعض بيئات العمل الشهيرة للعمل مع لغة البرمجة بايثون : أهمها 👇 1. PyCharm: واحد من أشهر بيئات التطوير المتكاملة لبايثون، يوفر واجهة مستخدم رسومية مفيدة وقوية، مع أدوات لتصحيح الأخطاء، وتحليل الشيفرة، وتنظيم المشاريع. رابط التحميل : https://www.jetbrains.com/pycharm/ النسخة المجانية هيا community 2. Visual Studio Code (VSCode): بيئة تطوير قوية وشهيرة من مايكروسوفت، توفر ميزات تحرير قوية وملحقات مخصصة لبايثون تجعل من تطوير التطبيقات أمرًا سهلاً ومريحًا. رابط التحميل : https://code.visualstudio.com/download كما يوجد العديد من البرامج مثل Spyder و Jupyter Notebook و IDLE #ملاحظة بيئة العمل المستخدمة في الشرح القادم بالنسبة لي pc هيا pycharm بالنسبة الى الأندرويد يمكن استخدام هذه التطبيقات 1 / pydroid3 هو Python IDE شامل لأجهزة Android، وهو مصمم لتسهيل تطوير Python أثناء التنقل. سواء كنت مبتدئًا في تعلم لغة Python أو مطورًا متمرسًا. رابط التحميل من قوقل بلاى 👇 https://play.google.com/store/apps/details?id=ru.iiec.pydroid3 2/ coding python : A powerful Python compiler for beginner يوفر وظائف التجميع والتشغيل التي تسمح للمبتدئين بالتحقق من أفكارهم في أسرع وقت ممكن. لا يحتاج البرنامج إلى تنزيل مكونات إضافية رابط التحميل من قوقل بلاى 👇 https://play.google.com/store/apps/details?id=com.kvassyu.coding.py هنالك أيضآ مواقع تمكنك من كتابة اكواد بايثون من اشهر المواقع هو موقع replit كل المطلوب منك يا صديقي ان تسجل في موقع و تختار لغة الكود الخاص بك python رابط الموقع 👇 https://replit.com/ See ya Next lesson... .............. .............. ............... ................. .............. رابط قناة التليغرام 👇 t.me/t3lampython رابط قناة اليوتيوب 👇 youtube.com/kaizonova My account 👇 t.me/kaizodev Or @kaizoa

1cT1n6qMIEtFl83HrPw7TFg-DzTechs.jpg.webp0.24 KB

18_P3lr0afuAVwBF83gokOQ-DzTechs.jpg.webp0.19 KB

في نافذة التحرير، انقر على "New" وأضف مسار تثبيت بايثون إلى القائمة

1lLFTQaO1j2xv3oMmPXZNAw-DzTechs.jpg.webp0.17 KB

في قسم "System Variables"، ابحث عن المتغير "Path" وحدده، ثم انقر على زر "Edit".