Kaizonova

@kaizonova


network tools " Internet tools " best android app " best website " best help "
القناة متخصصة في الانترنت وشروحات و تطبيقات و وافضل المواقع
و مساعدة العامة في التكنولوجيا
http://t.me/Kaizoa 👈 my account
youtube.com/c/kaizonova 👈 youtube

Kaizonova

23 Oct, 15:25


ما تنسو شرح لغة بايثون في القناة @knlearning

Kaizonova

23 Oct, 15:24


2. Speech Recognition: Deep learning is used in speech recognition systems such as Google Assistant and Siri, allowing these systems to understand and respond to human speech.

3. Machine Translation: Services like Google Translate use deep learning to improve the accuracy of translating texts between different languages.

#### Common Deep Learning Models:
1. Convolutional Neural Networks (CNNs): Mainly used for image processing tasks and object recognition.

2. Recurrent Neural Networks (RNNs): Used to process sequential data, such as texts or time series. For example, RNNs are used in machine translation and speech recognition.

3. Transformers: These are widely used in natural language processing tasks such as machine translation and text understanding.

#### Code Example (Using Keras and TensorFlow)
Here is a simple example of building a model using Convolutional Neural Networks (CNN) for image recognition:

import tensorflow as tf
from tensorflow.keras import layers, models

# Load the MNIST dataset (images of digits)
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()

# Normalize the data
x_train, x_test = x_train / 255.0, x_test / 255.0

# Build the model using CNN
model = models.Sequential([
layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)),
layers.MaxPooling2D((2, 2)),
layers.Conv2D(64, (3, 3), activation='relu'),
layers.MaxPooling2D((2, 2)),
layers.Flatten(),
layers.Dense(64, activation='relu'),
layers.Dense(10, activation='softmax')
])

# Compile the model
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])

# Train the model
model.fit(x_train, y_train, epochs=5)

# Test the model
test_loss, test_acc = model.evaluate(x_test, y_test)
print(f"Model accuracy on test set: {test_acc}")

These examples should give beginners a clear idea of what deep learning is, along with practical examples of how to use it.
:)

Kaizonova

23 Oct, 15:24


KN learning #post
ما هو التعلم العميق (Deep Learning)؟

التعلم العميق هو فرع من فروع الذكاء الاصطناعي يعتمد على الشبكات العصبية الاصطناعية لمحاكاة كيفية عمل الدماغ البشري في معالجة المعلومات واتخاذ القرارات. التعلم العميق هو نوع متقدم من التعلم الآلي (Machine Learning) ولكنه يركز على بناء شبكات عصبية متعددة الطبقات، تعرف باسم الشبكات العصبية العميقة (Deep Neural Networks)، التي تستطيع التعلم من كميات كبيرة من البيانات وتحليل أنماط معقدة.

#### كيف يعمل التعلم العميق؟
الشبكة العصبية الاصطناعية تتكون من وحدات صغيرة تسمى العُصبونات (Neurons)، وهي تشبه خلايا الدماغ. هذه العصبونات مرتبة في طبقات، وكل طبقة تتعلم معلومات معينة من البيانات. عندما يتم إعطاء نموذج التعلم العميق بيانات تدريبية، فإن النموذج يتعلم من هذه البيانات عن طريق ضبط الأوزان والارتباطات بين العصبونات لتحديد الأنماط والخصائص.

#### أمثلة على استخدام التعلم العميق:
1. التعرف على الصور: يمكن للشبكات العصبية العميقة التعرف على الصور وتصنيفها بدقة عالية. على سبيل المثال، يمكن للنموذج التعرف على صور القطط والكلاب وتمييزها عن بعضها البعض.

2. التعرف على الكلام: تستخدم تقنيات التعلم العميق في أنظمة التعرف على الكلام مثل تلك المستخدمة في المساعدات الصوتية مثل Google Assistant وSiri.

3. الترجمة الآلية: تعتمد خدمات الترجمة الآلية مثل Google Translate على التعلم العميق لتحسين دقة ترجمة النصوص بين اللغات المختلفة.

#### نماذج شائعة في التعلم العميق:
1. الشبكات العصبية التلافيفية (CNNs): تُستخدم بشكل رئيسي في مهام معالجة الصور والتعرف على الأشكال.

