0Pricing
Data Science Academy · درس

حسابات متجهة بلا حلقات

طبّق العمليات على مستوى العناصر عبر المصفوفات بأكملها.

حسابات متجهة بلا حلقات درس مجاني في Data Science Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Data Science Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Data Science Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Math on Whole Arrays

With NumPy you rarely write loops for math. You apply an operation to a whole array at once, and every element updates together. ⚡

The Old Loop Way

In plain Python, doubling numbers means looping one by one. It works, but it's verbose and slow for big datasets.

out = []
for x in nums:
    out.append(x * 2)

The Vectorized Way

NumPy collapses that loop into one line. Vectorization means the operation runs across the entire array in fast compiled code.

arr * 2  # every element doubled

Element-Wise by Default

Add two arrays and NumPy pairs them up position by position. This element-wise behavior is the heart of array math.

np.array([1, 2, 3]) + np.array([10, 20, 30])

Scalars Spread Everywhere

Add a single number to an array and it touches every element. NumPy calls this broadcasting the scalar across the whole grid.

np.array([1, 2, 3]) + 100

All the Operators Work

Subtraction, division, and powers all behave element-wise too. One expression transforms a million numbers in an instant.

arr ** 2  # square each element

Universal Functions

NumPy ships fast math helpers called ufuncs. np.sqrt and np.exp run across an entire array without a single loop.

np.sqrt(np.array([1, 4, 9]))  # 1 2 3

Compare Whole Arrays

Comparisons vectorize too. An expression like arr > 5 returns a boolean array, one True or False per element.

np.array([3, 7, 5]) > 5  # F T F

Why It Runs So Fast

Vectorized code pushes the loop down into optimized C. You skip Python's per-step overhead, so the same work finishes far faster. 🚀

Clearer Code, Too

Beyond speed, vectorized math reads like the formula itself. Less code means fewer bugs and an analysis anyone can follow.

celsius = (fahrenheit - 32) * 5 / 9

Think in Arrays

The mindset shift is simple: stop thinking one number at a time and start thinking in whole arrays. That habit unlocks NumPy's power. 🧠

Quick Check

Let's see what vectorized math returns.

Recap

You learned to drop the loop: vectorized math applies operations element-wise across whole arrays, with scalars broadcast and ufuncs for the rest. Faster and clearer. 🎉

الأسئلة الشائعة

هل درس «حسابات متجهة بلا حلقات» مجاني؟

نعم — نص درس «حسابات متجهة بلا حلقات» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Data Science Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Data Science Academy 4 دروس في المجموع.

ماذا ستتعلم في «حسابات متجهة بلا حلقات»؟

طبّق العمليات على مستوى العناصر عبر المصفوفات بأكملها. تتمرن على Data Science Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Data Science Academy؟

لا تُشترط خبرة سابقة. Data Science Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.

كم من الوقت يستغرق درس «حسابات متجهة بلا حلقات»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Data Science Academy هذا؟

نعم. كل درس في Data Science Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. من قائمة Python إلى ndarray
  2. Shape وSize وdtype
  3. حسابات متجهة بلا حلقات
  4. فهرسة المصفوفات وتقطيعها
← العودة إلى Data Science Academy