2. الشبكات العصبية التكرارية (RNNs): تُستخدم لمعالجة البيانات التي تأتي بتسلسل، مثل النصوص أو السلاسل الزمنية. على سبيل المثال، RNN تُستخدم في الترجمة الآلية والتعرف على الكلام.

3. الشبكات العصبية المتحوّلة (Transformers): وهي شائعة جدًا في مهام معالجة اللغة الطبيعية مثل الترجمة الآلية وفهم النصوص.

#### مثال برمجي (باستخدام مكتبة Keras و TensorFlow)
فيما يلي مثال بسيط لإنشاء نموذج باستخدام الشبكات العصبية التلافيفية (CNN) للتعرف على الصور:

import tensorflow as tf
from tensorflow.keras import layers, models

# تحميل مجموعة بيانات MNIST (صور الأرقام)
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()

# تطبيع البيانات
x_train, x_test = x_train / 255.0, x_test / 255.0

# بناء النموذج باستخدام CNN
model = models.Sequential([
layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)),
layers.MaxPooling2D((2, 2)),
layers.Conv2D(64, (3, 3), activation='relu'),
layers.MaxPooling2D((2, 2)),
layers.Flatten(),
layers.Dense(64, activation='relu'),
layers.Dense(10, activation='softmax')
])

# تجميع النموذج
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])

# تدريب النموذج
model.fit(x_train, y_train, epochs=5)

# اختبار النموذج
test_loss, test_acc = model.evaluate(x_test, y_test)
print(f"دقة النموذج على مجموعة الاختبار: {test_acc}")

What is Deep Learning?

Deep Learning is a branch of artificial intelligence that relies on artificial neural networks to simulate how the human brain processes information and makes decisions. Deep learning is an advanced form of machine learning that focuses on building multi-layered neural networks, known as deep neural networks, which can learn from large amounts of data and analyze complex patterns.

#### How Does Deep Learning Work?
An artificial neural network consists of small units called neurons, similar to brain cells. These neurons are arranged in layers, with each layer learning specific information from the data. When a deep learning model is given training data, it learns from the data by adjusting the weights and connections between neurons to identify patterns and features.

#### Examples of Deep Learning Applications:
1. Image Recognition: Deep neural networks can recognize and classify images with high accuracy. For instance, a model can identify pictures of cats and dogs and distinguish between them.

Kaizonova

21 Oct, 12:16


Deep learning
#التعلم-العميق
Scripting...

Kaizonova

20 Oct, 17:50


اهم شي ساعدوني بالتفاعل
اذا في اي سؤال اكتب في التعليق..
اتمنى لكم الفائده من المعلومة التي تخص الذكاء الاصطناعي سيكون هنالك كورس مدفوع كامل لهندسة الاصطناعي
:)

Kaizonova

20 Oct, 17:49


#### 1. Image Recognition:
Machine learning systems can classify images by identifying patterns within them. For instance, when you upload a photo to an app like Google Photos, the system recognizes the content of the image (people, cars, animals) based on pre-trained models.

Code:
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing import image
import numpy as np

# Load the pre-trained model
model = load_model('model.h5')

# Load the image for classification
img = image.load_img('test_image.jpg', target_size=(150, 150))
img_array = image.img_to_array(img)
img_array = np.expand_dims(img_array, axis=0)

# Predict the class of the image
prediction = model.predict(img_array)
print(f"Model Prediction: {prediction}")

#### 2. Sales Prediction:
Companies use machine learning to analyze past sales data and predict future trends. This helps in making strategic decisions like product stocking or financial planning.

Code:
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
import numpy as np

# Example sales data
sales_data = np.array([[1, 100], [2, 150], [3, 200], [4, 250]]) # month and sales
X = sales_data[:, 0].reshape(-1, 1) # input: month
y = sales_data[:, 1] # output: sales

# Split data
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

# Create Linear Regression model
model = LinearRegression()
model.fit(X_train, y_train)

# Predict sales for the fifth month
predicted_sales = model.predict([[5]])
print(f"Predicted sales for month 5: {predicted_sales}")

#### 3. Spam Detection:
Email systems use machine learning to detect spam messages from regular emails. The system learns from previous classified emails to improve its accuracy.

Code:
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB

# Training data (regular and spam emails)
emails = ["Congratulations, you've won a prize!", "Meeting tomorrow at 10am", "Cheap products available now"]
labels = [1, 0, 1] # 1 means spam, 0 means regular email

# Convert texts to numerical data
vectorizer = CountVectorizer()
X = vectorizer.fit_transform(emails)

# Train the model
model = MultinomialNB()
model.fit(X, labels)

# Test the model
test_email = vectorizer.transform(["Win a free vacation now!"])
prediction = model.predict(test_email)
print(f"Email Prediction: {'Spam' if prediction[0] == 1 else 'Regular email'}")

### Types of Machine Learning:

#### 1. Supervised Learning:
In this type, the model is trained using data that includes both inputs and the correct outputs. For example, the model could be trained to classify images or email messages.

#### 2. Unsupervised Learning:
In this type, the system is not provided with the correct answers. Instead, the model looks for patterns in the data, like clustering similar images.

#### 3. Reinforcement Learning:
This is similar to learning from trial and error, where the system learns by being rewarded for correct decisions and penalized for mistakes.

---

Both versions are enhanced for clarity and engagement, with added code examples to illustrate the concepts for beginners.
:)

Kaizonova

20 Oct, 17:49


KN learning #post

## ما هو تعلم الآلة؟

تعلم الآلة (Machine Learning) هو أحد فروع الذكاء الاصطناعي الذي يتيح للآلات (مثل الحواسيب) القدرة على التعلم من البيانات وتحسين أدائها بمرور الوقت دون الحاجة إلى برمجتها بشكل مباشر للقيام بمهام معينة. يعتمد النظام على الأنماط والإحصائيات الموجودة في البيانات للقيام بمهام مثل التنبؤات، التصنيفات، أو اتخاذ قرارات معينة.

### أمثلة على تعلم الآلة:

#### 1. التعرف على الصور:
تعتمد أنظمة تعلم الآلة على تحديد الأنماط في الصور لتصنيفها. على سبيل المثال، عند تحميل صورة إلى تطبيق مثل Google Photos، يتمكن النظام من التعرف على محتويات الصورة (أشخاص، سيارات، حيوانات) بناءً على النماذج التي تم تدريبها مسبقًا.

الكود:
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing import image
import numpy as np

# تحميل النموذج المدرب
model = load_model('model.h5')

# تحميل الصورة التي نريد تصنيفها
img = image.load_img('test_image.jpg', target_size=(150, 150))
img_array = image.img_to_array(img)
img_array = np.expand_dims(img_array, axis=0)

# توقع فئة الصورة
prediction = model.predict(img_array)
print(f"توقع النموذج: {prediction}")

#### 2. التنبؤ بالمبيعات:
تستخدم الشركات تعلم الآلة لتحليل بيانات المبيعات السابقة والتنبؤ بالمبيعات المستقبلية. هذا يساعدها في اتخاذ قرارات استراتيجية مثل تخزين المنتجات أو التخطيط المالي.

الكود:
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
import numpy as np

# بيانات المبيعات (مثال)
sales_data = np.array([[1, 100], [2, 150], [3, 200], [4, 250]]) # الشهر والمبيعات
X = sales_data[:, 0].reshape(-1, 1) # المدخلات: الشهر
y = sales_data[:, 1] # المخرجات: المبيعات

# تقسيم البيانات
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

# إنشاء نموذج الانحدار الخطي
model = LinearRegression()
model.fit(X_train, y_train)

# التنبؤ بالمبيعات للشهر الخامس
predicted_sales = model.predict([[5]])
print(f"توقع المبيعات للشهر الخامس: {predicted_sales}")

#### 3. تحديد الرسائل العشوائية (السبام):
تعتمد أنظمة البريد الإلكتروني على تعلم الآلة لتحديد الرسائل العشوائية من الرسائل العادية. يتم تدريب النظام بناءً على الرسائل السابقة المصنفة كـ"سبام" أو "غير سبام" لتحسين دقته.

الكود:
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB

# بيانات التدريب (رسائل عادية ورسائل سبام)
emails = ["Congratulations, you've won a prize!", "Meeting tomorrow at 10am", "Cheap products available now"]
labels = [1, 0, 1] # 1 تعني سبام، 0 تعني رسالة عادية

# تحويل النصوص إلى بيانات رقمية
vectorizer = CountVectorizer()
X = vectorizer.fit_transform(emails)

# تدريب النموذج
model = MultinomialNB()
model.fit(X, labels)

# اختبار النموذج
test_email = vectorizer.transform(["Win a free vacation now!"])
prediction = model.predict(test_email)
print(f"توقع الرسالة: {'سبام' if prediction[0] == 1 else 'رسالة عادية'}")

### أنواع تعلم الآلة:

#### 1. التعلم الموجه (Supervised Learning):
في هذا النوع، يتم تدريب النموذج باستخدام بيانات تحتوي على المدخلات والمخرجات الصحيحة. على سبيل المثال، يمكن تدريب النموذج على تصنيف الصور أو الرسائل البريدية.

#### 2. التعلم غير الموجه (Unsupervised Learning):
لا يتم تزويد النظام بنتائج صحيحة في هذا النوع. بدلاً من ذلك، يقوم النموذج بالبحث عن أنماط في البيانات مثل تجميع الصور المشابهة.

#### 3. التعلم المعزز (Reinforcement Learning):
يشبه التعلم من التجربة والخطأ، حيث يتعلم النظام من خلال المحاولة للوصول إلى أفضل نتيجة. يتم مكافأة النموذج عند اتخاذ القرارات الصحيحة ومعاقبته عند الخطأ.

---



## What is Machine Learning?

Machine Learning is a branch of artificial intelligence that allows machines (like computers) to learn from data and improve their performance over time without being explicitly programmed to perform certain tasks. The system relies on patterns and statistics found in the data to perform tasks such as predictions, classifications, or decision-making.

### Examples of Machine Learning:

Kaizonova

20 Oct, 16:20


Machine learning
#تعلم-الآلة
Scripting...

Kaizonova

20 Oct, 14:38


النقل جاء تلبية لطلب الاعضاء

Kaizonova

20 Oct, 14:29


Kaizonova pinned «سلام عليكم ورحمه الله وبركاته كيفكم ان شاءالله بخييير❤️ معليش وقفنا منكم نشر لمدة يومين 🥺 بس حاليا تم نقل قناة شروحات بايثون الى https://t.me/knlearning وهءه القناة ستكون شاملة لجميع المعلومات التي تهم المهندسين والمبرمجين 💔 اهم شي ساعدوني بالتفاعل لكي…»

Kaizonova

20 Oct, 14:29


سلام عليكم ورحمه الله وبركاته كيفكم ان شاءالله بخييير❤️
معليش وقفنا منكم نشر لمدة يومين 🥺 بس حاليا تم نقل قناة شروحات بايثون الى https://t.me/knlearning وهءه القناة ستكون شاملة لجميع المعلومات التي تهم المهندسين والمبرمجين 💔
اهم شي ساعدوني بالتفاعل لكي نقدم ليكم الافضل ⚡️
:)

Kaizonova

18 Oct, 19:09


Live stream finished (1 hour)

Kaizonova

18 Oct, 18:02


Live stream started

Kaizonova

18 Oct, 14:34


#### الفهرسة السلبية
يمكنك أيضًا استخدام **الفهرسة السلبية لبدء التقطيع من نهاية النص. الفهارس السلبية تعد بالعكس من نهاية النص.
##### مثال:
لإرجاع الأحرف من الفهرس -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

:)

Kaizonova

18 Oct, 14:34


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!"

---

Kaizonova

18 Oct, 09:53


محادثة اليوم الصوتية الساعه ٨ م عن:
ـ اجابة عن الاسئلة المتعلقة بالبرمجة.
- شرح مواقع التحديات والمنافسات العالمية بالبرمجة.
ـ خريطة تعلم البرمجة من الصفر وحتى الاحتراف
قناة المحادثة @kaizonova
:)

Kaizonova

17 Oct, 16:05


ان شاءالله غدا الساعة ٨ مساء سيبدا البث ويكون عبارة عن نقاش واجابة عن اسئلة البرمجة بلغة بايثون وايضا في شرح لموقع hacker rank وكيف التعامل مع البرمجة فيه والدخول في التحديات 😎
@kaizonova
:)

Kaizonova

17 Oct, 12:32


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] يشير إلى الحرف الرابع.
:)

Kaizonova

16 Oct, 16:29


غدا ان شاءالله سنبدا التعامل مع النصوص + توجد تمارين في كل بوست اتمنى لو تكتبو حلها في التعليقات
:)