

Foundationsالأساسيات
Read data and business questions, use AI responsibly, write and test simple Python, and solve problems step by step.
تقرأ البيانات وأسئلة الأعمال، وتستخدم الذكاء الاصطناعي بمسؤولية، وتكتب كود بايثون بسيطًا وتختبره، وتحل المشكلات خطوة بخطوة.
Units in this stageوحدات هذه المرحلة
- U01Data Science & the Modern Data Worldعلم البيانات وعالم البيانات الحديث
4 lessons + exit check4 دروس + تقييم نهاية الوحدة - U02Business Foundations for Data Professionalsأساسيات الأعمال لمحترفي البيانات
4 lessons + exit check4 دروس + تقييم نهاية الوحدة - U03AI for Data Workالذكاء الاصطناعي في العمل مع البيانات
4 lessons + exit check4 دروس + تقييم نهاية الوحدة - U04Python Fundamentalsأساسيات بايثون
4 lessons + exit check4 دروس + تقييم نهاية الوحدة - U05Problem Solving & Computational Thinkingحل المشكلات والتفكير الحاسوبي
4 lessons + exit check4 دروس + تقييم نهاية الوحدة
Have a pass? عندك اشتراك؟ Sign in to open every lessonسجّل الدخول لفتح كل الدروس.
U01 · Data Science & the Modern Data Worldعلم البيانات وعالم البيانات الحديث
Stage 1المرحلة 1Free: every lesson in this unit.
مجاني: كل دروس هذه الوحدة.
L01 · What Is Data Science?L01 · ما هو علم البيانات؟ Freeمجاني
L01 — What Is Data Science?
Learner file. Answers and model solutions are kept in a separate instructor file. Version: U01 pilot v1.0 · Content date: 11 October 2026.
1. Lesson Identity
| Field | Value |
|---|---|
| Title | What Is Data Science? |
| Stage | Stage 1 — Foundations |
| Unit | U01 — Data Science & the Modern Data World |
| Lesson ID | L01 |
| Skills | Data literacy; role awareness |
| Difficulty | Beginner (no prior Data Science knowledge needed) |
| Estimated time | About 1 hour 45 minutes (see the breakdown at the end of this section) |
| Prerequisites | None. You need to be able to read English and open web links. Using an AI assistant is optional. |
Time breakdown (estimate): reading the concept and worked example, 30 min · guided practice, 15 min · independent practice, 15 min · knowledge check, 10 min · AI in Practice and AI Verification, 15 min · workplace task, 10 min · mini challenge, 10 min · reflection, 5 min. Optional deeper resources are not included.
2. Learning Objective
By the end of this lesson, you will be able to explain what Data Science is and classify the parts of a short business scenario as data, analysis, modeling or decision-making.
3. Why It Matters
Most organizations already collect data: sales, website visits, delivery times, customer messages. Collecting data is not the hard part. The hard part is turning it into a better decision, such as how much stock to order or which customers need help first.
If you cannot tell the difference between having data, analysing it, building a model and making a decision, two things tend to go wrong. People believe a chart "decides" something, or they build something complicated when a simple comparison would have been enough. This lesson gives you a clear mental model to use for the rest of D.World.
4. Concept
Plain-language version
Data Science is the practice of using data to answer useful questions and to support better decisions. It combines three things:
- Data: recorded facts about what happened.
- Methods: ways of examining data, such as counting, comparing, statistics and computing.
- Context: understanding the business or situation well enough to ask the right question and to interpret the answer sensibly.
A more precise version
Data Science is an interdisciplinary field. It draws on statistics, computing and knowledge of a specific domain (such as retail, health or logistics) to get reliable knowledge from data and to communicate it to the people who must act on it.
The U.S. occupational database ONET describes Data Scientists as people who develop techniques and analytics applications that turn raw data into meaningful information*, and who then visualize, interpret and report what they find. That description is US-based, but the core idea is widely shared.
Four building blocks you must keep separate
| Building block | What it means | Small example (online store) |
|---|---|---|
| Data | Recorded values, often raw and unorganized | "Order 1042: 2 notebooks, 12 USD, 3 March, 14:05" |
| Analysis | Examining data to describe, compare or understand something | "Notebook orders were higher in the last two weeks of August than in July" |
| Modeling | Building a simplified rule or mathematical representation that estimates, predicts or explains something, and checking how well it works | "A rule that estimates next week's notebook orders from the previous 8 weeks" |
| Decision-making | A person or team choosing an action, using evidence together with costs, constraints and goals | "Order 300 notebooks for September instead of 200" |
Not every project needs modeling. Many useful questions are answered with a careful analysis. A model is worth building only when you need to estimate or predict something repeatedly, or at scale.
Related terms (they overlap, so use them carefully)
- Data analytics: examining data to answer questions, often about what happened and why. It overlaps heavily with Data Science; many teams use the words differently.
- Artificial Intelligence (AI): a broad field about computer systems that perform tasks we associate with human intelligence, such as understanding language.
- Machine Learning (ML): a part of AI in which a system learns patterns from data instead of following only hand-written rules. Data Scientists sometimes use ML as one of their methods, but not always.
Job titles and boundaries are not standardized. One company's "Data Analyst" may do work that another company calls "Data Science." L03 looks at this more closely.
Key principle: data → evidence → decision
Data on its own does not decide anything. Data becomes evidence when it has been checked and connected to a specific question. A person then makes a decision using that evidence plus everything else they know: costs, risks, values and constraints.
5. Worked Example
Scenario (fictional): Cedar Lane is an invented small online store that sells notebooks, pens and desk items. Cedar Lane and every number about it in this unit are invented for teaching; they do not describe a real company.
The owner asks: "Should we offer free shipping on orders above 40 USD?"
- Name the decision. Offer free shipping above 40 USD: yes or no. Without a decision, the work has no clear purpose.
- Turn it into a question that data can help answer. "If we offer free shipping above 40 USD, would order values rise enough to cover the extra shipping cost?"
- Identify the data. Past orders (values, items, dates), current shipping costs per order, and any past period when shipping rules were different.
- Analysis. Count how many recent orders were just below 40 USD (for example 32–39 USD). Those are the customers most likely to add an item to reach the threshold. Compare this with the shipping cost the store would absorb on orders already above 40 USD.
- Modeling? Probably not needed yet. A simple calculation with a few scenarios ("if 10%, 20% or 30% of near-threshold customers add an item") is enough for a first decision.
- Evidence. The checked figures, stated with their limits. For example: "This is based on 3 months of orders and assumes customer behaviour stays similar."
- Decision. The owner decides, perhaps choosing a 4-week trial instead of a permanent change, because the evidence is uncertain.
Observed vs not yet known: we can observe past order values. We cannot yet observe how customers will react to free shipping. That is why a trial with measurement is a sensible decision.
6. Visual Explanation
[ Data ] --> [ Analysis ] --> ( Modeling, only if needed ) --> [ Evidence ] --> [ Decision ] --> [ Action ]
^ |
|__________________________ new data from the result of the action __________________________|
Alt text: A left-to-right chain of boxes: Data, Analysis, an optional Modeling step shown in round brackets, Evidence, Decision, Action. An arrow returns from Action to Data, showing that the result of an action produces new data to learn from.
7. Guided Practice
Scenario (fictional): Cedar Lane wants to decide how many notebooks to reorder for September. Label each statement D (data), A (analysis), M (modeling) or DM (decision-making).
| # | Statement | Your label |
|---|---|---|
| 1 | The order system lists every notebook sold, with its date and price. | |
| 2 | The team compares notebook sales in August this year with August last year. | |
| 3 | A rule is built that estimates weekly notebook demand from the last 12 weeks, and it is checked against weeks that already happened. | |
| 4 | The owner chooses to reorder 300 notebooks after reviewing the estimate and the supplier's minimum order size. | |
| 5 | A spreadsheet export contains 1,240 rows of last quarter's orders. | |
| 6 | The team notices that pens and notebooks are often bought together and checks how often. |
Hints: - Ask yourself: is this a record, an examination, a rule that estimates or predicts, or a choice of action? - Statement 3 includes checking the rule. Checking is part of good modeling. - A large number of rows is still data until someone examines it.
8. Independent Practice
Scenario (fictional): A small fitness studio runs group classes and wants to decide whether to add an extra Saturday morning class.
Write a short answer (5–8 lines) that includes:
- the decision;
- one question that data could help answer;
- two types of data the studio probably already has;
- one analysis you would do;
- whether a model is needed at this stage, and why or why not;
- who should make the final decision, and one non-data factor they must consider.
No model answer is shown here. Your response is reviewed against the rubric in the assessment evidence section.
9. Knowledge Check (short scenario quiz)
Choose the best answer for each question.
Q1. Cedar Lane's system stores the date, items and price of every order. This record is best described as: - A) data B) analysis C) a model D) a decision
Q2. The owner compares the average order value of customers who used a discount code with those who did not. This is: - A) data B) analysis C) a decision D) artificial intelligence
Q3. The team builds a rule that estimates next week's orders from the last 8 weeks and the time of year, then checks it against past weeks. This is best called: - A) raw data B) decision-making C) modeling D) reporting
Q4. Which statement best describes Data Science? - A) Using AI tools to make business decisions automatically - B) Storing very large amounts of data in the cloud - C) Making attractive charts - D) Using data, methods such as statistics and computing, and context to answer questions and inform decisions
Q5. An analysis shows that notebook sales rise in the weeks before school starts. Who should make the restocking decision, and how? - A) A person responsible for stock, using the evidence plus costs, storage space and supplier delivery times. - B) The analysis makes the decision automatically. - C) An AI chatbot, because it can read the analysis. - D) Whoever made the chart, because they know the numbers best.
Q6. Which is the best example of a business decision that data could improve? - A) "Data is important for every company." - B) "We should collect all the data we can." - C) "Should we reorder 200 or 400 notebooks for September?" - D) "Our brand colour is blue."
Q7. Which statement about AI and Machine Learning is correct? - A) AI and Machine Learning are unrelated fields. - B) All Data Science work is Machine Learning. - C) Machine Learning means making any kind of chart. - D) Machine Learning is a part of AI in which systems learn patterns from data.
Q8. An AI assistant tells you: "Data Scientists spend 80% of their time cleaning data." What is the best response? - A) Accept it, because AI tools are trained on a lot of text. - B) Treat it as a claim to check against a credible, dated source before repeating it. - C) Never use AI tools for anything. - D) Put it in your report as a fact.
10. AI in Practice
Use an AI assistant to compare explanations at two levels. Copy this prompt:
"Explain what Data Science is in two versions. Version 1: for a complete beginner, in under 80 words, with one everyday business example. Version 2: for an intermediate learner, in under 150 words, mentioning how it relates to data analytics, Machine Learning and AI. After both versions, list any statements you are unsure about."
Why this can help: seeing two levels of explanation shows you which ideas are essential and which are extra detail. Asking the AI to list its uncertain statements makes it easier to see what you need to check.
11. AI Verification
AI output is a draft to check, not a source of truth. Do this:
- Compare with an official source. Open the O*NET Data Scientists summary (see Resources). Does the AI's description match the idea of turning raw data into meaningful information and reporting findings? Note any differences.
- Check against this lesson. Did the AI separate data, analysis, modeling and decision-making? Did it suggest that AI or a model makes the decision? That would contradict this lesson's key principle.
- Flag absolute claims. Words such as "always", "every Data Scientist" or a precise percentage with no source are warning signs. Do not repeat them unless you find a credible, dated source.
- Write one sentence saying what you kept, what you corrected and why.
Privacy: for this task, never paste names, emails, order details or any company data. A general question needs no private information.
12. Business Lens
Data creates business value only when it changes or improves a decision. Typical examples:
- Revenue: pricing, promotions, which products to feature.
- Cost: how much stock to hold, how many staff to schedule.
- Customers: who needs help first, why customers stop buying.
- Risk: spotting unusual orders that might be fraud.
- Product: which features or items to add or remove.
A useful test is: "If the answer came out differently, would we do something differently?" If not, the question may not be worth the effort.
13. Workplace Task — Decision Opportunity Note
You are helping Cedar Lane's owner. Write a short note (60–120 words) with these parts:
- Decision: one decision the store makes regularly.
- Why it matters: the cost, revenue, customer or risk at stake.
- Data that may already exist: at least two items.
- What could change: how the decision might be different if the evidence pointed one way or the other.
14. Mini Challenge
New scenario (fictional): A neighbourhood bakery decides each evening how many loaves to bake for the next morning. Unsold bread is thrown away; running out means losing sales.
Create a data → evidence → decision chain for this bakery: 1. two kinds of data it could record; 2. one analysis; 3. whether a model could eventually help, and why; 4. what evidence the baker would want before changing the usual quantity; 5. who decides, and one factor that is not in the data.
Submit your answer before looking at any feedback. The solution is not provided here.
15. Resources
- Required (about 10 min): ONET OnLine — Data Scientists (15-2051.00) summary page. Read the description and the "Tasks" list. https://www.onetonline.org/link/summary/15-2051.00 (US occupational data.)*
- Recommended (about 10 min): U.S. Bureau of Labor Statistics — Occupational Outlook Handbook: Data Scientists, "What They Do" tab. https://www.bls.gov/ooh/math/data-scientists.htm (US-focused. Skip the pay and outlook tabs for now; they are US-only and not needed here.)
- Deeper (optional audio; episode length not verified in this run): DataCamp DataFramed podcast, "Decision Intelligence and Data Science", with Cassie Kozyrkov (recorded 2018). https://www.datacamp.com/podcast/decision-intelligence-and-data-science
16. Person to Follow
Cassie Kozyrkov works on decision intelligence: improving how people and organizations turn information into better actions. Her website describes her as Google's first Chief Decision Scientist (a past role). She is relevant to this lesson because her work keeps the focus on the decision, not just the data or the model.
- Start with: her website https://www.kozyr.com/ and the 2018 DataFramed episode listed above.
- Read critically: as with any expert, compare her ideas with other sources and form your own view.
17. Reflection
Before this lesson, where did you think a "decision" happened in data work: inside the data, inside the chart or model, or with a person? What changed in your thinking, if anything?
18. Next Step
You learned that data becomes evidence before it supports a decision. In L02 — Data, Information, Insight & Evidence, you will look closely at that middle step. You will practise separating raw data from summarized information, from interpretations that might be wrong, and from conclusions that are actually supported by evidence.
19. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Knowledge check Q1–Q8 | You can recognize the building blocks and the related terms in short scenarios | 6 or more correct out of 8 = meets |
| Independent practice (fitness studio) | You can apply the four building blocks to a new situation | Rubric L01-IP: decision named; data-answerable question; two plausible data types; one analysis; a justified model decision; a person as decision owner plus one non-data factor |
| Workplace task (decision opportunity note) | You can connect data to a business decision | Rubric L01-WT: concrete decision; business stake stated; at least two data items; describes how the decision could change |
| Mini challenge (bakery) | You can transfer the chain to a new domain | Rubric L01-MC (instructor file) |
20. References
- ONET OnLine. Summary Report for: 15-2051.00 — Data Scientists. National Center for ONET Development / U.S. Department of Labor. https://www.onetonline.org/link/summary/15-2051.00 (page shows "Updated 2026"; accessed and checked 11 Oct 2026). Supports: the paraphrased occupational description.
- U.S. Bureau of Labor Statistics. Occupational Outlook Handbook — Data Scientists. https://www.bls.gov/ooh/math/data-scientists.htm (accessed 11 Oct 2026). Supports: the "What They Do" description used as recommended reading. US-focused.
- DataCamp. DataFramed podcast, "Decision Intelligence and Data Science" (guest: Cassie Kozyrkov; dated 22 Oct 2018). https://www.datacamp.com/podcast/decision-intelligence-and-data-science (accessed 11 Oct 2026).
- Kozyrkov, C. Personal website. https://www.kozyr.com/ (accessed 11 Oct 2026). Supports: "Google's first Chief Decision Scientist" (past role) and the decision-intelligence focus.
- D.World Curriculum Bible v1.0 and Curriculum Map v1.0 (internal). Lesson ID, objective, emphasis and principles.
L01 — ما هو علم البيانات؟
ملف المتعلّم. الإجابات والحلول النموذجية محفوظة في ملف منفصل خاص بالمدرّس. الإصدار: U01 pilot v1.0 · تاريخ المحتوى: 11 أكتوبر 2026.
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | ما هو علم البيانات؟ |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U01 — علم البيانات وعالم البيانات الحديث |
| رقم الدرس | L01 |
| المهارات | الثقافة البيانية (data literacy)؛ فهم الأدوار |
| المستوى | مبتدئ (لا تحتاج أي معرفة سابقة بعلم البيانات) |
| الوقت المتوقع | حوالي ساعة و45 دقيقة (انظر التفصيل في نهاية هذا القسم) |
| المتطلبات السابقة | لا شيء. تحتاج فقط أن تقرأ الإنجليزية وتفتح روابط الويب، لأن المصادر والأدوات بالإنجليزية. استخدام مساعد ذكاء اصطناعي اختياري. |
تفصيل الوقت (تقديري): قراءة المفهوم والمثال المحلول 30 دقيقة · التدريب الموجَّه 15 دقيقة · التدريب المستقل 15 دقيقة · اختبار الفهم 10 دقائق · الذكاء الاصطناعي في التطبيق والتحقق من مخرجاته 15 دقيقة · مهمة العمل 10 دقائق · التحدي القصير 10 دقائق · التأمّل 5 دقائق. المصادر الاختيارية للتعمّق غير محسوبة.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تشرح ما هو علم البيانات، وأن تصنّف أجزاء موقف عمل قصير إلى بيانات أو تحليل أو نمذجة أو اتخاذ قرار.
3. لماذا يهمّك هذا؟
معظم المؤسسات تجمع البيانات بالفعل: المبيعات، وزيارات الموقع، ومواعيد التوصيل، ورسائل العملاء. جمع البيانات ليس الجزء الصعب. الصعب هو تحويلها إلى قرار أفضل، مثل كمية المخزون التي يجب طلبها، أو أي العملاء يحتاجون المساعدة أولًا.
إذا لم تستطع التفريق بين امتلاك البيانات، وتحليلها، وبناء نموذج، واتخاذ قرار، فغالبًا يحدث خطآن: يظن الناس أن رسمًا بيانيًا "يقرّر" شيئًا، أو يبنون شيئًا معقدًا بينما كانت مقارنة بسيطة تكفي. هذا الدرس يعطيك صورة ذهنية واضحة ستستخدمها في بقية رحلتك في D.World.
4. المفهوم
بلغة بسيطة
علم البيانات (Data Science) هو استخدام البيانات للإجابة عن أسئلة مفيدة ودعم قرارات أفضل. وهو يجمع بين ثلاثة أشياء:
- البيانات: حقائق مسجّلة عمّا حدث.
- الطرق: أساليب فحص البيانات، مثل العدّ والمقارنة والإحصاء والحوسبة.
- السياق: فهم العمل أو الموقف بدرجة تكفي لطرح السؤال الصحيح وتفسير الإجابة بشكل معقول.
تعريف أدق
علم البيانات مجال متعدد التخصصات. يعتمد على الإحصاء والحوسبة ومعرفة مجال محدد (مثل التجزئة أو الصحة أو الخدمات اللوجستية) لاستخراج معرفة موثوقة من البيانات، وإيصالها إلى الأشخاص الذين يجب أن يتصرفوا بناءً عليها.
تصف قاعدة البيانات المهنية الأمريكية O*NET علماء البيانات (Data Scientists) بأنهم أشخاص يطوّرون تقنيات وتطبيقات تحليلية تحوّل البيانات الخام إلى معلومات ذات معنى، ثم يعرضون ما يجدونه بصريًا ويفسّرونه ويكتبون عنه تقارير. هذا الوصف أمريكي، لكن فكرته الأساسية متفق عليها على نطاق واسع.
أربع لبنات أساسية يجب أن تفصل بينها
| اللبنة | معناها | مثال صغير (متجر إلكتروني) |
|---|---|---|
| البيانات (Data) | قيم مسجّلة، غالبًا خام وغير منظمة | "الطلب 1042: كراستان، 12 دولارًا، 3 مارس، 14:05" |
| التحليل (Analysis) | فحص البيانات لوصف شيء أو مقارنته أو فهمه | "طلبات الكراسات في آخر أسبوعين من أغسطس كانت أعلى منها في يوليو" |
| النمذجة (Modeling) | بناء قاعدة مبسّطة أو تمثيل رياضي يقدّر شيئًا أو يتنبأ به أو يفسّره، ثم التحقق من مدى صحته | "قاعدة تقدّر طلبات الكراسات في الأسبوع القادم من بيانات آخر 8 أسابيع" |
| اتخاذ القرار (Decision-making) | شخص أو فريق يختار تصرفًا، مستخدمًا الأدلة مع التكاليف والقيود والأهداف | "اطلب 300 كراسة لشهر سبتمبر بدلًا من 200" |
ليس كل مشروع يحتاج إلى نمذجة. كثير من الأسئلة المفيدة يُجاب عنها بتحليل دقيق. بناء النموذج يستحق الجهد فقط عندما تحتاج إلى تقدير شيء أو التنبؤ به بشكل متكرر أو على نطاق واسع.
مصطلحات قريبة (متداخلة، فاستخدمها بحذر)
- تحليلات البيانات (Data analytics): فحص البيانات للإجابة عن أسئلة، غالبًا عمّا حدث ولماذا. تتداخل كثيرًا مع علم البيانات، وكثير من الفرق تستخدم الكلمتين بمعانٍ مختلفة.
- الذكاء الاصطناعي (Artificial Intelligence – AI): مجال واسع يهتم بأنظمة حاسوبية تؤدي مهام نربطها بالذكاء البشري، مثل فهم اللغة.
- تعلّم الآلة (Machine Learning – ML): جزء من الذكاء الاصطناعي يتعلّم فيه النظام الأنماط من البيانات بدلًا من أن يتبع قواعد مكتوبة يدويًا فقط. يستخدم علماء البيانات تعلّم الآلة أحيانًا كإحدى طرقهم، لكن ليس دائمًا.
المسميات الوظيفية وحدودها ليست موحّدة. ما تسميه شركة "محلل بيانات" (Data Analyst) قد تسميه شركة أخرى "علم بيانات". سيتناول الدرس L03 هذا الموضوع بتفصيل أكبر.
مبدأ أساسي: بيانات ← دليل ← قرار
البيانات وحدها لا تقرّر شيئًا. تصبح البيانات دليلًا عندما يتم التحقق منها وربطها بسؤال محدد. ثم يتخذ شخص القرار مستخدمًا هذا الدليل، مع كل ما يعرفه غير ذلك: التكاليف والمخاطر والقيم والقيود.
5. مثال محلول
الموقف (خيالي): Cedar Lane متجر إلكتروني صغير متخيَّل يبيع الكراسات والأقلام وأدوات المكتب. المتجر وكل الأرقام الخاصة به في هذه الوحدة مخترعة لأغراض التعليم، ولا تصف شركة حقيقية.
يسأل صاحب المتجر: "هل نقدّم شحنًا مجانيًا للطلبات التي تزيد على 40 دولارًا؟"
- حدّد القرار. تقديم شحن مجاني فوق 40 دولارًا: نعم أم لا. بدون قرار محدد، لا يكون للعمل هدف واضح.
- حوّله إلى سؤال تساعد البيانات في الإجابة عنه. "إذا قدّمنا شحنًا مجانيًا فوق 40 دولارًا، هل سترتفع قيمة الطلبات بما يكفي لتغطية تكلفة الشحن الإضافية؟"
- حدّد البيانات. الطلبات السابقة (قيمها وأصنافها وتواريخها)، وتكلفة الشحن الحالية لكل طلب، وأي فترة سابقة كانت فيها قواعد الشحن مختلفة.
- التحليل. عُدّ الطلبات الحديثة التي كانت أقل قليلًا من 40 دولارًا (مثلًا بين 32 و39 دولارًا). هؤلاء هم العملاء الأكثر احتمالًا لإضافة صنف للوصول إلى الحد. وقارن ذلك بتكلفة الشحن التي سيتحملها المتجر عن الطلبات التي تتجاوز 40 دولارًا أصلًا.
- هل نحتاج إلى نمذجة؟ على الأغلب ليس بعد. حساب بسيط مع بعض السيناريوهات ("إذا أضاف 10% أو 20% أو 30% من العملاء القريبين من الحد صنفًا") يكفي لقرار أول.
- الدليل. الأرقام بعد التحقق منها، مع ذكر حدودها. مثلًا: "هذا مبني على طلبات 3 أشهر، ويفترض أن سلوك العملاء سيظل مشابهًا".
- القرار. صاحب المتجر هو من يقرّر، وقد يختار تجربة لمدة 4 أسابيع بدلًا من تغيير دائم، لأن الدليل غير مؤكد.
ما نلاحظه مقابل ما لا نعرفه بعد: يمكننا ملاحظة قيم الطلبات السابقة، لكننا لا نستطيع بعد ملاحظة رد فعل العملاء على الشحن المجاني. لهذا فإن تجربة مع قياس النتائج قرار معقول.
6. شرح بصري
[ Data ] --> [ Analysis ] --> ( Modeling, only if needed ) --> [ Evidence ] --> [ Decision ] --> [ Action ]
^ |
|__________________________ new data from the result of the action __________________________|
وصف الرسم: سلسلة مربعات من اليسار إلى اليمين: البيانات (Data)، ثم التحليل (Analysis)، ثم خطوة نمذجة اختيارية بين قوسين (Modeling, only if needed)، ثم الدليل (Evidence)، ثم القرار (Decision)، ثم التصرف (Action). يعود سهم من التصرف إلى البيانات، ليوضح أن نتيجة أي تصرف تنتج بيانات جديدة نتعلّم منها.
7. تدريب موجَّه
الموقف (خيالي): يريد Cedar Lane أن يقرّر عدد الكراسات التي سيعيد طلبها لشهر سبتمبر. صنّف كل عبارة بأحد الرموز: D (بيانات)، أو A (تحليل)، أو M (نمذجة)، أو DM (اتخاذ قرار).
| # | العبارة | تصنيفك |
|---|---|---|
| 1 | نظام الطلبات يسجّل كل كراسة مباعة مع تاريخها وسعرها. | |
| 2 | يقارن الفريق مبيعات الكراسات في أغسطس هذا العام بمبيعات أغسطس في العام الماضي. | |
| 3 | تُبنى قاعدة تقدّر الطلب الأسبوعي على الكراسات من بيانات آخر 12 أسبوعًا، ثم تُختبر على أسابيع حدثت بالفعل. | |
| 4 | يختار صاحب المتجر إعادة طلب 300 كراسة بعد مراجعة التقدير والحد الأدنى للطلب عند المورّد. | |
| 5 | ملف جدول بيانات مُصدَّر يحتوي على 1,240 صفًا من طلبات الربع الماضي. | |
| 6 | يلاحظ الفريق أن الأقلام والكراسات تُشترى معًا كثيرًا، فيتحقق من عدد مرات حدوث ذلك. |
تلميحات: - اسأل نفسك: هل هذا تسجيل، أم فحص، أم قاعدة تقدّر أو تتنبأ، أم اختيار تصرف؟ - العبارة 3 تتضمن التحقق من القاعدة، والتحقق جزء من النمذجة الجيدة. - العدد الكبير من الصفوف يظل بيانات إلى أن يفحصها أحد.
8. تدريب مستقل
الموقف (خيالي): استوديو لياقة صغير يقدّم حصصًا جماعية، ويريد أن يقرّر هل يضيف حصة إضافية صباح يوم السبت.
اكتب إجابة قصيرة (من 5 إلى 8 أسطر) تتضمن:
- القرار؛
- سؤالًا واحدًا يمكن للبيانات أن تساعد في الإجابة عنه؛
- نوعين من البيانات يمتلكهما الاستوديو غالبًا بالفعل؛
- تحليلًا واحدًا ستقوم به؛
- هل نحتاج إلى نموذج في هذه المرحلة، ولماذا أو لماذا لا؛
- من يجب أن يتخذ القرار النهائي، وعاملًا واحدًا من خارج البيانات عليه أن يأخذه في الاعتبار.
لا توجد إجابة نموذجية هنا. تتم مراجعة إجابتك وفق معايير التقييم الموجودة في قسم أدلة التقييم.
9. اختبار الفهم (أسئلة قصيرة على مواقف)
اختر الإجابة الأفضل لكل سؤال.
Q1. يحفظ نظام Cedar Lane تاريخ كل طلب وأصنافه وسعره. أفضل وصف لهذا السجل هو: - A) بيانات B) تحليل C) نموذج D) قرار
Q2. يقارن صاحب المتجر متوسط قيمة الطلب للعملاء الذين استخدموا كود خصم بمتوسطها لمن لم يستخدموه. هذا: - A) بيانات B) تحليل C) قرار D) ذكاء اصطناعي
Q3. يبني الفريق قاعدة تقدّر طلبات الأسبوع القادم من آخر 8 أسابيع ومن وقت السنة، ثم يختبرها على أسابيع سابقة. أفضل اسم لهذا هو: - A) بيانات خام B) اتخاذ قرار C) نمذجة D) إعداد تقارير
Q4. أي عبارة تصف علم البيانات بشكل أفضل؟ - A) استخدام أدوات الذكاء الاصطناعي لاتخاذ قرارات العمل تلقائيًا - B) تخزين كميات ضخمة جدًا من البيانات في السحابة - C) صنع رسوم بيانية جذابة - D) استخدام البيانات، وطرق مثل الإحصاء والحوسبة، والسياق، للإجابة عن الأسئلة ودعم القرارات
Q5. يُظهر تحليل أن مبيعات الكراسات ترتفع في الأسابيع التي تسبق بدء الدراسة. من يجب أن يتخذ قرار إعادة التخزين، وكيف؟ - A) شخص مسؤول عن المخزون، مستخدمًا الدليل مع التكاليف ومساحة التخزين ومواعيد توريد المورّد. - B) التحليل يتخذ القرار تلقائيًا. - C) روبوت محادثة يعمل بالذكاء الاصطناعي، لأنه يستطيع قراءة التحليل. - D) من صنع الرسم البياني، لأنه أكثر من يعرف الأرقام.
Q6. ما أفضل مثال على قرار عمل يمكن للبيانات أن تحسّنه؟ - A) "البيانات مهمة لكل شركة." - B) "يجب أن نجمع كل البيانات التي نستطيعها." - C) "هل نعيد طلب 200 كراسة أم 400 لشهر سبتمبر؟" - D) "لون علامتنا التجارية أزرق."
Q7. أي عبارة عن الذكاء الاصطناعي وتعلّم الآلة صحيحة؟ - A) الذكاء الاصطناعي وتعلّم الآلة مجالان لا علاقة بينهما. - B) كل عمل في علم البيانات هو تعلّم آلة. - C) تعلّم الآلة يعني صنع أي نوع من الرسوم البيانية. - D) تعلّم الآلة جزء من الذكاء الاصطناعي تتعلّم فيه الأنظمة الأنماط من البيانات.
Q8. يخبرك مساعد ذكاء اصطناعي: "علماء البيانات يقضون 80% من وقتهم في تنظيف البيانات." ما أفضل تصرف؟ - A) تقبّل المعلومة، لأن أدوات الذكاء الاصطناعي مدرّبة على نصوص كثيرة. - B) تعامل معها كادعاء يجب التحقق منه من مصدر موثوق ومؤرَّخ قبل أن تكرره. - C) لا تستخدم أدوات الذكاء الاصطناعي في أي شيء أبدًا. - D) ضعها في تقريرك كحقيقة.
10. الذكاء الاصطناعي في التطبيق
استخدم مساعد ذكاء اصطناعي لمقارنة الشرح على مستويين. انسخ هذا الطلب (prompt):
"Explain what Data Science is in two versions. Version 1: for a complete beginner, in under 80 words, with one everyday business example. Version 2: for an intermediate learner, in under 150 words, mentioning how it relates to data analytics, Machine Learning and AI. After both versions, list any statements you are unsure about."
ولو تفضّل العربية، استخدم هذه الصيغة:
"اشرح ما هو علم البيانات في نسختين. النسخة 1: لمبتدئ تمامًا، في أقل من 80 كلمة، مع مثال واحد من العمل اليومي. النسخة 2: لمتعلّم متوسط المستوى، في أقل من 150 كلمة، مع توضيح علاقته بتحليلات البيانات وتعلّم الآلة والذكاء الاصطناعي. بعد النسختين، اذكر أي عبارات لست متأكدًا منها."
لماذا قد يفيدك هذا: رؤية الشرح على مستويين توضّح لك أي الأفكار أساسية وأيها تفاصيل إضافية. وطلبك من الذكاء الاصطناعي أن يذكر العبارات التي لا يثق بها يسهّل عليك معرفة ما يجب أن تتحقق منه.
11. التحقق من مخرجات الذكاء الاصطناعي
ما يكتبه الذكاء الاصطناعي مسودة تحتاج إلى مراجعة، وليس مصدرًا للحقيقة. افعل الآتي:
- قارن بمصدر رسمي. افتح ملخص O*NET عن علماء البيانات (انظر المصادر). هل يتفق وصف الذكاء الاصطناعي مع فكرة تحويل البيانات الخام إلى معلومات ذات معنى وكتابة تقارير بالنتائج؟ سجّل أي اختلافات.
- قارن بهذا الدرس. هل فصل الذكاء الاصطناعي بين البيانات والتحليل والنمذجة واتخاذ القرار؟ هل أوحى بأن الذكاء الاصطناعي أو النموذج هو من يتخذ القرار؟ هذا يناقض المبدأ الأساسي في هذا الدرس.
- انتبه للادعاءات المطلقة. كلمات مثل "دائمًا" أو "كل عالم بيانات" أو نسبة مئوية دقيقة بلا مصدر هي علامات تحذير. لا تكررها إلا إذا وجدت مصدرًا موثوقًا ومؤرَّخًا.
- اكتب جملة واحدة توضّح فيها ما احتفظت به، وما صحّحته، ولماذا.
الخصوصية: في هذه المهمة لا تلصق أبدًا أسماء أو عناوين بريد إلكتروني أو تفاصيل طلبات أو أي بيانات خاصة بشركة. السؤال العام لا يحتاج إلى أي معلومات خاصة.
12. منظور الأعمال
البيانات تصنع قيمة للعمل فقط عندما تغيّر قرارًا أو تحسّنه. أمثلة شائعة:
- الإيرادات: التسعير، والعروض الترويجية، وأي المنتجات تُبرَز.
- التكاليف: حجم المخزون الذي نحتفظ به، وعدد الموظفين في كل وردية.
- العملاء: من يحتاج المساعدة أولًا، ولماذا يتوقف العملاء عن الشراء.
- المخاطر: اكتشاف الطلبات غير المعتادة التي قد تكون احتيالًا.
- المنتج: أي الخصائص أو الأصناف نضيفها أو نحذفها.
اختبار مفيد: "لو جاءت الإجابة مختلفة، هل كنا سنتصرف بشكل مختلف؟" إذا كانت الإجابة لا، فقد لا يستحق السؤال الجهد.
13. مهمة عمل — مذكرة فرصة قرار
أنت تساعد صاحب متجر Cedar Lane. اكتب مذكرة قصيرة (من 60 إلى 120 كلمة) تحتوي على هذه الأجزاء:
- القرار: قرار واحد يتخذه المتجر بانتظام.
- لماذا يهم: ما يتأثر به من تكلفة أو إيراد أو عملاء أو مخاطر.
- بيانات قد تكون موجودة بالفعل: عنصران على الأقل.
- ما الذي قد يتغيّر: كيف يمكن أن يختلف القرار إذا أشار الدليل إلى اتجاه أو آخر.
14. تحدٍّ قصير
موقف جديد (خيالي): مخبز في أحد الأحياء يقرّر كل مساء عدد أرغفة الخبز التي سيخبزها للصباح التالي. الخبز غير المُباع يُرمى، ونفاده يعني خسارة مبيعات.
ابنِ سلسلة بيانات ← دليل ← قرار لهذا المخبز: 1. نوعان من البيانات يمكنه تسجيلهما؛ 2. تحليل واحد؛ 3. هل يمكن أن يفيد نموذج في المستقبل، ولماذا؛ 4. ما الدليل الذي يريده الخبّاز قبل أن يغيّر الكمية المعتادة؛ 5. من يقرّر، وعامل واحد لا يظهر في البيانات.
سلّم إجابتك قبل أن تطّلع على أي ملاحظات. الحل غير موجود هنا.
15. المصادر
- مطلوب (حوالي 10 دقائق): O*NET OnLine — صفحة ملخص Data Scientists (15-2051.00). اقرأ الوصف وقائمة "Tasks". https://www.onetonline.org/link/summary/15-2051.00 (بيانات مهنية أمريكية.)
- موصى به (حوالي 10 دقائق): U.S. Bureau of Labor Statistics — Occupational Outlook Handbook: Data Scientists، تبويب "What They Do". https://www.bls.gov/ooh/math/data-scientists.htm (يركّز على الولايات المتحدة. تجاوز تبويبات الأجور والتوقعات الآن، فهي خاصة بالولايات المتحدة وغير مطلوبة هنا.)
- للتعمّق (صوتي اختياري؛ لم يتم التحقق من مدة الحلقة): بودكاست DataFramed من DataCamp، حلقة "Decision Intelligence and Data Science" مع Cassie Kozyrkov (مسجّلة عام 2018). https://www.datacamp.com/podcast/decision-intelligence-and-data-science
16. شخصية تتابعها
تعمل Cassie Kozyrkov في مجال ذكاء القرار (decision intelligence): تحسين طريقة تحويل الأشخاص والمؤسسات للمعلومات إلى تصرفات أفضل. يصفها موقعها بأنها أول Chief Decision Scientist في Google (دور سابق). هي مرتبطة بهذا الدرس لأن عملها يُبقي التركيز على القرار، وليس على البيانات أو النموذج وحدهما.
- ابدأ من: موقعها https://www.kozyr.com/ وحلقة DataFramed لعام 2018 المذكورة أعلاه.
- اقرأ بعين ناقدة: كما مع أي خبير، قارن أفكارها بمصادر أخرى وكوّن رأيك الخاص.
17. تأمّل
قبل هذا الدرس، أين كنت تظن أن "القرار" يحدث في العمل مع البيانات: داخل البيانات، أم داخل الرسم البياني أو النموذج، أم عند شخص؟ ما الذي تغيّر في تفكيرك، إن كان شيء قد تغيّر؟
18. الخطوة التالية
تعلّمت أن البيانات تصبح دليلًا قبل أن تدعم قرارًا. في L02 — البيانات والمعلومات والاستنتاج والدليل ستنظر عن قرب إلى هذه الخطوة الوسطى، وتتدرّب على الفصل بين البيانات الخام، والمعلومات الملخّصة، والتفسيرات التي قد تكون خاطئة، والاستنتاجات التي يدعمها الدليل فعلًا.
19. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| اختبار الفهم Q1–Q8 | أنك تستطيع التعرّف على اللبنات الأساسية والمصطلحات القريبة في مواقف قصيرة | 6 إجابات صحيحة أو أكثر من 8 = يحقق المطلوب |
| التدريب المستقل (استوديو اللياقة) | أنك تستطيع تطبيق اللبنات الأربع على موقف جديد | معايير L01-IP: القرار محدد؛ سؤال يمكن للبيانات الإجابة عنه؛ نوعان معقولان من البيانات؛ تحليل واحد؛ قرار مبرَّر بشأن النموذج؛ شخص مسؤول عن القرار مع عامل واحد من خارج البيانات |
| مهمة العمل (مذكرة فرصة قرار) | أنك تستطيع ربط البيانات بقرار عمل | معايير L01-WT: قرار ملموس؛ توضيح ما يتأثر به العمل؛ عنصران على الأقل من البيانات؛ وصف لكيف يمكن أن يتغيّر القرار |
| التحدي القصير (المخبز) | أنك تستطيع نقل السلسلة إلى مجال جديد | معايير L01-MC (في ملف المدرّس) |
20. المراجع
- O*NET OnLine. Summary Report for: 15-2051.00 — Data Scientists. National Center for O*NET Development / U.S. Department of Labor. https://www.onetonline.org/link/summary/15-2051.00 (الصفحة تذكر "Updated 2026"؛ تمت زيارتها ومراجعتها في 11 أكتوبر 2026). يدعم: الوصف المهني المُعاد صياغته.
- U.S. Bureau of Labor Statistics. Occupational Outlook Handbook — Data Scientists. https://www.bls.gov/ooh/math/data-scientists.htm (تمت زيارتها في 11 أكتوبر 2026). يدعم: وصف "What They Do" المستخدم كقراءة موصى بها. يركّز على الولايات المتحدة.
- DataCamp. بودكاست DataFramed، حلقة "Decision Intelligence and Data Science" (الضيفة: Cassie Kozyrkov؛ بتاريخ 22 أكتوبر 2018). https://www.datacamp.com/podcast/decision-intelligence-and-data-science (تمت زيارتها في 11 أكتوبر 2026).
- Kozyrkov, C. الموقع الشخصي. https://www.kozyr.com/ (تمت زيارته في 11 أكتوبر 2026). يدعم: "أول Chief Decision Scientist في Google" (دور سابق) والتركيز على ذكاء القرار.
- D.World Curriculum Bible v1.0 و Curriculum Map v1.0 (وثائق داخلية). رقم الدرس، والهدف، ونقاط التركيز، والمبادئ.
L02 · Data, Information, Insight & EvidenceL02 · البيانات والمعلومات والاستنتاج والدليل Freeمجاني
L02 — Data, Information, Insight & Evidence
Learner file. Answers and model solutions are kept in a separate instructor file. Version: U01 pilot v1.0 · Content date: 11 October 2026.
1. Lesson Identity
| Field | Value |
|---|---|
| Title | Data, Information, Insight & Evidence |
| Stage | Stage 1 — Foundations |
| Unit | U01 — Data Science & the Modern Data World |
| Lesson ID | L02 |
| Skills | Analytical thinking; evidence |
| Difficulty | Beginner |
| Estimated time | About 2 hours |
| Prerequisites | L01 (the data → evidence → decision chain). Basic arithmetic: division and differences. No software needed; a calculator helps. |
Time breakdown (estimate): concept and worked example, 30 min · guided practice, 20 min · independent practice, 15 min · knowledge check (classification) and reflection, 15 min · AI in Practice and AI Verification, 15 min · workplace task, 15 min · mini challenge, 10 min.
2. Learning Objective
By the end of this lesson, you will be able to classify statements as data, information, insight (hypothesis), evidence-supported conclusion or assumption, and explain why a pattern in data is not, by itself, proof of a cause.
3. Why It Matters
Most mistakes in data work are not calculation errors. They are reasoning errors: treating a guess as a fact, or treating a pattern as proof. A manager who hears "sales fell because of the new website design" may spend money undoing the design, when the real cause was something else.
ONET lists Critical Thinking among the essential skills, and Judgment and Decision Making* among the transferable skills, for Data Scientists (US occupational data). This lesson is where you start practising both.
4. Concept
Five kinds of statements
D.World uses these working definitions. Other books use similar terms in slightly different ways, but the distinctions underneath them matter everywhere.
| Term | Plain meaning | Question it answers |
|---|---|---|
| Data | Individual recorded values, usually with little context | "What was recorded?" |
| Information | Data organized or summarized with context | "What happened?" |
| Insight (hypothesis) | An interpretation that suggests what a pattern might mean for a decision. Until it is checked, treat it as a hypothesis: a possible explanation to test | "What might this mean?" |
| Evidence-supported conclusion | A claim checked against relevant evidence, with the remaining uncertainty stated | "What can we justifiably say?" |
| Assumption | Something treated as true without checking it | "What are we taking for granted?" |
Evidence itself means information that has been checked and is relevant to testing a specific claim. The same information can be strong evidence for one question and irrelevant to another.
Key principle: do not confuse a pattern with proof
When two things move together (for example, a promotion and higher sales), that is a pattern, also called a correlation. It does not prove that one caused the other. Other explanations are often possible:
- Another factor affected both. For example, a holiday week brought more visitors and the promotion happened to run that week.
- Timing or chance: with only a few weeks of data, ups and downs happen anyway.
- Measurement problems: the data was recorded differently in one period.
A careful analyst writes the pattern as an observation, writes the possible explanation as a hypothesis, and then asks: "What evidence would make me more or less confident?"
Observed, inferred, unknown
For any finding, separate three things:
- Observed: directly visible in the data.
- Inferred: your interpretation. It may be reasonable, but it could be wrong.
- Unknown: what the data cannot tell you yet.
5. Worked Example
Synthetic data: invented for teaching. Cedar Lane is a fictional store.
Cedar Lane — weekly summary, four weeks in March
| Week | Website visits | Orders | Revenue (USD) | Promotion running |
|---|---|---|---|---|
| 1 | 4,000 | 120 | 3,000 | None |
| 2 | 4,100 | 118 | 2,950 | None |
| 3 | 4,050 | 150 | 3,300 | 10% off notebooks |
| 4 | 4,200 | 96 | 2,400 | None |
Note that this table is already information: someone has summarized thousands of individual records (the data) into weekly totals.
Step 1 — Observation (observed). Week 3 had 150 orders, the highest of the four weeks. That is 30 more than Week 1 (150 − 120 = 30).
Step 2 — A tempting claim. "The 10% promotion increased orders."
Step 3 — Classify it. The promotion and the higher orders happened in the same week. That is a pattern, so the claim is an insight stated as a hypothesis, not yet a conclusion.
Step 4 — Look for other explanations. Website visits were similar in all four weeks (4,000–4,200), so a big jump in visitors is unlikely to explain Week 3. That slightly strengthens the promotion hypothesis, but it does not prove it. Something else could also have happened in Week 3, such as a mention on social media or a school-related buying season.
Step 5 — What evidence would test it? For example: did the extra Week 3 orders mainly contain discounted notebooks? Did similar promotions in the past show the same pattern? Did anything else change that week?
Step 6 — Careful wording. "Orders were highest in the promotion week (150 vs 96–120 in other weeks), while website visits stayed similar. This is consistent with the promotion increasing orders, but we have not yet ruled out other causes."
6. Visual Explanation
DATA ----------> INFORMATION ----------> INSIGHT (hypothesis) ----------> EVIDENCE-SUPPORTED CONCLUSION
(single records) (organized summary) (possible meaning; untested) (checked; limits stated)
|
+--> "What evidence would test this?" --> collect / check
Alt text: A left-to-right sequence of four labelled stages. Data (single records) leads to Information (an organized summary), then to Insight, marked as a hypothesis that is not yet tested. A branch below Insight asks "What evidence would test this?" and leads to collecting or checking evidence. Only then does the sequence reach Evidence-supported conclusion, with its limits stated.
7. Guided Practice
Use the Cedar Lane table above. Work through each step and write your answer.
- Data: write one example of a single raw record that might sit behind this table. (Hint: one order, with date, item and amount.)
- Information: calculate the average order value (revenue ÷ orders) for each week. (Hint: Week 1 is 3,000 ÷ 120 = 25.00 USD.) What do you notice about Week 3?
- Insight (hypothesis): write one possible explanation for what you noticed in step 2, starting with "This might be because…"
- Evidence: name one piece of information that would make your hypothesis more or less likely.
- Unknown: write one thing this table cannot tell you.
8. Independent Practice
Synthetic data (invented): Cedar Lane customer-support messages over the same four weeks.
| Week | Orders | Support messages | Messages about late delivery |
|---|---|---|---|
| 1 | 120 | 12 | 3 |
| 2 | 118 | 11 | 4 |
| 3 | 150 | 21 | 11 |
| 4 | 96 | 10 | 2 |
Write: 1. two observations (facts directly visible in the table, or simple calculations from it); 2. one hypothesis, clearly labelled as a hypothesis; 3. one piece of evidence that would help test your hypothesis; 4. one thing the table cannot tell you.
No model answer is shown here.
9. Knowledge Check — Classification Exercise + Reflection
Classify each statement as A Data, B Information, C Insight (hypothesis), D Evidence-supported conclusion or E Assumption. All details are synthetic.
| # | Statement | A–E |
|---|---|---|
| 1 | "Order #2207: 3 notebooks, 12.00 USD, 14 March, 10:42." | |
| 2 | "Week 4 had 96 orders, the lowest of the four weeks." | |
| 3 | "Customers may have bought earlier because of the Week 3 discount, so Week 4 was quieter." | |
| 4 | "After checking order histories, we found that 40 of the 48 customers who bought in Week 3 and normally order every two weeks did not order in Week 4. This supports the 'bought earlier' explanation, although other causes are not fully ruled out." | |
| 5 | "The website visit numbers are correct, so we do not need to check how they were recorded." | |
| 6 | "Website visits were between 4,000 and 4,200 each week." | |
| 7 | "A visitor clicked 'Add to cart' at 09:13 on 15 March." | |
| 8 | "Average order value in Week 3 was 22 USD (3,300 ÷ 150)." |
Reflection (required, 3–5 sentences): A colleague writes, "The discount caused the drop in Week 4." Using this lesson's ideas, explain what kind of statement this currently is. Then rewrite it so that it is honest about what is known.
10. AI in Practice
Give an AI assistant only the synthetic table from the worked example (it contains no personal or company data). Prompt:
"Here is a small weekly summary from a fictional online store: [paste the 4-row table]. Sort your statements into three lists: (1) observations that can be read or calculated directly from the table, (2) hypotheses that might explain the patterns, (3) assumptions you would be making. Do not state any cause as a fact. Show every calculation."
Why this can help: the AI can quickly suggest several hypotheses you might not think of. Asking for separate lists and shown calculations makes its reasoning easier to check.
11. AI Verification
- Recalculate every number the AI gives, using the table. AI tools can make arithmetic mistakes.
- Check each "observation." Can you point to the exact cells it comes from? If not, it is not an observation.
- Hunt for causal words such as "because," "caused," "led to" or "due to" in the observations list. Move those statements to the hypotheses list.
- Check the assumptions list. Did the AI miss any? For example, that the weeks are comparable, or that visits were counted the same way each week.
- Record the result: "AI suggested __ hypotheses. I kept __, corrected __ (reason), and found __ calculation errors."
Privacy: use only synthetic or anonymized tables. Never paste real customer names, emails, addresses, order IDs or confidential company figures into a public AI tool unless your organization's policy explicitly allows it.
12. Business Lens
Businesses act on summaries every day. If an untested hypothesis ("the promotion worked") is reported as a conclusion, the company may repeat a promotion that only moved sales from one week to the next. It would then lose margin without gaining customers.
Clear separation of observations and hypotheses protects revenue (avoiding ineffective promotions), cost (avoiding wasted effort) and trust (managers learn which statements are solid).
13. Workplace Task — Weekly Sales Note
Using the Cedar Lane weekly table (Section 5), write a short note to the owner containing:
- three factual observations. Use numbers from the table or simple calculations. Do not reuse the worked example's "150 orders" observation.
- one hypothesis about Week 4, clearly labelled as a hypothesis;
- one suggested check that would help test the hypothesis.
Keep it under 120 words. Use cautious language where needed.
14. Mini Challenge
Synthetic data (invented): a small café recorded five days of drink sales.
| Day | Max temperature (°C) | Iced drinks sold | Hot drinks sold |
|---|---|---|---|
| Mon | 18 | 22 | 61 |
| Tue | 24 | 35 | 48 |
| Wed | 29 | 58 | 30 |
| Thu | 31 | 64 | 27 |
| Fri | 26 | 40 | 52 |
Write: 1. three observations; 2. one hypothesis; 3. one other factor that could also explain some of the pattern; 4. two sentences explaining why five days of data is not proof.
Submit before looking at any feedback. No solution is provided here.
15. Resources
- Required (about 5 min): ONET OnLine — Data Scientists* summary. Look at the "Essential Skills" and "Transferable Skills" lists and find Critical Thinking and Judgment and Decision Making. https://www.onetonline.org/link/summary/15-2051.00
- Recommended (optional audio; episode length not verified in this run): DataCamp DataFramed, "Decision Intelligence and Data Science" (2018), with Cassie Kozyrkov. Listen for the difference between using data for inspiration and using it for rigorous testing. https://www.datacamp.com/podcast/decision-intelligence-and-data-science
- Deeper: Claus O. Wilke, Fundamentals of Data Visualization (open online book). Browse the introduction to see how summaries and charts can inform or mislead; this topic returns in Stage 3. https://clauswilke.com/dataviz/ (Not verified in this run.)
16. Person to Follow
Cassie Kozyrkov. Her work on decision intelligence is relevant here because it separates exploring data for ideas from testing whether those ideas hold. That is the same difference as between an insight and an evidence-supported conclusion. Website: https://www.kozyr.com/ (her site lists her as Google's first Chief Decision Scientist, a past role).
17. Reflection
Think of a recent claim you heard or read that sounded like "X caused Y." Was it based on a pattern or on evidence that tested the cause? What would you need to see before believing it?
18. Next Step
You can now tell an observation from a hypothesis and a hypothesis from a supported conclusion. In L03 — What Data Scientists Actually Do, you will see the real tasks that turn data into evidence: cleaning, analysis, modeling, validation and reporting. You will also see how those tasks are shared across different roles in an organization.
19. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Classification exercise (items 1–8) | You can distinguish the five statement types | 6 or more correct out of 8 = meets |
| Reflection on "The discount caused the drop" | You recognize a causal claim stated without evidence | Rubric L02-R: identifies it as a hypothesis or unsupported claim; explains pattern vs proof; rewrites with cautious language |
| Workplace task (weekly sales note) | You can turn a table into accurate observations plus a labelled hypothesis | Rubric L02-WT: 3 correct observations; 1 labelled hypothesis; 1 relevant check; no causal over-claiming; calculations correct |
| Independent practice and mini challenge | You can transfer the skill to new data | Rubrics L02-IP and L02-MC (instructor file) |
20. References
- ONET OnLine. Summary Report for: 15-2051.00 — Data Scientists* (Essential Skills; Transferable Skills sections). https://www.onetonline.org/link/summary/15-2051.00 (accessed and checked 11 Oct 2026; page shows "Updated 2026"). Supports: Critical Thinking and Judgment and Decision Making as listed skills (US occupational data).
- DataCamp. DataFramed — "Decision Intelligence and Data Science" (22 Oct 2018). https://www.datacamp.com/podcast/decision-intelligence-and-data-science (accessed 11 Oct 2026). Supports: the episode discusses using data for inspiration vs rigorous testing (checked from the episode page description).
- Wilke, C. O. Fundamentals of Data Visualization. https://clauswilke.com/dataviz/ (listed in the D.World Resource map; not opened in this run).
- Kozyrkov, C. Website. https://www.kozyr.com/ (accessed 11 Oct 2026).
- D.World Curriculum Bible v1.0 and Curriculum Map v1.0 (internal).
L02 — البيانات والمعلومات والاستنتاج والدليل
ملف المتعلّم. الإجابات والحلول النموذجية محفوظة في ملف منفصل خاص بالمدرّس. الإصدار: U01 pilot v1.0 · تاريخ المحتوى: 11 أكتوبر 2026.
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | البيانات والمعلومات والاستنتاج والدليل |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U01 — علم البيانات وعالم البيانات الحديث |
| رقم الدرس | L02 |
| المهارات | التفكير التحليلي؛ التعامل مع الأدلة |
| المستوى | مبتدئ |
| الوقت المتوقع | حوالي ساعتين |
| المتطلبات السابقة | L01 (سلسلة بيانات ← دليل ← قرار). حساب بسيط: القسمة والفرق بين رقمين. لا تحتاج أي برامج، والآلة الحاسبة تساعد. |
تفصيل الوقت (تقديري): المفهوم والمثال المحلول 30 دقيقة · التدريب الموجَّه 20 دقيقة · التدريب المستقل 15 دقيقة · اختبار الفهم (التصنيف) والتأمّل 15 دقيقة · الذكاء الاصطناعي في التطبيق والتحقق من مخرجاته 15 دقيقة · مهمة العمل 15 دقيقة · التحدي القصير 10 دقائق.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تصنّف العبارات إلى بيانات، أو معلومات، أو استنتاج (فرضية)، أو خلاصة يدعمها الدليل، أو افتراض، وأن تشرح لماذا لا يكون النمط الموجود في البيانات، وحده، دليلًا على السبب.
3. لماذا يهمّك هذا؟
معظم الأخطاء في العمل مع البيانات ليست أخطاء حسابية، بل أخطاء في التفكير: التعامل مع تخمين على أنه حقيقة، أو مع نمط على أنه إثبات. المدير الذي يسمع أن "المبيعات انخفضت بسبب تصميم الموقع الجديد" قد ينفق المال للتراجع عن التصميم، بينما كان السبب الحقيقي شيئًا آخر.
تضع O*NET التفكير النقدي (Critical Thinking) ضمن المهارات الأساسية، والحكم واتخاذ القرار (Judgment and Decision Making) ضمن المهارات القابلة للنقل، لعلماء البيانات (بيانات مهنية أمريكية). في هذا الدرس تبدأ التدرّب على المهارتين.
4. المفهوم
خمسة أنواع من العبارات
تستخدم D.World التعريفات العملية التالية. كتب أخرى تستخدم مصطلحات مشابهة بمعانٍ مختلفة قليلًا، لكن الفروق التي تحتها مهمة في كل مكان.
| المصطلح | معناه ببساطة | السؤال الذي يجيب عنه |
|---|---|---|
| البيانات (Data) | قيم فردية مسجّلة، غالبًا بقليل من السياق | "ما الذي تم تسجيله؟" |
| المعلومات (Information) | بيانات منظمة أو ملخّصة مع سياقها | "ماذا حدث؟" |
| الاستنتاج (Insight) كفرضية | تفسير يقترح ما قد يعنيه نمط ما بالنسبة لقرار. إلى أن يتم التحقق منه، تعامل معه على أنه فرضية (hypothesis): تفسير محتمل يحتاج إلى اختبار | "ماذا قد يعني هذا؟" |
| خلاصة يدعمها الدليل (Evidence-supported conclusion) | ادعاء تم التحقق منه في مقابل أدلة مناسبة، مع ذكر ما تبقّى من عدم يقين | "ما الذي يمكننا قوله بثقة مبرَّرة؟" |
| الافتراض (Assumption) | شيء نعامله على أنه صحيح دون أن نتحقق منه | "ما الذي نعتبره مسلّمًا به؟" |
أما الدليل (Evidence) نفسه فيعني معلومات تم التحقق منها وتتعلق باختبار ادعاء محدد. نفس المعلومات قد تكون دليلًا قويًا لسؤال، ولا علاقة لها بسؤال آخر.
مبدأ أساسي: لا تخلط بين النمط والإثبات
عندما يتحرك شيئان معًا (مثل عرض ترويجي وارتفاع المبيعات)، فهذا نمط، ويسمى أيضًا ارتباطًا (correlation). وهو لا يثبت أن أحدهما سبّب الآخر. كثيرًا ما توجد تفسيرات أخرى ممكنة:
- عامل آخر أثّر في الاثنين معًا. مثلًا، أسبوع عطلة جلب زوارًا أكثر، وصادف أن العرض كان في نفس الأسبوع.
- التوقيت أو الصدفة: مع بيانات أسابيع قليلة فقط، يحدث الصعود والهبوط على أي حال.
- مشكلات في القياس: البيانات سُجّلت بطريقة مختلفة في فترة ما.
المحلل الحريص يكتب النمط على أنه ملاحظة، ويكتب التفسير المحتمل على أنه فرضية، ثم يسأل: "ما الدليل الذي سيزيد ثقتي أو يقلّلها؟"
ما نلاحظه، وما نستنتجه، وما لا نعرفه
في أي نتيجة، افصل بين ثلاثة أشياء:
- ما نلاحظه (Observed): ما يظهر في البيانات مباشرة.
- ما نستنتجه (Inferred): تفسيرك أنت. قد يكون معقولًا، لكنه قد يكون خاطئًا.
- ما لا نعرفه (Unknown): ما لا تستطيع البيانات أن تخبرك به حتى الآن.
5. مثال محلول
بيانات تركيبية: مخترعة لأغراض التعليم. Cedar Lane متجر خيالي.
Cedar Lane — ملخص أسبوعي لأربعة أسابيع في مارس
| الأسبوع | زيارات الموقع | الطلبات | الإيرادات (بالدولار) | العرض الترويجي |
|---|---|---|---|---|
| 1 | 4,000 | 120 | 3,000 | لا يوجد |
| 2 | 4,100 | 118 | 2,950 | لا يوجد |
| 3 | 4,050 | 150 | 3,300 | خصم 10% على الكراسات |
| 4 | 4,200 | 96 | 2,400 | لا يوجد |
لاحظ أن هذا الجدول هو بالفعل معلومات: شخص ما لخّص آلاف السجلات الفردية (البيانات) في مجاميع أسبوعية.
الخطوة 1 — ملاحظة (ما نلاحظه). الأسبوع 3 كان فيه 150 طلبًا، وهو الأعلى بين الأسابيع الأربعة، أي أكثر من الأسبوع 1 بـ30 طلبًا (150 − 120 = 30).
الخطوة 2 — ادعاء مُغرٍ. "خصم الـ10% زاد الطلبات."
الخطوة 3 — صنّف الادعاء. العرض وارتفاع الطلبات حدثا في نفس الأسبوع. هذا نمط، إذن الادعاء استنتاج في صورة فرضية، وليس خلاصة بعد.
الخطوة 4 — ابحث عن تفسيرات أخرى. زيارات الموقع كانت متقاربة في الأسابيع الأربعة (4,000–4,200)، فمن غير المرجح أن تفسّر قفزةٌ في عدد الزوار ما حدث في الأسبوع 3. هذا يقوّي قليلًا فرضية العرض، لكنه لا يثبتها. ربما حدث شيء آخر في الأسبوع 3، مثل إشارة للمتجر على وسائل التواصل، أو موسم شراء مرتبط بالمدارس.
الخطوة 5 — ما الدليل الذي يختبرها؟ مثلًا: هل كانت الطلبات الإضافية في الأسبوع 3 تحتوي أساسًا على الكراسات المخفّضة؟ هل أظهرت عروض مشابهة في الماضي نفس النمط؟ هل تغيّر أي شيء آخر في ذلك الأسبوع؟
الخطوة 6 — صياغة حذرة. "كانت الطلبات في أعلى مستوى لها في أسبوع العرض (150 مقابل 96–120 في الأسابيع الأخرى)، بينما ظلّت زيارات الموقع متقاربة. هذا يتّسق مع فكرة أن العرض زاد الطلبات، لكننا لم نستبعد الأسباب الأخرى بعد."
6. شرح بصري
DATA ----------> INFORMATION ----------> INSIGHT (hypothesis) ----------> EVIDENCE-SUPPORTED CONCLUSION
(single records) (organized summary) (possible meaning; untested) (checked; limits stated)
|
+--> "What evidence would test this?" --> collect / check
وصف الرسم: تسلسل من اليسار إلى اليمين لأربع مراحل: البيانات (سجلات فردية) تقود إلى المعلومات (ملخص منظم)، ثم إلى الاستنتاج، وهو موسوم كفرضية لم تُختبر بعد. يتفرّع تحت الاستنتاج سؤال: "ما الدليل الذي يختبر هذا؟"، ويقود إلى جمع الأدلة أو التحقق منها. بعد ذلك فقط يصل التسلسل إلى الخلاصة التي يدعمها الدليل، مع ذكر حدودها.
7. تدريب موجَّه
استخدم جدول Cedar Lane السابق. اعمل على كل خطوة واكتب إجابتك.
- البيانات: اكتب مثالًا واحدًا لسجل خام فردي قد يكون وراء هذا الجدول. (تلميح: طلب واحد، بتاريخه وصنفه ومبلغه.)
- المعلومات: احسب متوسط قيمة الطلب (الإيرادات ÷ الطلبات) لكل أسبوع. (تلميح: الأسبوع 1 هو 3,000 ÷ 120 = 25.00 دولارًا.) ماذا تلاحظ في الأسبوع 3؟
- الاستنتاج (فرضية): اكتب تفسيرًا محتملًا واحدًا لما لاحظته في الخطوة 2، وابدأه بعبارة "ربما يكون السبب أن…"
- الدليل: اذكر معلومة واحدة تجعل فرضيتك أكثر أو أقل احتمالًا.
- ما لا نعرفه: اكتب شيئًا واحدًا لا يستطيع هذا الجدول أن يخبرك به.
8. تدريب مستقل
بيانات تركيبية (مخترعة): رسائل دعم العملاء في Cedar Lane خلال نفس الأسابيع الأربعة.
| الأسبوع | الطلبات | رسائل الدعم | رسائل عن تأخر التوصيل |
|---|---|---|---|
| 1 | 120 | 12 | 3 |
| 2 | 118 | 11 | 4 |
| 3 | 150 | 21 | 11 |
| 4 | 96 | 10 | 2 |
اكتب: 1. ملاحظتين (حقائق ظاهرة في الجدول مباشرة، أو حسابات بسيطة منه)؛ 2. فرضية واحدة، موسومة بوضوح على أنها فرضية؛ 3. دليلًا واحدًا يساعد في اختبار فرضيتك؛ 4. شيئًا واحدًا لا يستطيع الجدول أن يخبرك به.
لا توجد إجابة نموذجية هنا.
9. اختبار الفهم — تمرين تصنيف + تأمّل
صنّف كل عبارة إلى: A بيانات، أو B معلومات، أو C استنتاج (فرضية)، أو D خلاصة يدعمها الدليل، أو E افتراض. كل التفاصيل تركيبية.
| # | العبارة | A–E |
|---|---|---|
| 1 | "الطلب رقم 2207: 3 كراسات، 12.00 دولارًا، 14 مارس، 10:42." | |
| 2 | "الأسبوع 4 كان فيه 96 طلبًا، وهو الأقل بين الأسابيع الأربعة." | |
| 3 | "ربما اشترى العملاء مبكرًا بسبب خصم الأسبوع 3، ولذلك كان الأسبوع 4 أهدأ." | |
| 4 | "بعد مراجعة سجلات الطلبات، وجدنا أن 40 من أصل 48 عميلًا اشتروا في الأسبوع 3، ويطلبون عادةً كل أسبوعين، لم يطلبوا في الأسبوع 4. هذا يدعم تفسير 'الشراء المبكر'، مع أن الأسباب الأخرى لم تُستبعد تمامًا." | |
| 5 | "أرقام زيارات الموقع صحيحة، فلا داعي للتحقق من طريقة تسجيلها." | |
| 6 | "زيارات الموقع كانت بين 4,000 و4,200 كل أسبوع." | |
| 7 | "زائر ضغط 'Add to cart' في الساعة 09:13 يوم 15 مارس." | |
| 8 | "متوسط قيمة الطلب في الأسبوع 3 كان 22 دولارًا (3,300 ÷ 150)." |
تأمّل (مطلوب، من 3 إلى 5 جمل): كتب زميل: "الخصم هو سبب الانخفاض في الأسبوع 4." باستخدام أفكار هذا الدرس، اشرح ما نوع هذه العبارة حاليًا. ثم أعد كتابتها بحيث تكون صادقة بشأن ما نعرفه فعلًا.
10. الذكاء الاصطناعي في التطبيق
أعطِ مساعد الذكاء الاصطناعي الجدول التركيبي فقط من المثال المحلول (فهو لا يحتوي على بيانات شخصية أو بيانات شركة). الطلب:
"Here is a small weekly summary from a fictional online store: [paste the 4-row table]. Sort your statements into three lists: (1) observations that can be read or calculated directly from the table, (2) hypotheses that might explain the patterns, (3) assumptions you would be making. Do not state any cause as a fact. Show every calculation."
ولو تفضّل العربية:
"هذا ملخص أسبوعي صغير من متجر إلكتروني خيالي: [الصق الجدول ذا الصفوف الأربعة]. رتّب عباراتك في ثلاث قوائم: (1) ملاحظات يمكن قراءتها أو حسابها مباشرة من الجدول، (2) فرضيات قد تفسّر الأنماط، (3) افتراضات ستكون معتمدًا عليها. لا تذكر أي سبب على أنه حقيقة. اعرض كل عملية حسابية."
لماذا قد يفيدك هذا: يستطيع الذكاء الاصطناعي أن يقترح بسرعة عدة فرضيات قد لا تخطر ببالك. وطلب قوائم منفصلة مع عرض الحسابات يجعل طريقة تفكيره أسهل في المراجعة.
11. التحقق من مخرجات الذكاء الاصطناعي
- أعد حساب كل رقم يعطيه الذكاء الاصطناعي باستخدام الجدول. أدوات الذكاء الاصطناعي قد تخطئ في الحساب.
- افحص كل "ملاحظة". هل تستطيع أن تشير إلى الخلايا التي جاءت منها بالضبط؟ إن لم تستطع، فهي ليست ملاحظة.
- ابحث عن كلمات السببية مثل "لأن" و"سبّب" و"أدى إلى" و"بسبب" في قائمة الملاحظات، وانقل هذه العبارات إلى قائمة الفرضيات.
- راجع قائمة الافتراضات. هل فات الذكاء الاصطناعي شيء؟ مثلًا: أن الأسابيع قابلة للمقارنة، أو أن الزيارات حُسبت بنفس الطريقة كل أسبوع.
- سجّل النتيجة: "اقترح الذكاء الاصطناعي __ فرضيات. احتفظت بـ__، وصحّحت __ (والسبب)، ووجدت __ أخطاء حسابية."
الخصوصية: استخدم جداول تركيبية أو مجهّلة الهوية فقط. لا تلصق أبدًا أسماء عملاء حقيقيين أو عناوين بريدهم أو عناوينهم أو أرقام طلباتهم أو أرقامًا سرية للشركة في أداة ذكاء اصطناعي عامة، إلا إذا كانت سياسة مؤسستك تسمح بذلك صراحةً.
12. منظور الأعمال
الشركات تتصرف بناءً على الملخصات كل يوم. إذا قُدّمت فرضية لم تُختبر ("العرض نجح") على أنها خلاصة، فقد تكرر الشركة عرضًا كل ما فعله أنه نقل المبيعات من أسبوع إلى الأسبوع التالي. وعندها ستخسر من هامش الربح دون أن تكسب عملاء جددًا.
الفصل الواضح بين الملاحظات والفرضيات يحمي الإيرادات (بتجنّب العروض غير الفعّالة)، والتكاليف (بتجنّب الجهد الضائع)، والثقة (لأن المديرين يعرفون أي العبارات يمكن الاعتماد عليها).
13. مهمة عمل — مذكرة المبيعات الأسبوعية
باستخدام جدول Cedar Lane الأسبوعي (القسم 5)، اكتب مذكرة قصيرة لصاحب المتجر تحتوي على:
- ثلاث ملاحظات واقعية. استخدم أرقامًا من الجدول أو حسابات بسيطة. لا تكرر ملاحظة "150 طلبًا" من المثال المحلول.
- فرضية واحدة عن الأسبوع 4، موسومة بوضوح على أنها فرضية؛
- فحصًا واحدًا مقترحًا يساعد في اختبار الفرضية.
اجعلها أقل من 120 كلمة، واستخدم لغة حذرة حيث يلزم.
14. تحدٍّ قصير
بيانات تركيبية (مخترعة): مقهى صغير سجّل مبيعات المشروبات لخمسة أيام.
| اليوم | أعلى درجة حرارة (°C) | المشروبات المثلّجة المباعة | المشروبات الساخنة المباعة |
|---|---|---|---|
| الإثنين | 18 | 22 | 61 |
| الثلاثاء | 24 | 35 | 48 |
| الأربعاء | 29 | 58 | 30 |
| الخميس | 31 | 64 | 27 |
| الجمعة | 26 | 40 | 52 |
اكتب: 1. ثلاث ملاحظات؛ 2. فرضية واحدة؛ 3. عاملًا آخر يمكن أن يفسّر جزءًا من النمط أيضًا؛ 4. جملتين توضّح فيهما لماذا لا تكون بيانات خمسة أيام إثباتًا.
سلّم إجابتك قبل أن تطّلع على أي ملاحظات. الحل غير موجود هنا.
15. المصادر
- مطلوب (حوالي 5 دقائق): O*NET OnLine — ملخص Data Scientists. انظر قائمتي "Essential Skills" و"Transferable Skills"، وابحث عن Critical Thinking وJudgment and Decision Making. https://www.onetonline.org/link/summary/15-2051.00
- موصى به (صوتي اختياري؛ لم يتم التحقق من مدة الحلقة): بودكاست DataFramed من DataCamp، حلقة "Decision Intelligence and Data Science" (2018) مع Cassie Kozyrkov. انتبه للفرق بين استخدام البيانات لاستلهام الأفكار واستخدامها للاختبار الصارم. https://www.datacamp.com/podcast/decision-intelligence-and-data-science
- للتعمّق: كتاب Claus O. Wilke بعنوان Fundamentals of Data Visualization (كتاب مفتوح على الإنترنت). تصفّح المقدمة لترى كيف يمكن للملخصات والرسوم البيانية أن تُعلِم أو تُضلّل؛ وسيعود هذا الموضوع في المرحلة 3. https://clauswilke.com/dataviz/ (لم يتم التحقق منه في هذه المراجعة.)
16. شخصية تتابعها
Cassie Kozyrkov. عملها في ذكاء القرار (decision intelligence) مرتبط بهذا الدرس، لأنه يفصل بين استكشاف البيانات بحثًا عن أفكار واختبار ما إذا كانت هذه الأفكار صحيحة. وهذا هو نفسه الفرق بين الاستنتاج والخلاصة التي يدعمها الدليل. الموقع: https://www.kozyr.com/ (يذكر موقعها أنها كانت أول Chief Decision Scientist في Google، وهو دور سابق).
17. تأمّل
فكّر في ادعاء سمعته أو قرأته مؤخرًا بصيغة "X سبّب Y". هل كان مبنيًا على نمط، أم على دليل اختبر السبب؟ ما الذي تحتاج إلى رؤيته قبل أن تصدّقه؟
18. الخطوة التالية
أصبحت تستطيع التفريق بين الملاحظة والفرضية، وبين الفرضية والخلاصة المدعومة. في L03 — ماذا يفعل علماء البيانات فعلًا سترى المهام الحقيقية التي تحوّل البيانات إلى أدلة: التنظيف، والتحليل، والنمذجة، والتحقق، وإعداد التقارير. وسترى أيضًا كيف تتوزع هذه المهام على أدوار مختلفة داخل المؤسسة.
19. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| تمرين التصنيف (البنود 1–8) | أنك تستطيع التمييز بين أنواع العبارات الخمسة | 6 إجابات صحيحة أو أكثر من 8 = يحقق المطلوب |
| التأمّل في عبارة "الخصم هو سبب الانخفاض" | أنك تتعرّف على ادعاء سببي قيل بلا دليل | معايير L02-R: يحدد أنها فرضية أو ادعاء غير مدعوم؛ يشرح الفرق بين النمط والإثبات؛ يعيد الصياغة بلغة حذرة |
| مهمة العمل (مذكرة المبيعات الأسبوعية) | أنك تستطيع تحويل جدول إلى ملاحظات دقيقة مع فرضية موسومة | معايير L02-WT: 3 ملاحظات صحيحة؛ فرضية واحدة موسومة؛ فحص واحد مناسب؛ لا مبالغة في ادعاء السببية؛ الحسابات صحيحة |
| التدريب المستقل والتحدي القصير | أنك تستطيع نقل المهارة إلى بيانات جديدة | معايير L02-IP وL02-MC (في ملف المدرّس) |
20. المراجع
- O*NET OnLine. Summary Report for: 15-2051.00 — Data Scientists (قسما Essential Skills وTransferable Skills). https://www.onetonline.org/link/summary/15-2051.00 (تمت زيارتها ومراجعتها في 11 أكتوبر 2026؛ الصفحة تذكر "Updated 2026"). يدعم: إدراج Critical Thinking وJudgment and Decision Making ضمن المهارات (بيانات مهنية أمريكية).
- DataCamp. DataFramed — "Decision Intelligence and Data Science" (22 أكتوبر 2018). https://www.datacamp.com/podcast/decision-intelligence-and-data-science (تمت زيارتها في 11 أكتوبر 2026). يدعم: الحلقة تناقش استخدام البيانات لاستلهام الأفكار مقابل الاختبار الصارم (تم التحقق من وصف صفحة الحلقة).
- Wilke, C. O. Fundamentals of Data Visualization. https://clauswilke.com/dataviz/ (مدرج في خريطة مصادر D.World؛ لم يُفتح في هذه المراجعة).
- Kozyrkov, C. الموقع الشخصي. https://www.kozyr.com/ (تمت زيارته في 11 أكتوبر 2026).
- D.World Curriculum Bible v1.0 و Curriculum Map v1.0 (وثائق داخلية).
L03 · What Data Scientists Actually DoL03 · ماذا يفعل علماء البيانات فعلًا Freeمجاني
L03 — What Data Scientists Actually Do
Learner file. Answers and model solutions are kept in a separate instructor file. Version: U01 pilot v1.0 · Content date: 11 October 2026.
1. Lesson Identity
| Field | Value |
|---|---|
| Title | What Data Scientists Actually Do |
| Stage | Stage 1 — Foundations |
| Unit | U01 — Data Science & the Modern Data World |
| Lesson ID | L03 |
| Skills | Role awareness; workflow |
| Difficulty | Beginner |
| Estimated time | About 1 hour 45 minutes |
| Prerequisites | L01 (data, analysis, modeling, decision) and L02 (observation vs hypothesis vs supported conclusion). |
Time breakdown (estimate): concept, worked example and O*NET reading, 35 min · guided practice, 15 min · independent practice, 15 min · role-to-task matching, 10 min · AI in Practice and AI Verification, 15 min · workplace task, 10 min · mini challenge, 5–10 min.
2. Learning Objective
By the end of this lesson, you will be able to describe the common tasks of Data Science work (problem framing, data collection, processing, analysis, modeling, validation, visualization, interpretation and reporting) and match typical tasks to roles and to the business purpose they serve.
3. Why It Matters
Many beginners imagine Data Science as "building AI models all day." Real work is broader. A lot of time goes into understanding the problem, preparing data, checking results and explaining them to people who will act.
Knowing the real tasks helps you choose what to learn and read job descriptions realistically. It also helps you understand how your work connects to colleagues such as analysts, engineers and managers.
4. Concept
Plain-language version
A Data Scientist helps an organization answer important questions with data. The work usually follows the principle problem → data → analysis → communication:
- Problem: understand what the business needs to decide.
- Data: find, collect and prepare the right data.
- Analysis: examine the data; sometimes build and test a model.
- Communication: explain results, limits and options so someone can act.
What official occupational data says
ONET, a US government occupational database, lists 17 tasks for Data Scientists (page updated 2026). Grouping them by workflow phase gives a realistic picture. Short task statements below are quoted from ONET; the grouping is D.World's.
| Workflow phase | Examples of O*NET Data Scientist tasks |
|---|---|
| Problem framing | "Identify business problems or management objectives that can be addressed through data analysis." · "Interview stakeholders to identify questions or problems to address through data analysis." |
| Data collection | "Design surveys, opinion polls, or other instruments to collect data." · Applying sampling techniques |
| Processing and cleaning | "Clean and manipulate raw data using statistical software." · Analyzing, manipulating or processing large data sets |
| Analysis | "Identify relationships and trends or any factors that could affect the results of research." |
| Modeling and validation | "Test, validate, and reformulate models to ensure accurate prediction of outcomes of interest." · Comparing models using performance metrics · Applying feature selection |
| Programming | "Write new functions or applications in programming languages to conduct analyses." |
| Visualization | "Create graphs, charts, or other visualizations to convey the results of data analysis using specialized software." |
| Interpretation and recommendation | "Recommend data-driven solutions to key stakeholders." · Identifying solutions to business problems such as budgeting, staffing and marketing decisions |
| Reporting | Delivering oral or written presentations of results to management or other users |
| Keeping up to date | Reading articles and research to identify emerging methods and technologies |
Notice two things. First, validation (checking whether a model or result is reliable) is an explicit task. It connects directly to L02's "pattern is not proof." Second, the list starts and ends with people: stakeholders, management, end users.
Roles vary: common patterns, not fixed rules
Job titles are not standardized across companies or countries. The table below shows common patterns, not universal job descriptions. In a small company one person may do all of these. In a large company each may be a separate team.
| Role (common title) | Typical focus |
|---|---|
| Data Analyst | Describing what happened: reports, dashboards, answering business questions with existing data |
| Data Scientist | Framing questions, deeper analysis, statistical modeling or ML when useful, validation, recommendations (see O*NET) |
| Data Engineer | Building and maintaining the systems that collect, store and move data reliably |
| Machine Learning Engineer | Turning tested models into reliable software and monitoring them in use |
| Business stakeholder / decision owner | Owning the decision and its consequences: sets goals, weighs trade-offs, decides |
This lesson does not promise what any particular job will involve. Always read the specific job description.
5. Worked Example
Scenario (fictional): In L02 you saw Cedar Lane's Week 4 orders drop to 96. The owner asks a part-time data scientist to look into it. Here is how the work maps to the tasks above:
- Problem framing: a short conversation with the owner (ONET: interview stakeholders). The real decision turns out to be: "Should we run another 10% promotion next month?" Business purpose: revenue*.
- Data: export order histories and promotion dates. Check that Week 4's data is complete; for example, no missing days because of a system outage.
- Processing: remove test orders the owner placed, and make the date formats consistent (O*NET: clean and manipulate raw data).
- Analysis: compare how often regular customers ordered before, during and after the promotion (O*NET: identify relationships and trends).
- Validation: check whether the same pattern appeared after an earlier promotion. One episode is weak evidence.
- Visualization and reporting: one clear chart of weekly orders with the promotion week marked, plus three sentences of findings and limits (O*NET: create visualizations; deliver presentations).
- Recommendation: "Run a smaller test before repeating the promotion store-wide" (ONET: recommend data-driven solutions). The owner decides.*
No model was needed here. The value came from framing, careful analysis, validation and clear communication.
6. Visual Explanation
PROBLEM ----------> DATA ----------> ANALYSIS ----------> COMMUNICATION ------> DECISION (owner)
frame the question collect, clean explore, model?, visualize, report,
with stakeholders check quality VALIDATE recommend options
Alt text: Five stages from left to right: Problem (frame the question with stakeholders), Data (collect, clean, check quality), Analysis (explore, possibly model, validate, with validate shown in capitals), Communication (visualize, report, recommend options), and finally Decision, labelled as made by the owner.
7. Guided Practice
For each ONET task below, write (a) the workflow phase from Section 4 and (b) the main business purpose it serves in the Cedar Lane context: cost, revenue, customer, risk or product*. Some tasks can serve more than one purpose; choose the most likely one and give a short reason.
| # | O*NET task (quoted or summarized) | Cedar Lane context | Phase | Purpose |
|---|---|---|---|---|
| 1 | "Clean and manipulate raw data using statistical software." | Preparing order records before checking for unusual (possibly fraudulent) orders | ||
| 2 | "Create graphs, charts, or other visualizations…" | A chart showing which product categories bring in the most revenue | ||
| 3 | "Interview stakeholders to identify questions or problems…" | Talking with the person who packs orders about why shipping costs are rising | ||
| 4 | "Recommend data-driven solutions to key stakeholders." | Suggesting which customers should receive a "we miss you" email | ||
| 5 | "Test, validate, and reformulate models…" | Checking a model that estimates next month's demand so the store does not overstock |
Hints: "Phase" means when in the workflow it happens. "Purpose" means why the business cares. Overstocking ties up money, which is a cost.
8. Independent Practice
Fictional job advertisement for a "Junior Data Scientist" at an invented delivery company:
- Work with operations managers to understand delivery-delay problems.
- Clean and combine delivery logs from two systems.
- Build dashboards showing on-time delivery by region.
- Test simple models that estimate delivery time.
- Present findings and recommendations to the operations team every month.
- Maintain the company's cloud database servers.
Answer: 1. Which advertisement items match ONET Data Scientist tasks? Name the matching task idea for each. 2. Which item is not in ONET's Data Scientist task list, and which common role from Section 4 more typically does it? 3. In two sentences: what does this tell you about job titles?
No model answer is shown here.
9. Knowledge Check — Role-to-Task Matching
Part A. For each task, choose the role that most typically owns it: A Data Analyst · B Data Scientist · C Data Engineer · D Machine Learning Engineer · E Business stakeholder / decision owner. Real organizations vary. If you think another role could also do it, add a one-line reason.
| # | Task | Role |
|---|---|---|
| 1 | Build and maintain an automated process that loads daily order data into a database | |
| 2 | Produce a weekly dashboard of sales by category for managers | |
| 3 | Test and compare prediction models for next month's demand | |
| 4 | Put a tested model into the live website and monitor that it keeps working | |
| 5 | Decide whether to switch to a different delivery company | |
| 6 | Interview managers to find out which business question matters most | |
| 7 | Clean raw customer-survey responses before analysis | |
| 8 | Present results and recommended options to management |
Part B. Match each task to its main business purpose (cost, revenue, customer, risk, product):
| # | Task | Purpose |
|---|---|---|
| 9 | Flag unusual orders that may be fraudulent | |
| 10 | Find which features customers use least in the store's mobile app | |
| 11 | Estimate demand to avoid buying too much stock | |
| 12 | Identify customers who have not ordered for 90 days so they can be contacted | |
| 13 | Compare promotion options by expected extra sales |
10. AI in Practice
Prompt an AI assistant:
"Simulate a realistic single workday for a junior Data Scientist at a small online retailer. List the activities hour by hour. Then, for each activity, say whether it is mainly problem framing, data preparation, analysis, modeling, validation, visualization, or communication. Mark any activity you are unsure is typical."
Why this can help: a concrete "day" makes abstract tasks easier to picture. Labelling each activity by phase lets you compare it directly with O*NET.
11. AI Verification
- Open the ONET Tasks list (Resources). For each AI activity, write the ONET task it matches, or "not listed."
- For "not listed" items, decide whether they are plausible extras (such as a team meeting) or exaggerations (such as "trains deep-learning models every day").
- Check for over-generalization: does the AI describe one type of company as if it were universal? O*NET is US data and is itself a general description.
- Count how much of the simulated day is communication and validation vs modeling. Note whether the AI over-weighted modeling compared with the task list.
- Write two sentences: what the AI got right and what it distorted.
Privacy: this prompt needs no personal or company data. Do not add any.
12. Business Lens
Every task should connect to why the business cares:
- Cost: demand estimates that prevent overstocking; finding wasted spending.
- Revenue: evaluating promotions and pricing.
- Customer: finding customers who are likely to leave, or improving service.
- Risk: detecting fraud and checking whether results are reliable before acting.
- Product: learning which features or items customers use or ignore.
A task that cannot be linked to any decision or purpose should be questioned. It may still be useful (for example, learning a new method), but it should not crowd out work that drives decisions.
13. Workplace Task — Mini Task Plan
Cedar Lane's owner wants to know whether to keep selling a slow-moving product line (desk lamps). Write a task plan of 5 steps in order. For each step give: the task, the role that would typically do it (in a small company this may be you), and the business purpose. Finish with one sentence naming who makes the final decision.
14. Mini Challenge
New scenario (fictional): A regional bus company wants to reduce the number of late buses.
- List four tasks a Data Scientist might do, in workflow order.
- Link each task to an O*NET task idea.
- Name one task that belongs to a Data Engineer and one decision that belongs to a manager, not to the data team.
- State one business purpose (cost, revenue, customer, risk or product) and explain it in one sentence.
Submit before any feedback. No solution is provided here.
15. Resources
- Required (about 15 min): ONET OnLine — Data Scientists (15-2051.00), the Tasks and Work Activities sections. https://www.onetonline.org/link/summary/15-2051.00 (US occupational data; updated 2026.)*
- Recommended (about 10 min): U.S. Bureau of Labor Statistics — Data Scientists, "What They Do" tab. https://www.bls.gov/ooh/math/data-scientists.htm (US-focused. This lesson does not use its pay or outlook data.)
- Deeper (optional): DataCamp DataFramed, "Decision Intelligence and Data Science" (2018). The discussion covers how organizations place data scientists in teams. https://www.datacamp.com/podcast/decision-intelligence-and-data-science
16. Person to Follow
Note on the source map: for this lesson, the D.World curriculum map lists "ONET occupational practice" in the role-model field. That is a source, not a person. The suggestion below is provisional* and needs curriculum-owner approval.
Provisional suggestion: Cassie Kozyrkov. She is relevant here because her public work discusses where data scientists sit in organizations and how their work connects to decision-makers (for example, in the 2018 DataFramed episode). Her website lists her as Google's first Chief Decision Scientist (a past role). https://www.kozyr.com/
17. Reflection
Before this lesson, what share of a Data Scientist's work did you think was "building models"? After reading the O*NET tasks, what would you now estimate, and why did your estimate change (or not)?
18. Next Step
You now know the tasks and who typically does them. In L04 — The Modern Data Workflow & Where AI Fits, you will connect these tasks into one end-to-end workflow, from business problem to measured result. You will then decide carefully where AI can speed up the work and where human validation must stay in control.
19. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Role-to-task matching (Parts A and B) | You can link tasks to typical roles and business purposes | Part A: 6 or more of 8 matching the key or with an accepted justified alternative. Part B: 4 or more of 5 |
| Independent practice (job ad) | You can compare a real-style job description with occupational data | Rubric L03-IP |
| Workplace task (task plan) | You can sequence tasks and connect them to roles and purposes | Rubric L03-WT: logical order; plausible roles; a purpose for each step; decision owner named |
| Mini challenge (bus company) | You can transfer to a new domain | Rubric L03-MC |
20. References
- ONET OnLine. Summary Report for: 15-2051.00 — Data Scientists*, Tasks section (17 tasks). https://www.onetonline.org/link/summary/15-2051.00 (accessed and checked 11 Oct 2026; "Updated 2026"). Supports: all quoted task statements and the 17-task count. The grouping into phases is D.World's interpretation.
- U.S. Bureau of Labor Statistics. Occupational Outlook Handbook — Data Scientists, "What Data Scientists Do." https://www.bls.gov/ooh/math/data-scientists.htm (accessed 11 Oct 2026). Supports: the duties summary (gathering, cleaning, analysing, modeling, visualizing and recommending).
- DataCamp. DataFramed — "Decision Intelligence and Data Science" (22 Oct 2018). https://www.datacamp.com/podcast/decision-intelligence-and-data-science (accessed 11 Oct 2026).
- Role descriptions for Data Analyst, Data Engineer and ML Engineer are D.World's summary of common patterns. No single official source was used, and they are presented as variable, not standardized (see the source log).
- D.World Curriculum Map v1.0 (internal). L03 row: objective, assessment type, key principle.
L03 — ماذا يفعل علماء البيانات فعلًا
ملف المتعلّم. الإجابات والحلول النموذجية محفوظة في ملف منفصل خاص بالمدرّس. الإصدار: U01 pilot v1.0 · تاريخ المحتوى: 11 أكتوبر 2026.
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | ماذا يفعل علماء البيانات فعلًا |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U01 — علم البيانات وعالم البيانات الحديث |
| رقم الدرس | L03 |
| المهارات | فهم الأدوار؛ سير العمل |
| المستوى | مبتدئ |
| الوقت المتوقع | حوالي ساعة و45 دقيقة |
| المتطلبات السابقة | L01 (البيانات، التحليل، النمذجة، القرار) وL02 (الملاحظة مقابل الفرضية مقابل الخلاصة المدعومة). |
تفصيل الوقت (تقديري): المفهوم والمثال المحلول وقراءة O*NET 35 دقيقة · التدريب الموجَّه 15 دقيقة · التدريب المستقل 15 دقيقة · مطابقة الأدوار بالمهام 10 دقائق · الذكاء الاصطناعي في التطبيق والتحقق من مخرجاته 15 دقيقة · مهمة العمل 10 دقائق · التحدي القصير 5–10 دقائق.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تصف المهام الشائعة في عمل علم البيانات (تحديد المشكلة، جمع البيانات، معالجتها، التحليل، النمذجة، التحقق، التصوير البصري، التفسير، إعداد التقارير)، وأن تطابق المهام المعتادة مع الأدوار ومع الهدف التجاري الذي تخدمه.
3. لماذا يهمّك هذا؟
كثير من المبتدئين يتخيّلون علم البيانات على أنه "بناء نماذج ذكاء اصطناعي طوال اليوم". العمل الحقيقي أوسع من ذلك. جزء كبير من الوقت يذهب إلى فهم المشكلة، وتجهيز البيانات، ومراجعة النتائج، وشرحها للأشخاص الذين سيتصرفون بناءً عليها.
معرفة المهام الحقيقية تساعدك على اختيار ما تتعلّمه، وعلى قراءة إعلانات الوظائف بواقعية. وتساعدك أيضًا على فهم كيف يرتبط عملك بعمل زملائك، مثل المحللين والمهندسين والمديرين.
4. المفهوم
الشرح بلغة بسيطة
عالم البيانات (Data Scientist) يساعد المؤسسة على الإجابة عن أسئلة مهمة باستخدام البيانات. يسير العمل عادةً وفق المبدأ مشكلة ← بيانات ← تحليل ← تواصل:
- المشكلة: افهم ما الذي تحتاج المؤسسة إلى أن تقرّره.
- البيانات: ابحث عن البيانات المناسبة، واجمعها، وجهّزها.
- التحليل: افحص البيانات، وأحيانًا ابنِ نموذجًا واختبره.
- التواصل: اشرح النتائج وحدودها والخيارات المتاحة، حتى يستطيع شخص ما أن يتصرّف.
ماذا تقول البيانات المهنية الرسمية؟
O*NET قاعدة بيانات حكومية أمريكية للمهن، وهي تذكر 17 مهمة لعلماء البيانات (الصفحة محدّثة في 2026). عندما نجمّع هذه المهام حسب مراحل سير العمل نحصل على صورة واقعية. عبارات المهام القصيرة في الجدول منقولة كما هي من O*NET، أما التجميع في مراحل فهو من D.World.
| مرحلة سير العمل | أمثلة من مهام عالم البيانات في O*NET |
|---|---|
| تحديد المشكلة | "Identify business problems or management objectives that can be addressed through data analysis." (تحديد مشكلات العمل أو أهداف الإدارة التي يمكن معالجتها بتحليل البيانات) · "Interview stakeholders to identify questions or problems to address through data analysis." (مقابلة أصحاب المصلحة لتحديد الأسئلة أو المشكلات التي يعالجها تحليل البيانات) |
| جمع البيانات | "Design surveys, opinion polls, or other instruments to collect data." (تصميم استبيانات أو استطلاعات رأي أو أدوات أخرى لجمع البيانات) · تطبيق أساليب أخذ العيّنات |
| المعالجة والتنظيف | "Clean and manipulate raw data using statistical software." (تنظيف البيانات الخام ومعالجتها باستخدام برامج إحصائية) · تحليل مجموعات بيانات كبيرة ومعالجتها |
| التحليل | "Identify relationships and trends or any factors that could affect the results of research." (تحديد العلاقات والاتجاهات وأي عوامل قد تؤثر في نتائج البحث) |
| النمذجة والتحقق | "Test, validate, and reformulate models to ensure accurate prediction of outcomes of interest." (اختبار النماذج والتحقق منها وإعادة صياغتها لضمان دقة التنبؤ بالنتائج المطلوبة) · مقارنة النماذج باستخدام مقاييس الأداء · تطبيق اختيار المتغيرات (feature selection) |
| البرمجة | "Write new functions or applications in programming languages to conduct analyses." (كتابة دوال أو تطبيقات جديدة بلغات البرمجة لإجراء التحليلات) |
| التصوير البصري | "Create graphs, charts, or other visualizations to convey the results of data analysis using specialized software." (إنشاء رسوم بيانية أو مخططات أو تصويرات أخرى لنقل نتائج التحليل باستخدام برامج متخصصة) |
| التفسير والتوصية | "Recommend data-driven solutions to key stakeholders." (التوصية بحلول مبنية على البيانات لأصحاب المصلحة الرئيسيين) · إيجاد حلول لمشكلات العمل مثل قرارات الميزانية والتوظيف والتسويق |
| إعداد التقارير | تقديم عروض شفهية أو مكتوبة للنتائج إلى الإدارة أو المستخدمين الآخرين |
| مواكبة الجديد | قراءة المقالات والأبحاث للتعرّف على الأساليب والتقنيات الناشئة |
لاحظ أمرين. الأول: التحقق (validation)، أي فحص ما إذا كان النموذج أو النتيجة جديرًا بالثقة، مهمة صريحة في القائمة. وهذا مرتبط مباشرة بقاعدة L02: "النمط ليس إثباتًا". الثاني: القائمة تبدأ وتنتهي بالناس: أصحاب المصلحة، والإدارة، والمستخدمون النهائيون.
الأدوار تختلف: أنماط شائعة، لا قواعد ثابتة
المسميات الوظيفية غير موحّدة بين الشركات أو الدول. الجدول التالي يعرض أنماطًا شائعة، وليس توصيفات وظيفية عامة تنطبق في كل مكان. في شركة صغيرة قد يقوم شخص واحد بكل هذه الأدوار، وفي شركة كبيرة قد يكون كل دور فريقًا مستقلًا.
| الدور (المسمى الشائع) | التركيز المعتاد |
|---|---|
| محلل البيانات (Data Analyst) | وصف ما حدث: تقارير، ولوحات متابعة (dashboards)، والإجابة عن أسئلة العمل من البيانات الموجودة |
| عالم البيانات (Data Scientist) | صياغة الأسئلة، وتحليل أعمق، ونمذجة إحصائية أو تعلّم الآلة عند الحاجة، والتحقق، والتوصيات (راجع O*NET) |
| مهندس البيانات (Data Engineer) | بناء الأنظمة التي تجمع البيانات وتخزّنها وتنقلها بشكل موثوق، وصيانة هذه الأنظمة |
| مهندس تعلّم الآلة (Machine Learning Engineer) | تحويل النماذج المختبرة إلى برمجيات موثوقة، ومراقبتها أثناء الاستخدام |
| صاحب المصلحة في العمل / صاحب القرار | امتلاك القرار وتحمّل نتائجه: يحدد الأهداف، ويوازن بين المكاسب والتنازلات، ويقرّر |
هذا الدرس لا يَعِد بما ستتضمنه أي وظيفة بعينها. اقرأ دائمًا التوصيف الوظيفي المحدد.
5. مثال محلول
السيناريو (خيالي): في L02 رأيت أن طلبات Cedar Lane في الأسبوع 4 انخفضت إلى 96. يطلب صاحب المتجر من عالم بيانات يعمل بدوام جزئي أن يبحث في الأمر. إليك كيف يتوزّع العمل على المهام السابقة:
- تحديد المشكلة: حديث قصير مع صاحب المتجر (O*NET: مقابلة أصحاب المصلحة). يتبيّن أن القرار الحقيقي هو: "هل نكرر خصم الـ 10% الشهر القادم؟" الهدف التجاري: الإيرادات.
- البيانات: تصدير سجلات الطلبات وتواريخ العروض. التأكد من أن بيانات الأسبوع 4 مكتملة، مثلًا لا توجد أيام ناقصة بسبب عطل في النظام.
- المعالجة: حذف الطلبات التجريبية التي سجّلها صاحب المتجر، وتوحيد صيغ التواريخ (O*NET: تنظيف البيانات الخام ومعالجتها).
- التحليل: مقارنة عدد مرات طلب العملاء الدائمين قبل العرض وأثناءه وبعده (O*NET: تحديد العلاقات والاتجاهات).
- التحقق: فحص ما إذا كان النمط نفسه قد ظهر بعد عرض سابق. حالة واحدة دليل ضعيف.
- التصوير البصري والتقرير: رسم بياني واحد واضح للطلبات الأسبوعية مع تمييز أسبوع العرض، وثلاث جمل عن النتائج وحدودها (O*NET: إنشاء التصويرات؛ تقديم العروض).
- التوصية: "جرّبوا اختبارًا أصغر قبل تكرار العرض على المتجر كله" (O*NET: التوصية بحلول مبنية على البيانات). القرار لصاحب المتجر.
لم نحتج هنا إلى أي نموذج. القيمة جاءت من تحديد المشكلة جيدًا، والتحليل الدقيق، والتحقق، والتواصل الواضح.
6. شرح بصري
PROBLEM ----------> DATA ----------> ANALYSIS ----------> COMMUNICATION ------> DECISION (owner)
frame the question collect, clean explore, model?, visualize, report,
with stakeholders check quality VALIDATE recommend options
وصف الرسم: خمس مراحل من اليسار إلى اليمين: المشكلة (Problem: صياغة السؤال مع أصحاب المصلحة)، ثم البيانات (Data: الجمع والتنظيف وفحص الجودة)، ثم التحليل (Analysis: الاستكشاف، وربما النمذجة، ثم التحقق، وكلمة VALIDATE مكتوبة بحروف كبيرة)، ثم التواصل (Communication: التصوير البصري، والتقرير، واقتراح الخيارات)، وأخيرًا القرار (Decision)، ومكتوب أنه يتخذه صاحب العمل.
7. تدريب موجَّه
لكل مهمة من مهام O*NET التالية، اكتب (أ) مرحلة سير العمل من القسم 4، و(ب) الهدف التجاري الرئيسي الذي تخدمه في سياق Cedar Lane: التكلفة، أو الإيرادات، أو العملاء، أو المخاطر، أو المنتج. بعض المهام قد تخدم أكثر من هدف؛ اختر الأرجح واذكر سببًا قصيرًا.
| # | مهمة O*NET (منقولة أو ملخّصة) | السياق في Cedar Lane | المرحلة | الهدف |
|---|---|---|---|---|
| 1 | "Clean and manipulate raw data using statistical software." | تجهيز سجلات الطلبات قبل البحث عن الطلبات غير المعتادة (التي قد تكون احتيالًا) | ||
| 2 | "Create graphs, charts, or other visualizations…" | رسم بياني يوضح أي فئات المنتجات تجلب أكبر إيرادات | ||
| 3 | "Interview stakeholders to identify questions or problems…" | الحديث مع الشخص الذي يغلّف الطلبات عن سبب ارتفاع تكاليف الشحن | ||
| 4 | "Recommend data-driven solutions to key stakeholders." | اقتراح العملاء الذين يجب أن تصلهم رسالة "افتقدناك" | ||
| 5 | "Test, validate, and reformulate models…" | فحص نموذج يقدّر الطلب في الشهر القادم حتى لا يشتري المتجر مخزونًا زائدًا |
تلميحات: "المرحلة" تعني متى يحدث الشيء في سير العمل. "الهدف" يعني لماذا يهتم به العمل. المخزون الزائد يجمّد المال، وهذه تكلفة.
8. تدريب مستقل
إعلان وظيفة خيالي لوظيفة "Junior Data Scientist" (عالم بيانات مبتدئ) في شركة توصيل مختلَقة:
- العمل مع مديري العمليات لفهم مشكلات تأخر التوصيل.
- تنظيف سجلات التوصيل من نظامين ودمجها.
- بناء لوحات متابعة تعرض نسبة التوصيل في الموعد حسب المنطقة.
- اختبار نماذج بسيطة تقدّر وقت التوصيل.
- عرض النتائج والتوصيات على فريق العمليات كل شهر.
- صيانة خوادم قواعد البيانات السحابية الخاصة بالشركة.
أجب عن الأسئلة التالية:
- أي بنود الإعلان تطابق مهام عالم البيانات في O*NET؟ اذكر فكرة المهمة المطابقة لكل بند.
- أي بند ليس ضمن قائمة مهام عالم البيانات في O*NET؟ وأي دور شائع من القسم 4 يقوم به عادةً؟
- في جملتين: ماذا يخبرك هذا عن المسميات الوظيفية؟
لا توجد إجابة نموذجية هنا.
9. اختبار الفهم — مطابقة الأدوار بالمهام
الجزء A. لكل مهمة، اختر الدور الذي يتولاها في أغلب الأحيان: A محلل البيانات · B عالم البيانات · C مهندس البيانات · D مهندس تعلّم الآلة · E صاحب المصلحة في العمل / صاحب القرار. المؤسسات الحقيقية تختلف؛ إذا رأيت أن دورًا آخر قد يقوم بالمهمة أيضًا، فأضف سطرًا واحدًا تشرح فيه السبب.
| # | المهمة | الدور |
|---|---|---|
| 1 | بناء عملية آلية تُحمّل بيانات الطلبات اليومية إلى قاعدة بيانات، وصيانتها | |
| 2 | إعداد لوحة متابعة أسبوعية للمبيعات حسب الفئة للمديرين | |
| 3 | اختبار نماذج للتنبؤ بالطلب في الشهر القادم ومقارنتها | |
| 4 | وضع نموذج مختبَر داخل الموقع الحي ومراقبة استمراره في العمل | |
| 5 | تقرير ما إذا كان المتجر سينتقل إلى شركة توصيل أخرى | |
| 6 | مقابلة المديرين لمعرفة أي سؤال عمل هو الأهم | |
| 7 | تنظيف ردود استبيان العملاء الخام قبل التحليل | |
| 8 | عرض النتائج والخيارات الموصى بها على الإدارة |
الجزء B. طابق كل مهمة مع هدفها التجاري الرئيسي (التكلفة، الإيرادات، العملاء، المخاطر، المنتج):
| # | المهمة | الهدف |
|---|---|---|
| 9 | تمييز الطلبات غير المعتادة التي قد تكون احتيالًا | |
| 10 | معرفة أقل الخصائص استخدامًا من العملاء في تطبيق المتجر على الموبايل | |
| 11 | تقدير الطلب لتجنّب شراء مخزون أكثر من اللازم | |
| 12 | تحديد العملاء الذين لم يطلبوا منذ 90 يومًا للتواصل معهم | |
| 13 | مقارنة خيارات العروض حسب المبيعات الإضافية المتوقعة |
10. الذكاء الاصطناعي في التطبيق
اكتب لمساعد ذكاء اصطناعي (AI assistant) الطلب التالي:
"Simulate a realistic single workday for a junior Data Scientist at a small online retailer. List the activities hour by hour. Then, for each activity, say whether it is mainly problem framing, data preparation, analysis, modeling, validation, visualization, or communication. Mark any activity you are unsure is typical."
وبالعربية: "حاكِ يوم عمل واقعيًا واحدًا لعالم بيانات مبتدئ في متجر إلكتروني صغير. اذكر الأنشطة ساعة بساعة. ثم لكل نشاط، قل هل هو أساسًا تحديد مشكلة، أو تجهيز بيانات، أو تحليل، أو نمذجة، أو تحقق، أو تصوير بصري، أو تواصل. ميّز أي نشاط لست متأكدًا من أنه معتاد."
لماذا قد يفيد هذا: "اليوم" الملموس يجعل المهام المجردة أسهل في التخيّل. وتصنيف كل نشاط حسب المرحلة يتيح لك مقارنته مباشرة بقائمة O*NET.
11. التحقق من مخرجات الذكاء الاصطناعي
- افتح قائمة Tasks في O*NET (راجع المصادر). لكل نشاط ذكره الذكاء الاصطناعي، اكتب مهمة O*NET التي تطابقه، أو "غير مذكور".
- بالنسبة للبنود "غير المذكورة"، قرّر هل هي إضافات معقولة (مثل اجتماع الفريق) أم مبالغات (مثل "يدرّب نماذج تعلّم عميق كل يوم").
- افحص التعميم الزائد: هل يصف الذكاء الاصطناعي نوعًا واحدًا من الشركات كأنه القاعدة في كل مكان؟ تذكّر أن O*NET بيانات أمريكية، وهي نفسها وصف عام.
- احسب نصيب التواصل والتحقق من اليوم المُحاكى مقارنةً بالنمذجة. لاحظ هل أعطى الذكاء الاصطناعي النمذجة وزنًا أكبر مما في قائمة المهام.
- اكتب جملتين: ما الذي أصاب فيه الذكاء الاصطناعي، وما الذي شوّهه.
الخصوصية: هذا الطلب لا يحتاج أي بيانات شخصية أو بيانات شركة. لا تضف أيًا منها.
12. منظور الأعمال
كل مهمة يجب أن ترتبط بسبب اهتمام العمل بها:
- التكلفة: تقديرات الطلب التي تمنع المخزون الزائد؛ اكتشاف الإنفاق المهدر.
- الإيرادات: تقييم العروض والتسعير.
- العملاء: اكتشاف العملاء المرجّح أن يتركوا، أو تحسين الخدمة.
- المخاطر: كشف الاحتيال، والتأكد من أن النتائج جديرة بالثقة قبل التصرف بناءً عليها.
- المنتج: معرفة أي الخصائص أو المنتجات يستخدمها العملاء وأيها يتجاهلونها.
المهمة التي لا يمكن ربطها بأي قرار أو هدف يجب أن تُراجَع. قد تظل مفيدة (مثل تعلّم أسلوب جديد)، لكن لا ينبغي أن تزاحم العمل الذي يقود القرارات.
13. مهمة عمل — خطة مهام مصغّرة
يريد صاحب Cedar Lane أن يعرف هل يستمر في بيع خط منتجات بطيء البيع (مصابيح المكتب). اكتب خطة مهام من 5 خطوات مرتّبة. لكل خطوة اذكر: المهمة، والدور الذي يقوم بها عادةً (في شركة صغيرة قد تكون أنت)، والهدف التجاري. واختم بجملة واحدة تحدد فيها من يتخذ القرار النهائي.
14. تحدٍّ قصير
سيناريو جديد (خيالي): شركة حافلات إقليمية تريد تقليل عدد الحافلات المتأخرة.
- اذكر أربع مهام قد يقوم بها عالم البيانات، بترتيب سير العمل.
- اربط كل مهمة بفكرة مهمة من O*NET.
- سمِّ مهمة واحدة تخص مهندس البيانات، وقرارًا واحدًا يخص المدير وليس فريق البيانات.
- اذكر هدفًا تجاريًا واحدًا (التكلفة، الإيرادات، العملاء، المخاطر، المنتج) واشرحه في جملة واحدة.
سلّم إجابتك قبل أي تعليق أو ملاحظات. لا يوجد حل هنا.
15. المصادر
- مطلوب (حوالي 15 دقيقة): O*NET OnLine — Data Scientists (15-2051.00)، قسما Tasks وWork Activities. https://www.onetonline.org/link/summary/15-2051.00 (بيانات مهنية أمريكية؛ محدّثة في 2026.)
- مقترح (حوالي 10 دقائق): U.S. Bureau of Labor Statistics — Data Scientists، تبويب "What They Do". https://www.bls.gov/ooh/math/data-scientists.htm (يركّز على الولايات المتحدة. هذا الدرس لا يستخدم بيانات الأجور أو التوقعات الواردة فيه.)
- للتعمّق (اختياري): DataCamp DataFramed، حلقة "Decision Intelligence and Data Science" (2018). يتناول النقاش كيف تضع المؤسسات علماء البيانات داخل فرقها. https://www.datacamp.com/podcast/decision-intelligence-and-data-science
16. شخصية تتابعها
ملاحظة عن خريطة المصادر: في هذا الدرس، تذكر خريطة منهج D.World عبارة "O*NET occupational practice" في خانة الشخصية القدوة. وهذا مصدر وليس شخصًا. لذلك فالاقتراح التالي مؤقت ويحتاج إلى موافقة مسؤول المنهج.
اقتراح مؤقت: Cassie Kozyrkov. هي مناسبة هنا لأن أعمالها العامة تناقش موقع علماء البيانات داخل المؤسسات، وكيف يرتبط عملهم بأصحاب القرار (مثلًا في حلقة DataFramed سنة 2018). موقعها يذكر أنها كانت أول Chief Decision Scientist في Google (منصب سابق). https://www.kozyr.com/
17. تأمّل
قبل هذا الدرس، كم كنت تظن نصيب "بناء النماذج" من عمل عالم البيانات؟ بعد قراءة مهام O*NET، كم تقدّره الآن، ولماذا تغيّر تقديرك (أو لم يتغيّر)؟
18. الخطوة التالية
أصبحت تعرف المهام ومن يقوم بها عادةً. في L04 — سير عمل البيانات الحديث وأين يدخل الذكاء الاصطناعي، ستربط هذه المهام في سير عمل واحد متكامل، من مشكلة العمل إلى نتيجة مقاسة. ثم ستقرّر بعناية أين يمكن للذكاء الاصطناعي أن يسرّع العمل، وأين يجب أن يبقى التحقق البشري هو المتحكم.
19. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| مطابقة الأدوار بالمهام (الجزءان A وB) | أنك تستطيع ربط المهام بالأدوار المعتادة وبالأهداف التجارية | الجزء A: 6 أو أكثر من 8 مطابقة لمفتاح الإجابة أو لبديل مقبول مع تبرير. الجزء B: 4 أو أكثر من 5 |
| التدريب المستقل (إعلان الوظيفة) | أنك تستطيع مقارنة توصيف وظيفي واقعي الشكل بالبيانات المهنية | معايير L03-IP |
| مهمة العمل (خطة المهام) | أنك تستطيع ترتيب المهام وربطها بالأدوار والأهداف | معايير L03-WT: ترتيب منطقي؛ أدوار معقولة؛ هدف لكل خطوة؛ تحديد صاحب القرار |
| التحدي القصير (شركة الحافلات) | أنك تستطيع نقل المهارة إلى مجال جديد | معايير L03-MC |
20. المراجع
- O*NET OnLine. Summary Report for: 15-2051.00 — Data Scientists، قسم Tasks (17 مهمة). https://www.onetonline.org/link/summary/15-2051.00 (تمت زيارتها ومراجعتها في 11 أكتوبر 2026؛ الصفحة تذكر "Updated 2026"). يدعم: كل عبارات المهام المنقولة وعدد المهام (17). تجميع المهام في مراحل هو تفسير D.World.
- U.S. Bureau of Labor Statistics. Occupational Outlook Handbook — Data Scientists، "What Data Scientists Do". https://www.bls.gov/ooh/math/data-scientists.htm (تمت زيارتها في 11 أكتوبر 2026). يدعم: ملخص المهام (الجمع، والتنظيف، والتحليل، والنمذجة، والتصوير البصري، والتوصية).
- DataCamp. DataFramed — "Decision Intelligence and Data Science" (22 أكتوبر 2018). https://www.datacamp.com/podcast/decision-intelligence-and-data-science (تمت زيارتها في 11 أكتوبر 2026).
- توصيفات أدوار محلل البيانات ومهندس البيانات ومهندس تعلّم الآلة هي تلخيص D.World للأنماط الشائعة. لم يُستخدم مصدر رسمي واحد لها، وهي معروضة على أنها متغيرة وغير موحّدة (راجع سجل المصادر).
- D.World Curriculum Map v1.0 (وثيقة داخلية). صف L03: الهدف، ونوع التقييم، والمبدأ الأساسي.
L04 · The Modern Data Workflow & Where AI FitsL04 · سير عمل البيانات الحديث وأين يدخل الذكاء الاصطناعي Freeمجاني
L04 — The Modern Data Workflow & Where AI Fits
Learner file. Answers and model solutions are kept in a separate instructor file. Version: U01 pilot v1.0 · Content date: 11 October 2026.
1. Lesson Identity
| Field | Value |
|---|---|
| Title | The Modern Data Workflow & Where AI Fits |
| Stage | Stage 1 — Foundations |
| Unit | U01 — Data Science & the Modern Data World |
| Lesson ID | L04 |
| Skills | Workflow thinking; AI literacy |
| Difficulty | Beginner |
| Estimated time | About 1 hour 50 minutes |
| Prerequisites | L01–L03. You need no software, but you may use an AI assistant for Section 10. |
Time breakdown (estimate): concept, worked example and AWS reading, 35 min · guided practice, 15 min · independent practice, 15 min · workflow-mapping check, 15 min · AI in Practice and AI Verification, 15 min · workplace task, 10 min · mini challenge, 5 min.
2. Learning Objective
By the end of this lesson, you will be able to trace a simple end-to-end data workflow for a business decision and identify where AI can assist and where human validation and judgment must remain in control.
3. Why It Matters
AI tools can now draft text, explain methods, suggest analyses and write code in seconds. That speed is useful, but it creates a new risk: people let the tool decide what the question is, which data is acceptable, or whether a result is true.
Organizations still need someone who understands the whole workflow, from business problem to measured result. That person can place AI where it helps and keep human judgment where it matters.
4. Concept
The end-to-end workflow (D.World version)
This combines everything from L01–L03 into eight stages. Real projects loop back; they rarely move in a straight line.
| # | Stage | Key question |
|---|---|---|
| 1 | Business problem and decision | What decision are we trying to improve, and why does it matter? |
| 2 | Question and success measure | What exactly will we answer, and how will we know if the outcome improved? |
| 3 | Data: find, access, check | What data exists, is it trustworthy, and are we allowed to use it? |
| 4 | Prepare | Is the data clean, consistent and organized for the question? |
| 5 | Analyze or model | What does the data show? Is a model actually needed? |
| 6 | Validate | Is the result correct and robust? What else could explain it? |
| 7 | Communicate and decide | What are the options, expected impact and limits? Who decides? |
| 8 | Act, measure, monitor | Did the action work? What do we learn for next time? |
This follows the D.World business sequence: business problem → question → data → evidence → decision → expected impact → measurement.
What AWS guidance emphasizes
The AWS Cloud Adoption Framework's Data science page is industry guidance focused on AI/ML projects. It describes data science as using experimentation, advanced analytics and ML to solve complex business problems. Among its recommendations (paraphrased):
- Define business problems that the work can solve, with a clear idea of the business value.
- Set a measurable performance metric that is observable and quantifiable.
- Evaluate whether ML is the right approach at all. Simple business rules may work better, and some problems lack enough data.
- Find key decision points in the process and list the data that could inform them.
- Involve stakeholders, choose a business owner, and collect feedback to improve the solution.
- Once a solution is in use, monitor its performance and send low-confidence predictions to human review.
The page itself notes that it is a historical whitepaper, so some details may be out of date. The principles above are the stable part you need now.
Where AI fits, and where it must not take over
| Stage | AI can assist by… | Human must… |
|---|---|---|
| 1 Problem and decision | Suggesting questions to ask stakeholders | Own the decision and its goal |
| 2 Question and success measure | Suggesting possible measures | Choose the measure that reflects real value |
| 3 Data | Suggesting what data might exist | Check quality, permission and privacy. Never paste personal or confidential data into tools that are not approved |
| 4 Prepare | Suggesting cleaning checks (and, later in D.World, drafting code) | Inspect the data and confirm every change |
| 5 Analyze or model | Explaining methods; proposing analyses | Decide which method fits; check the logic |
| 6 Validate | Suggesting alternative explanations to test | Recalculate, compare sources, judge robustness |
| 7 Communicate and decide | Drafting a summary | Own every claim in it; the decision-owner decides |
| 8 Act and measure | Drafting a monitoring checklist | Interpret results and take responsibility for next steps |
Key principle: AI accelerates work; it does not own decisions. In D.World's words: AI can accelerate your work. It cannot replace your judgment.
5. Worked Example
Scenario (fictional): Cedar Lane's support messages about late delivery jumped in Week 3 (11 messages vs 2–4 in other weeks; see L02). The owner wonders whether to change delivery company.
- Problem and decision: switch delivery company, yes or no. At stake are customer satisfaction (customer) and possibly shipping cost.
- Question and success measure: "Is our current delivery company consistently late, or was Week 3 unusual?" Success measure: the share of orders delivered within the promised 3 days.
- Data: order dates and delivery-confirmation dates from the delivery company's records, plus support messages. Check: do both systems use the same time zone? Privacy: the analysis needs only order IDs and dates, not customer names.
- Prepare: match orders to delivery records and remove test orders.
- Analyze: on-time share by week. No model is needed. A simple comparison answers the question (compare AWS: "simple business rules may work better").
- Validate: check the highest-volume week. Week 3 had the most orders (150, the promotion week), so perhaps the delivery company was overloaded. Check whether earlier busy weeks showed the same pattern.
- Communicate and decide: the analyst reports the on-time share for each week (calculated from the matched records), and, if the results show the problem concentrated in Week 3 (the highest-volume week), suggests: "Before switching, ask the current company how it handles peak weeks." If delays appear in every week, the recommendation would be different. The owner decides.
- Act and measure: agree a peak-week plan with the current company, and track the on-time share during the next promotion.
Where AI helped: suggesting what could cause delays (stage 6) and drafting the summary (stage 7). Where it did not decide: the success measure, the privacy choice, the validation and the decision.
6. Visual Explanation
1 Problem & decision --> 2 Question & measure --> 3 Data --> 4 Prepare --> 5 Analyze/model
^ |
| v
8 Act, measure, monitor <-- 7 Communicate & decide <------------------------ 6 Validate
AI may assist at every stage · Human validation is required at every stage · The decision owner decides at 7
Alt text: A loop of eight stages. The top row runs left to right: 1 Problem and decision, 2 Question and measure, 3 Data, 4 Prepare, 5 Analyze or model. An arrow goes down to 6 Validate, then left along the bottom row to 7 Communicate and decide, and 8 Act, measure, monitor. From 8, an arrow returns up to stage 1. A note underneath says AI may assist at every stage, human validation is required at every stage, and the decision owner decides at stage 7.
7. Guided Practice
Cedar Lane is deciding whether to repeat the 10% notebook promotion next month. Complete the table. For each stage, write one activity, one way AI could assist, and one thing a human must check.
| Stage | Activity | AI could assist by… | Human must check… |
|---|---|---|---|
| 1 Problem and decision | |||
| 2 Question and success measure | Hint: think about extra orders vs orders only moved from another week (L02). | ||
| 3 Data | Hint: privacy, completeness. | ||
| 4 Prepare | |||
| 5 Analyze or model | Hint: is a model needed? | ||
| 6 Validate | |||
| 7 Communicate and decide | |||
| 8 Act and measure |
8. Independent Practice
New scenario (fictional): a small hotel wants to decide whether to raise weekend room prices. Write an eight-stage workflow (1–2 lines per stage). Mark at least two stages where AI could reasonably assist and three places where human validation is essential, with a reason for each.
No model answer is shown here.
9. Knowledge Check — Workflow Mapping
Scenario (fictional): Cedar Lane is deciding whether to send a "we miss you" email to customers who have not ordered in 90 days.
Part A. Put the activities P–W into workflow order (stages 1–8). Each activity belongs to exactly one stage.
| Letter | Activity |
|---|---|
| P | Recalculate the inactive-customer count a second way, and check whether using 60 or 120 days instead of 90 changes the conclusion much. |
| Q | Agree with the owner which decision this work must support: whether to send the email to inactive customers. |
| R | Write a one-page summary of options, expected impact and limits; the owner chooses. |
| S | List which customer records exist, and confirm which customers agreed to receive marketing emails. |
| T | Define success: a clearly higher share of emailed customers ordering within 30 days than a similar group that was not emailed. |
| U | Send the email to half of the inactive customers, then compare orders after 30 days and review. |
| V | Remove duplicate customer accounts and test orders. |
| W | Count customers with no order in 90 days and compare their past ordering patterns. |
Part B. For three activities of your choice, write one way AI could assist or "AI not appropriate here," plus one human check, with a reason.
Part C. Multiple choice.
C1. According to the AWS guidance discussed in this lesson, what should happen before choosing Machine Learning? - A) Evaluate whether ML is the right approach, because simple business rules may work better. - B) Always choose the most advanced model available. - C) Collect every possible dataset first. - D) Let an AI tool choose the method.
C2. Which responsibility must stay with a human? - A) Producing a first draft of the summary wording - B) Suggesting possible data sources - C) Making the final decision and being accountable for it - D) Explaining an unfamiliar term
C3. An AI assistant writes in your draft report: "Emailed customers spent 20% more." You have not yet run any analysis. What should you do? - A) Keep it, because AI tools have seen many similar businesses. - B) Remove or replace it until the number is calculated from your own checked data. - C) Round it to 25% to be safe. - D) Keep it but add "according to AI."
10. AI in Practice
Prompt an AI assistant. The scenario is fictional, and no real data is included:
"I am planning a small analysis for a fictional online store deciding whether to repeat a 10% promotion. The workflow stages are: 1 problem and decision, 2 question and success measure, 3 data, 4 prepare, 5 analyze or model, 6 validate, 7 communicate and decide, 8 act and measure. For each stage, suggest one way an AI assistant could help, and one thing a human must verify or decide. Be specific and do not invent any numbers."
Why this can help: the AI may suggest assistance ideas you had not considered, and it gives you a structured draft to critique.
11. AI Verification
- Check decision ownership. Did the AI suggest that it, or a model, should make the decision at stage 7? If so, correct it.
- Check privacy. Did any suggestion involve pasting customer lists, emails or order details into an AI tool? Mark that as not acceptable unless the tool is approved by policy for that data.
- Check invented facts. Did it include numbers or "typical" results? Delete them; they are not evidence about this store.
- Compare with AWS guidance. Does its stage 2 include a measurable success measure? Does its stage 5 consider whether a simple rule is enough?
- Write an AI-use note (2–3 lines): what AI was used for, what you verified, and what remained your judgment. D.World asks you to keep this kind of note for major work.
12. Business Lens — Where Is the Decision Value?
The value of data work is realized only when a decision changes and the result is measured. Two stages usually matter most:
- Stage 1–2 (framing): solving the wrong problem well creates no value. A precise decision and success measure focus everything else.
- Stage 7–8 (deciding, acting, measuring): the analysis pays off only when someone acts on it and checks the outcome.
Analysis and modeling (stage 5) are essential, but they are worthless if framing is wrong or nobody acts.
13. Workplace Task — Workflow Plan with AI-Use Note
For Cedar Lane's "repeat the promotion?" decision, write a one-page workflow plan:
- the eight stages, each with one concrete activity;
- the success measure (stage 2);
- one stage you believe creates the most decision value, with a 2–3 sentence justification;
- an AI-use note: where you would use AI, what you would verify, and what you would never give to an AI tool.
14. Mini Challenge
New scenario (fictional): a community library wants to decide whether to extend evening opening hours.
- Write the eight-stage workflow (one line each).
- Identify the stage with the greatest privacy risk and explain why.
- Identify one point where an AI suggestion would need human validation before use.
- Propose a success measure for stage 8.
Submit before feedback. No solution is provided here.
15. Resources
- Required (about 15 min): AWS Cloud Adoption Framework: Business Perspective — Data science. Focus on the "Start" recommendations. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-science.html (Industry guidance; the page states it is a historical whitepaper.)
- Recommended (about 10 min): NIST — AI Risk Management Framework overview page. Read the first section to see why trustworthy AI use is treated as a risk-management question. https://www.nist.gov/itl/ai-risk-management-framework (US government framework; voluntary use.)
- Deeper (optional): revisit the O*NET Data Scientists Tasks list and mark each task with its workflow stage from this lesson. https://www.onetonline.org/link/summary/15-2051.00
16. Person to Follow
Note on the source map: the D.World map lists "AWS data-science guidance" in this lesson's role-model field. That is an organization's guidance, not a person. The suggestion below is provisional and needs curriculum-owner approval.
Provisional suggestion: Cassie Kozyrkov. Her website links an article titled "Why AI and Decisions are two sides of the same coin," which fits this lesson's idea that AI work must stay tied to human decisions. https://www.kozyr.com/ (past role per her site: Google's first Chief Decision Scientist). The curriculum map assigns Andrew Ng as the role model for U03 (AI for Data Work). Learners will meet him there.
17. Reflection
Think about the last time you used an AI tool for something important. At which "stage" were you, and did you check its output before acting? What would you do differently with this workflow in mind?
18. Next Step
U01 is complete once you pass the U01 Exit Assessment: explaining the workflow and role differences with a business example. Next comes U02 — Business Foundations for Data Professionals, starting with L05 — How a Business Actually Works. It teaches the revenue, cost and customer ideas behind stage 1 ("why does this decision matter?") and stage 2 ("how do we measure success?").
19. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Workflow mapping, Part A | You can order a workflow correctly | 7 or more of 8 positions correct |
| Workflow mapping, Part B | You can place AI assistance and human validation sensibly | Rubric L04-B: realistic AI assist or a justified "not appropriate"; a concrete human check with a reason |
| Part C (C1–C3) | You understand AWS framing, decision ownership, and that AI output is not evidence | 3 of 3 = meets; 2 of 3 = review |
| Workplace task (workflow plan and AI-use note) | Integrated planning with responsible AI use | Rubric L04-WT |
| Independent practice and mini challenge | Transfer | Rubrics L04-IP and L04-MC |
20. References
- Amazon Web Services. AWS Cloud Adoption Framework: Business Perspective — Data science. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-science.html (accessed and checked 11 Oct 2026). Supports: the definition paraphrase; "define business problems… business value"; measurable, "observable and quantifiable" metric; "evaluate whether ML is the right approach" (simple rules may work better); decision points and data inventory; stakeholder involvement and business owner; monitoring and human review of low-confidence predictions; and the page's own "historical whitepaper" note.
- NIST. AI Risk Management Framework. https://www.nist.gov/itl/ai-risk-management-framework (accessed 11 Oct 2026). Supports: AI RMF released 26 January 2023, intended for voluntary use, aimed at managing AI risks.
- ONET OnLine. Data Scientists (15-2051.00)*. https://www.onetonline.org/link/summary/15-2051.00 (accessed 11 Oct 2026).
- Kozyrkov, C. Website. https://www.kozyr.com/ (accessed 11 Oct 2026). Supports: the linked article title and her past role as stated on her site.
- D.World Curriculum Bible v1.0: AI Integration Standard ("AI can accelerate your work. It cannot replace your judgment."), the AI-use note practice, and the business thinking sequence.
L04 — سير عمل البيانات الحديث وأين يدخل الذكاء الاصطناعي
ملف المتعلّم. الإجابات والحلول النموذجية محفوظة في ملف منفصل خاص بالمدرّس. الإصدار: U01 pilot v1.0 · تاريخ المحتوى: 11 أكتوبر 2026.
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | سير عمل البيانات الحديث وأين يدخل الذكاء الاصطناعي |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U01 — علم البيانات وعالم البيانات الحديث |
| رقم الدرس | L04 |
| المهارات | التفكير بمنطق سير العمل؛ الوعي بالذكاء الاصطناعي |
| المستوى | مبتدئ |
| الوقت المتوقع | حوالي ساعة و50 دقيقة |
| المتطلبات السابقة | L01–L03. لا تحتاج أي برامج، لكن يمكنك استخدام مساعد ذكاء اصطناعي في القسم 10. |
تفصيل الوقت (تقديري): المفهوم والمثال المحلول وقراءة دليل AWS 35 دقيقة · التدريب الموجَّه 15 دقيقة · التدريب المستقل 15 دقيقة · اختبار رسم سير العمل 15 دقيقة · الذكاء الاصطناعي في التطبيق والتحقق من مخرجاته 15 دقيقة · مهمة العمل 10 دقائق · التحدي القصير 5 دقائق.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تتتبّع سير عمل بيانات بسيطًا من البداية إلى النهاية لقرار عمل، وأن تحدد أين يمكن للذكاء الاصطناعي أن يساعد، وأين يجب أن يبقى التحقق والحكم البشري هو المتحكم.
3. لماذا يهمّك هذا؟
أدوات الذكاء الاصطناعي تستطيع الآن أن تكتب مسودات، وتشرح الأساليب، وتقترح تحليلات، وتكتب الكود في ثوانٍ. هذه السرعة مفيدة، لكنها تخلق خطرًا جديدًا: أن يترك الناس للأداة أن تقرر ما هو السؤال، وأي البيانات مقبولة، وهل النتيجة صحيحة.
المؤسسات ما زالت تحتاج إلى شخص يفهم سير العمل كاملًا، من مشكلة العمل إلى النتيجة المقاسة. هذا الشخص يستطيع أن يضع الذكاء الاصطناعي حيث يفيد، وأن يُبقي الحكم البشري حيث يهم.
4. المفهوم
سير العمل من البداية إلى النهاية (نسخة D.World)
هذا يجمع كل ما تعلّمته في L01–L03 في ثماني مراحل. المشروعات الحقيقية تعود إلى مراحل سابقة، ونادرًا ما تسير في خط مستقيم.
| # | المرحلة | السؤال الأساسي |
|---|---|---|
| 1 | مشكلة العمل والقرار | ما القرار الذي نحاول تحسينه، ولماذا يهم؟ |
| 2 | السؤال ومقياس النجاح | ما الذي سنجيب عنه بالضبط، وكيف سنعرف أن النتيجة تحسّنت؟ |
| 3 | البيانات: إيجادها، والوصول إليها، وفحصها | ما البيانات الموجودة، وهل هي جديرة بالثقة، وهل مسموح لنا باستخدامها؟ |
| 4 | التجهيز | هل البيانات نظيفة ومتّسقة ومنظّمة بما يناسب السؤال؟ |
| 5 | التحليل أو النمذجة | ماذا تُظهر البيانات؟ وهل نحتاج فعلًا إلى نموذج؟ |
| 6 | التحقق | هل النتيجة صحيحة وثابتة؟ وما التفسيرات الأخرى الممكنة؟ |
| 7 | التواصل واتخاذ القرار | ما الخيارات، والأثر المتوقع، والحدود؟ ومن يقرر؟ |
| 8 | التنفيذ والقياس والمتابعة | هل نجح الإجراء؟ وماذا نتعلم للمرة القادمة؟ |
هذا يتبع تسلسل الأعمال في D.World: مشكلة العمل ← السؤال ← البيانات ← الدليل ← القرار ← الأثر المتوقع ← القياس.
ما الذي يؤكد عليه دليل AWS
صفحة Data science في AWS Cloud Adoption Framework دليل صناعي يركّز على مشروعات الذكاء الاصطناعي وتعلّم الآلة. تصف الصفحة علم البيانات بأنه استخدام التجريب والتحليلات المتقدمة وتعلّم الآلة لحل مشكلات عمل معقّدة. ومن توصياتها (بإعادة صياغة):
- حدِّد مشكلات العمل التي يمكن أن يحلّها العمل، مع فكرة واضحة عن قيمتها للمؤسسة.
- ضع مقياس أداء قابلًا للقياس، يمكن ملاحظته والتعبير عنه بالأرقام.
- قيِّم أولًا هل تعلّم الآلة هو النهج المناسب أصلًا. قد تنجح قواعد عمل بسيطة بشكل أفضل، وبعض المشكلات لا تتوفر لها بيانات كافية.
- حدِّد نقاط القرار الأساسية في العملية، واذكر البيانات التي يمكن أن تفيد فيها.
- أشرِك أصحاب المصلحة، واختر مالكًا للعمل من جهة الأعمال، واجمع الملاحظات لتحسين الحل.
- بعد أن يبدأ استخدام الحل، راقب أداءه، وأرسل التنبؤات منخفضة الثقة إلى مراجعة بشرية.
الصفحة نفسها تذكر أنها ورقة بيضاء قديمة (historical whitepaper)، لذلك قد تكون بعض التفاصيل غير محدّثة. المبادئ السابقة هي الجزء الثابت الذي تحتاجه الآن.
أين يدخل الذكاء الاصطناعي، وأين يجب ألا يتولى الأمر
| المرحلة | يمكن للذكاء الاصطناعي أن يساعد في… | على الإنسان أن… |
|---|---|---|
| 1 المشكلة والقرار | اقتراح أسئلة تطرحها على أصحاب المصلحة | يمتلك القرار وهدفه |
| 2 السؤال ومقياس النجاح | اقتراح مقاييس ممكنة | يختار المقياس الذي يعكس القيمة الحقيقية |
| 3 البيانات | اقتراح البيانات التي قد تكون موجودة | يفحص الجودة والإذن والخصوصية. لا تلصق أبدًا بيانات شخصية أو سرية في أدوات غير معتمدة |
| 4 التجهيز | اقتراح فحوصات للتنظيف (ولاحقًا في D.World، كتابة مسودة الكود) | يفحص البيانات ويؤكد كل تغيير |
| 5 التحليل أو النمذجة | شرح الأساليب؛ اقتراح تحليلات | يقرر أي أسلوب يناسب؛ ويراجع المنطق |
| 6 التحقق | اقتراح تفسيرات بديلة لاختبارها | يعيد الحساب، ويقارن المصادر، ويحكم على ثبات النتيجة |
| 7 التواصل واتخاذ القرار | كتابة مسودة الملخص | يتحمّل مسؤولية كل ادعاء فيه؛ وصاحب القرار هو من يقرر |
| 8 التنفيذ والقياس | كتابة مسودة قائمة متابعة | يفسّر النتائج ويتحمّل مسؤولية الخطوات التالية |
المبدأ الأساسي: الذكاء الاصطناعي يسرّع العمل، لكنه لا يمتلك القرارات. وبكلمات D.World: الذكاء الاصطناعي يمكن أن يسرّع عملك، لكنه لا يستطيع أن يحل محل حكمك.
5. مثال محلول
السيناريو (خيالي): رسائل الدعم التي تشكو من تأخر التوصيل في Cedar Lane قفزت في الأسبوع 3 (11 رسالة مقابل 2–4 في الأسابيع الأخرى؛ راجع L02). صاحب المتجر يتساءل هل يغيّر شركة التوصيل.
- المشكلة والقرار: تغيير شركة التوصيل، نعم أم لا. على المحك رضا العملاء (العملاء) وربما تكلفة الشحن.
- السؤال ومقياس النجاح: "هل شركة التوصيل الحالية تتأخر باستمرار، أم أن الأسبوع 3 كان استثناءً؟" مقياس النجاح: نسبة الطلبات التي وصلت خلال الأيام الثلاثة الموعودة.
- البيانات: تواريخ الطلبات وتواريخ تأكيد التسليم من سجلات شركة التوصيل، بالإضافة إلى رسائل الدعم. فحص: هل يستخدم النظامان المنطقة الزمنية نفسها؟ الخصوصية: التحليل يحتاج فقط أرقام الطلبات والتواريخ، لا أسماء العملاء.
- التجهيز: مطابقة الطلبات بسجلات التسليم، وحذف الطلبات التجريبية.
- التحليل: نسبة التسليم في الموعد لكل أسبوع. لا نحتاج إلى نموذج. مقارنة بسيطة تجيب عن السؤال (قارن بما يقوله دليل AWS: "قد تنجح قواعد عمل بسيطة بشكل أفضل").
- التحقق: افحص الأسبوع الأعلى في عدد الطلبات. الأسبوع 3 كان فيه أكبر عدد من الطلبات (150، أسبوع العرض)، فربما كانت شركة التوصيل تحت ضغط زائد. افحص هل ظهر النمط نفسه في أسابيع مزدحمة سابقة.
- التواصل واتخاذ القرار: يعرض المحلل نسبة التسليم في الموعد لكل أسبوع (محسوبة من السجلات المتطابقة)، وإذا أظهرت النتائج أن المشكلة تتركّز في الأسبوع 3 (الأعلى في عدد الطلبات)، يقترح: "قبل التغيير، اسألوا الشركة الحالية كيف تتعامل مع أسابيع الذروة". أما إذا ظهرت التأخيرات في كل الأسابيع، فستكون التوصية مختلفة. صاحب المتجر هو من يقرر.
- التنفيذ والقياس: الاتفاق مع الشركة الحالية على خطة لأسابيع الذروة، ومتابعة نسبة التسليم في الموعد خلال العرض القادم.
أين ساعد الذكاء الاصطناعي: في اقتراح ما قد يسبب التأخير (المرحلة 6) وكتابة مسودة الملخص (المرحلة 7). وأين لم يقرر: مقياس النجاح، وقرار الخصوصية، والتحقق، والقرار النهائي.
6. شرح بصري
1 Problem & decision --> 2 Question & measure --> 3 Data --> 4 Prepare --> 5 Analyze/model
^ |
| v
8 Act, measure, monitor <-- 7 Communicate & decide <------------------------ 6 Validate
AI may assist at every stage · Human validation is required at every stage · The decision owner decides at 7
وصف الرسم: حلقة من ثماني مراحل. الصف العلوي يسير من اليسار إلى اليمين: 1 المشكلة والقرار، 2 السؤال والمقياس، 3 البيانات، 4 التجهيز، 5 التحليل أو النمذجة. ينزل سهم إلى 6 التحقق، ثم يتجه يسارًا في الصف السفلي إلى 7 التواصل واتخاذ القرار، ثم 8 التنفيذ والقياس والمتابعة. ومن 8 يعود سهم إلى أعلى نحو المرحلة 1. وتحت الرسم ملاحظة تقول إن الذكاء الاصطناعي قد يساعد في كل مرحلة، وإن التحقق البشري مطلوب في كل مرحلة، وإن صاحب القرار يقرر في المرحلة 7.
7. تدريب موجَّه
Cedar Lane تقرر هل تكرر عرض خصم الـ 10% على الدفاتر الشهر القادم. أكمل الجدول. لكل مرحلة اكتب نشاطًا واحدًا، وطريقة واحدة يمكن أن يساعد بها الذكاء الاصطناعي، وشيئًا واحدًا يجب أن يتحقق منه الإنسان.
| المرحلة | النشاط | يمكن للذكاء الاصطناعي أن يساعد في… | على الإنسان أن يتحقق من… |
|---|---|---|---|
| 1 المشكلة والقرار | |||
| 2 السؤال ومقياس النجاح | تلميح: فكّر في الطلبات الإضافية فعلًا مقابل الطلبات التي انتقلت فقط من أسبوع آخر (L02). | ||
| 3 البيانات | تلميح: الخصوصية، والاكتمال. | ||
| 4 التجهيز | |||
| 5 التحليل أو النمذجة | تلميح: هل نحتاج إلى نموذج؟ | ||
| 6 التحقق | |||
| 7 التواصل واتخاذ القرار | |||
| 8 التنفيذ والقياس |
8. تدريب مستقل
سيناريو جديد (خيالي): فندق صغير يريد أن يقرر هل يرفع أسعار الغرف في عطلة نهاية الأسبوع. اكتب سير عمل من ثماني مراحل (سطر أو سطران لكل مرحلة). ميّز مرحلتين على الأقل يمكن أن يساعد فيهما الذكاء الاصطناعي بشكل معقول، وثلاثة مواضع يكون فيها التحقق البشري ضروريًا، مع سبب لكل منها.
لا توجد إجابة نموذجية هنا.
9. اختبار الفهم — رسم سير العمل
السيناريو (خيالي): Cedar Lane تقرر هل ترسل رسالة "افتقدناك" بالبريد الإلكتروني إلى العملاء الذين لم يطلبوا منذ 90 يومًا.
الجزء A. رتّب الأنشطة P–W حسب ترتيب سير العمل (المراحل 1–8). كل نشاط ينتمي إلى مرحلة واحدة فقط.
| الحرف | النشاط |
|---|---|
| P | أعِد حساب عدد العملاء غير النشطين بطريقة ثانية، وافحص هل يغيّر استخدام 60 أو 120 يومًا بدل 90 الخلاصة كثيرًا. |
| Q | اتفق مع صاحب المتجر على القرار الذي يجب أن يدعمه هذا العمل: هل تُرسَل الرسالة إلى العملاء غير النشطين. |
| R | اكتب ملخصًا من صفحة واحدة للخيارات والأثر المتوقع والحدود؛ وصاحب المتجر يختار. |
| S | اذكر سجلات العملاء الموجودة، وتأكد من العملاء الذين وافقوا على تلقي رسائل تسويقية. |
| T | حدِّد النجاح: نسبة أعلى بوضوح من العملاء الذين وصلتهم الرسالة يطلبون خلال 30 يومًا، مقارنةً بمجموعة مشابهة لم تصلها الرسالة. |
| U | أرسل الرسالة إلى نصف العملاء غير النشطين، ثم قارن الطلبات بعد 30 يومًا وراجع النتيجة. |
| V | احذف حسابات العملاء المكررة والطلبات التجريبية. |
| W | احسب العملاء الذين لم يطلبوا شيئًا منذ 90 يومًا، وقارن أنماط طلباتهم السابقة. |
الجزء B. اختر ثلاثة أنشطة، واكتب لكل منها طريقة واحدة يمكن أن يساعد بها الذكاء الاصطناعي أو "الذكاء الاصطناعي غير مناسب هنا"، بالإضافة إلى فحص بشري واحد، مع ذكر السبب.
الجزء C. اختيار من متعدد.
C1. وفقًا لدليل AWS الذي ناقشناه في هذا الدرس، ماذا يجب أن يحدث قبل اختيار تعلّم الآلة؟ - A) تقييم هل تعلّم الآلة هو النهج المناسب، لأن قواعد العمل البسيطة قد تنجح بشكل أفضل. - B) اختيار أكثر نموذج متقدم متاح دائمًا. - C) جمع كل مجموعة بيانات ممكنة أولًا. - D) ترك أداة ذكاء اصطناعي تختار الأسلوب.
C2. أي مسؤولية يجب أن تبقى مع الإنسان؟ - A) كتابة المسودة الأولى لصياغة الملخص - B) اقتراح مصادر بيانات ممكنة - C) اتخاذ القرار النهائي وتحمّل المسؤولية عنه - D) شرح مصطلح غير مألوف
C3. مساعد ذكاء اصطناعي كتب في مسودة تقريرك: "العملاء الذين وصلتهم الرسالة أنفقوا 20% أكثر". وأنت لم تُجرِ أي تحليل بعد. ماذا تفعل؟ - A) أبقِها، لأن أدوات الذكاء الاصطناعي رأت شركات كثيرة مشابهة. - B) احذفها أو استبدلها حتى تحسب الرقم من بياناتك التي راجعتها بنفسك. - C) قرّبها إلى 25% من باب الاحتياط. - D) أبقِها وأضف "حسب الذكاء الاصطناعي".
10. الذكاء الاصطناعي في التطبيق
اكتب لمساعد ذكاء اصطناعي الطلب التالي. السيناريو خيالي، ولا يتضمن أي بيانات حقيقية:
"I am planning a small analysis for a fictional online store deciding whether to repeat a 10% promotion. The workflow stages are: 1 problem and decision, 2 question and success measure, 3 data, 4 prepare, 5 analyze or model, 6 validate, 7 communicate and decide, 8 act and measure. For each stage, suggest one way an AI assistant could help, and one thing a human must verify or decide. Be specific and do not invent any numbers."
وبالعربية: "أخطط لتحليل صغير لمتجر إلكتروني خيالي يقرر هل يكرر عرض خصم 10%. مراحل سير العمل هي: 1 المشكلة والقرار، 2 السؤال ومقياس النجاح، 3 البيانات، 4 التجهيز، 5 التحليل أو النمذجة، 6 التحقق، 7 التواصل واتخاذ القرار، 8 التنفيذ والقياس. لكل مرحلة، اقترح طريقة واحدة يمكن أن يساعد بها مساعد الذكاء الاصطناعي، وشيئًا واحدًا يجب أن يتحقق منه الإنسان أو يقرره. كن محددًا ولا تخترع أي أرقام."
لماذا قد يفيد هذا: قد يقترح الذكاء الاصطناعي أفكارًا للمساعدة لم تخطر لك، ويعطيك مسودة منظّمة تنتقدها.
11. التحقق من مخرجات الذكاء الاصطناعي
- افحص من يمتلك القرار. هل اقترح الذكاء الاصطناعي أن يتخذ هو، أو نموذج ما، القرار في المرحلة 7؟ إن حدث ذلك فصحّحه.
- افحص الخصوصية. هل تضمّن أي اقتراح لصق قوائم العملاء أو بريدهم الإلكتروني أو تفاصيل طلباتهم في أداة ذكاء اصطناعي؟ اعتبر ذلك غير مقبول ما لم تكن الأداة معتمدة وفق السياسة لهذا النوع من البيانات.
- افحص الحقائق المخترعة. هل ذكر أرقامًا أو نتائج "معتادة"؟ احذفها؛ فهي ليست دليلًا عن هذا المتجر.
- قارن بدليل AWS. هل تتضمن المرحلة 2 عنده مقياس نجاح قابلًا للقياس؟ وهل تأخذ المرحلة 5 في الاعتبار أن قاعدة بسيطة قد تكفي؟
- اكتب ملاحظة استخدام الذكاء الاصطناعي (سطران أو ثلاثة): فيمَ استخدمت الذكاء الاصطناعي، وما الذي تحققت منه، وما الذي بقي حكمك أنت. تطلب منك D.World الاحتفاظ بهذا النوع من الملاحظات في الأعمال الكبيرة.
12. منظور الأعمال — أين تكمن قيمة القرار؟
قيمة العمل مع البيانات لا تتحقق إلا عندما يتغيّر قرار وتُقاس نتيجته. هناك مرحلتان تهمّان أكثر من غيرهما عادةً:
- المرحلتان 1–2 (تحديد المشكلة): حل المشكلة الخطأ بإتقان لا يخلق أي قيمة. القرار الدقيق ومقياس النجاح الواضح يركّزان كل ما بعدهما.
- المرحلتان 7–8 (القرار والتنفيذ والقياس): التحليل لا يؤتي ثماره إلا عندما يتصرف شخص بناءً عليه ويراجع النتيجة.
التحليل والنمذجة (المرحلة 5) أساسيان، لكن لا قيمة لهما إذا كان تحديد المشكلة خطأ أو لم يتصرف أحد.
13. مهمة عمل — خطة سير عمل مع ملاحظة استخدام الذكاء الاصطناعي
لقرار Cedar Lane "هل نكرر العرض؟"، اكتب خطة سير عمل من صفحة واحدة تتضمن:
- المراحل الثماني، ولكل منها نشاط ملموس واحد؛
- مقياس النجاح (المرحلة 2)؛
- المرحلة التي تعتقد أنها تخلق أكبر قيمة للقرار، مع تبرير في جملتين أو ثلاث؛
- ملاحظة استخدام الذكاء الاصطناعي: أين ستستخدمه، وما الذي ستتحقق منه، وما الذي لن تعطيه أبدًا لأداة ذكاء اصطناعي.
14. تحدٍّ قصير
سيناريو جديد (خيالي): مكتبة عامة في حيٍّ ما تريد أن تقرر هل تمدّ ساعات العمل المسائية.
- اكتب سير العمل من ثماني مراحل (سطر واحد لكل مرحلة).
- حدِّد المرحلة التي فيها أكبر خطر على الخصوصية، واشرح السبب.
- حدِّد نقطة واحدة يحتاج فيها اقتراح من الذكاء الاصطناعي إلى تحقق بشري قبل استخدامه.
- اقترح مقياس نجاح للمرحلة 8.
سلّم إجابتك قبل أي ملاحظات. لا يوجد حل هنا.
15. المصادر
- مطلوب (حوالي 15 دقيقة): AWS Cloud Adoption Framework: Business Perspective — Data science. ركّز على توصيات "Start". https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-science.html (دليل صناعي؛ الصفحة تذكر أنها historical whitepaper.)
- مقترح (حوالي 10 دقائق): NIST — صفحة التعريف بـ AI Risk Management Framework. اقرأ القسم الأول لترى لماذا يُعامَل الاستخدام الجدير بالثقة للذكاء الاصطناعي على أنه مسألة إدارة مخاطر. https://www.nist.gov/itl/ai-risk-management-framework (إطار من الحكومة الأمريكية؛ استخدامه اختياري.)
- للتعمّق (اختياري): عُد إلى قائمة Tasks لعلماء البيانات في O*NET، وضع بجانب كل مهمة مرحلتها في سير العمل من هذا الدرس. https://www.onetonline.org/link/summary/15-2051.00
16. شخصية تتابعها
ملاحظة عن خريطة المصادر: تذكر خريطة D.World عبارة "AWS data-science guidance" في خانة الشخصية القدوة لهذا الدرس. وهذا دليل صادر عن مؤسسة، وليس شخصًا. لذلك فالاقتراح التالي مؤقت ويحتاج إلى موافقة مسؤول المنهج.
اقتراح مؤقت: Cassie Kozyrkov. موقعها يضم رابطًا لمقال بعنوان "Why AI and Decisions are two sides of the same coin"، وهو يناسب فكرة هذا الدرس بأن عمل الذكاء الاصطناعي يجب أن يبقى مرتبطًا بقرارات البشر. https://www.kozyr.com/ (منصبها السابق حسب موقعها: أول Chief Decision Scientist في Google). تحدد خريطة المنهج Andrew Ng شخصيةً قدوة للوحدة U03 (الذكاء الاصطناعي في العمل مع البيانات)، وستتعرّف عليه هناك.
17. تأمّل
فكّر في آخر مرة استخدمت فيها أداة ذكاء اصطناعي في شيء مهم. في أي "مرحلة" كنت، وهل راجعت مخرجاتها قبل أن تتصرف؟ ماذا ستفعل بشكل مختلف وأنت تضع سير العمل هذا في ذهنك؟
18. الخطوة التالية
تكتمل U01 عندما تنجح في تقييم نهاية الوحدة U01: شرح سير العمل والفروق بين الأدوار بمثال من عالم الأعمال. بعدها تأتي U02 — أساسيات الأعمال لمحترفي البيانات، وتبدأ بـ L05 — كيف تعمل الشركات فعلًا. هذا الدرس يعلّمك أفكار الإيرادات والتكلفة والعملاء التي تقف خلف المرحلة 1 ("لماذا يهم هذا القرار؟") والمرحلة 2 ("كيف نقيس النجاح؟").
19. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| رسم سير العمل، الجزء A | أنك تستطيع ترتيب سير العمل بشكل صحيح | 7 مواضع صحيحة أو أكثر من 8 |
| رسم سير العمل، الجزء B | أنك تستطيع وضع مساعدة الذكاء الاصطناعي والتحقق البشري في مكانهما المعقول | معايير L04-B: مساعدة واقعية من الذكاء الاصطناعي أو "غير مناسب" مع تبرير؛ وفحص بشري ملموس مع سبب |
| الجزء C (C1–C3) | أنك تفهم منهج AWS، وملكية القرار، وأن مخرجات الذكاء الاصطناعي ليست دليلًا | 3 من 3 = يحقق المطلوب؛ 2 من 3 = يحتاج مراجعة |
| مهمة العمل (خطة سير العمل وملاحظة استخدام الذكاء الاصطناعي) | تخطيط متكامل مع استخدام مسؤول للذكاء الاصطناعي | معايير L04-WT |
| التدريب المستقل والتحدي القصير | نقل المهارة إلى سياق جديد | معايير L04-IP وL04-MC |
20. المراجع
- Amazon Web Services. AWS Cloud Adoption Framework: Business Perspective — Data science. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-science.html (تمت زيارتها ومراجعتها في 11 أكتوبر 2026). يدعم: إعادة صياغة التعريف؛ "define business problems… business value"؛ المقياس القابل للقياس "observable and quantifiable"؛ "evaluate whether ML is the right approach" (قد تنجح القواعد البسيطة بشكل أفضل)؛ نقاط القرار وحصر البيانات؛ إشراك أصحاب المصلحة واختيار مالك من جهة الأعمال؛ المتابعة والمراجعة البشرية للتنبؤات منخفضة الثقة؛ وملاحظة الصفحة نفسها بأنها "historical whitepaper".
- NIST. AI Risk Management Framework. https://www.nist.gov/itl/ai-risk-management-framework (تمت زيارتها في 11 أكتوبر 2026). يدعم: إصدار AI RMF في 26 يناير 2023، وأنه مخصص للاستخدام الاختياري، ويهدف إلى إدارة مخاطر الذكاء الاصطناعي.
- O*NET OnLine. Data Scientists (15-2051.00). https://www.onetonline.org/link/summary/15-2051.00 (تمت زيارتها في 11 أكتوبر 2026).
- Kozyrkov, C. الموقع الشخصي. https://www.kozyr.com/ (تمت زيارته في 11 أكتوبر 2026). يدعم: عنوان المقال المرتبط ومنصبها السابق كما يذكره موقعها.
- D.World Curriculum Bible v1.0: معيار دمج الذكاء الاصطناعي ("AI can accelerate your work. It cannot replace your judgment.")، وممارسة ملاحظة استخدام الذكاء الاصطناعي، وتسلسل التفكير في الأعمال.
U01 Exit Assessment — Data Science & the Modern Data Worldتقييم نهاية الوحدة U01 — علم البيانات وعالم البيانات الحديث Freeمجاني
U01 Exit Assessment — Data Science & the Modern Data World
Learner-facing instructions and rubric. The model answer and marking notes are in the instructor file (05). Version: U01 pilot v1.0 · 11 October 2026.
Unit exit criterion (from the D.World map): Explain the workflow and role differences using a real business example.
Estimated time: 60–75 minutes · Format: written decision brief, 450–750 words (tables allowed) · Allowed: your notes from L01–L04 and the linked resources. AI tools are allowed only as described in Part 7; you must include an AI-use note.
Choose your business example
Option A — provided case (recommended for most learners). FreshCart is a fictional grocery-delivery business in one city. The manager must decide whether to add a second delivery van on Saturdays. Customers have complained about late Saturday deliveries.
Synthetic data (invented for this assessment): orders and late deliveries over one week
| Day | Orders | Late deliveries |
|---|---|---|
| Mon | 80 | 4 |
| Tue | 75 | 3 |
| Wed | 82 | 5 |
| Thu | 90 | 6 |
| Fri | 110 | 9 |
| Sat | 160 | 28 |
| Sun | 70 | 3 |
Option B — a real type of business you know. Choose a real kind of organization you understand: for example, a local pharmacy, a school canteen or an online clothing shop. You may describe a real organization only from public information or your own general experience. - Do not use confidential, internal or personal data. - Do not present invented numbers as real facts about a real company. If you need numbers, label them "illustrative" or "synthetic."
What to submit — the decision brief
Write your brief with these eight headed parts.
Part 1 — Business and decision. Name one specific decision, why it matters (cost, revenue, customer, risk or product), and who owns it.
Part 2 — Question and success measure. Write the question data can help answer, and one measurable success measure for after the decision.
Part 3 — Data. List at least three data sources. Give one data-quality check you would do and one privacy consideration.
Part 4 — Workflow. Describe all eight workflow stages from L04 for your case, one or two lines each, in order.
Part 5 — Roles. Show who would typically do what. Include at least four roles: three data-related roles (for example, Data Analyst, Data Scientist, Data Engineer or ML Engineer) and the decision owner. In one or two sentences, explain how these roles may be combined or differ in a small vs a large organization.
Part 6 — Evidence reasoning. Give one observation, one hypothesis (labelled), and one piece of evidence that would test the hypothesis. If you chose Option A, use the table.
Part 7 — AI in the workflow. Name two stages where AI could assist and how. Name two places where human validation is mandatory and why. Add a 2–3 line AI-use note: if you used AI while writing, what for, and what you verified.
Part 8 — Decision and measurement. State who decides, one non-data factor they must weigh, and how the result will be measured afterwards.
Rubric
Each criterion is scored 0, 1 or 2.
| # | Criterion | 2 — Meets | 1 — Partly | 0 — Not yet |
|---|---|---|---|---|
| C1 | Decision framing (Parts 1–2) | Specific decision; clear business stake; data-answerable question; measurable success measure | Decision or measure vague | No real decision, or the question is not linked to one |
| C2 | Workflow (Part 4) | All 8 stages, logically ordered and specific to the case, including validation | 1–2 stages missing, generic or out of order | 3 or more stages missing, or no validation |
| C3 | Role differences (Part 5) | At least 4 roles with distinct, plausible responsibilities; notes that roles vary by organization; decision owner separate from the data team | Roles listed but blurred, or variation not mentioned | Roles missing or wrong, e.g. the "data scientist decides" |
| C4 | Evidence reasoning (Part 6) | Correct observation; labelled hypothesis; a relevant test; no causal over-claim; any calculation correct | One element weak, or mild over-claim | Hypothesis stated as fact, or calculations wrong |
| C5 | AI placement and verification (Part 7) | Realistic AI assistance; correct mandatory human validation points; privacy respected; AI-use note present | AI placement plausible but checks vague, or AI-use note missing | AI owns the decision, private data is given to AI, or AI output is treated as evidence |
| C6 | Business value and measurement (Parts 1 and 8) | Links the decision to value; names a non-data factor; post-decision measurement defined | Value or measurement only implied | No link to value or measurement |
Gate conditions (each must be met to pass)
- G1: No confidential or personal data is included.
- G2: No invented figure is presented as a real fact about a real organization.
- G3: The decision is owned by a person or role, not by AI or a model.
Result
- PASS: a total of 9 or more out of 12, no criterion scored 0, and all gates met.
- REVISE: anything else. You receive feedback on the specific criteria and may resubmit once the feedback is addressed.
This assessment checks understanding of U01 concepts. It is not a certification and makes no claim about job readiness.
تقييم نهاية الوحدة U01 — علم البيانات وعالم البيانات الحديث
تعليمات ومعايير تقييم موجّهة للمتعلّم. الإجابة النموذجية وملاحظات التصحيح موجودة في ملف المدرّس (05). الإصدار: U01 pilot v1.0 · 11 أكتوبر 2026.
معيار إنهاء الوحدة (من خريطة D.World): اشرح سير العمل والفروق بين الأدوار باستخدام مثال حقيقي من عالم الأعمال.
الوقت المتوقع: 60–75 دقيقة · الشكل: مذكرة قرار مكتوبة من 450 إلى 750 كلمة (يُسمح بالجداول) · المسموح: ملاحظاتك من L01–L04 والمصادر المرتبطة بها. أدوات الذكاء الاصطناعي مسموحة فقط بالطريقة الموضحة في الجزء 7، ويجب أن تضيف ملاحظة استخدام الذكاء الاصطناعي.
اختر مثالك من عالم الأعمال
الخيار A — حالة جاهزة (موصى بها لأغلب المتعلّمين). FreshCart شركة خيالية لتوصيل البقالة في مدينة واحدة. على المدير أن يقرر هل يضيف سيارة توصيل ثانية أيام السبت. فقد اشتكى العملاء من تأخر التوصيل يوم السبت.
بيانات مصطنعة (مختلَقة لهذا التقييم): الطلبات والتوصيلات المتأخرة خلال أسبوع واحد
| اليوم | الطلبات | التوصيلات المتأخرة |
|---|---|---|
| الإثنين | 80 | 4 |
| الثلاثاء | 75 | 3 |
| الأربعاء | 82 | 5 |
| الخميس | 90 | 6 |
| الجمعة | 110 | 9 |
| السبت | 160 | 28 |
| الأحد | 70 | 3 |
الخيار B — نوع حقيقي من الأعمال تعرفه. اختر نوعًا حقيقيًا من المؤسسات تفهمه: مثل صيدلية في الحي، أو مقصف مدرسة، أو متجر ملابس على الإنترنت. يمكنك وصف مؤسسة حقيقية فقط من المعلومات المتاحة للعامة أو من خبرتك العامة.
- لا تستخدم بيانات سرية أو داخلية أو شخصية.
- لا تعرض أرقامًا مخترعة على أنها حقائق عن شركة حقيقية. إذا احتجت أرقامًا، فاكتب بجانبها "توضيحية" أو "مصطنعة".
ما الذي تسلّمه — مذكرة القرار
اكتب مذكرتك في الأجزاء الثمانية التالية، ولكل جزء عنوانه.
الجزء 1 — العمل والقرار. حدِّد قرارًا واحدًا بعينه، ولماذا يهم (التكلفة، الإيرادات، العملاء، المخاطر، المنتج)، ومن يملكه.
الجزء 2 — السؤال ومقياس النجاح. اكتب السؤال الذي يمكن للبيانات أن تساعد في الإجابة عنه، ومقياس نجاح واحدًا قابلًا للقياس لما بعد القرار.
الجزء 3 — البيانات. اذكر ثلاثة مصادر بيانات على الأقل. واذكر فحصًا واحدًا لجودة البيانات ستقوم به، واعتبارًا واحدًا يخص الخصوصية.
الجزء 4 — سير العمل. صِف مراحل سير العمل الثماني من L04 لحالتك، في سطر أو سطرين لكل مرحلة، وبالترتيب.
الجزء 5 — الأدوار. وضّح من يقوم عادةً بماذا. اذكر أربعة أدوار على الأقل: ثلاثة أدوار مرتبطة بالبيانات (مثل Data Analyst أو Data Scientist أو Data Engineer أو ML Engineer)، وصاحب القرار. واشرح في جملة أو جملتين كيف يمكن أن تُدمج هذه الأدوار أو تختلف بين مؤسسة صغيرة ومؤسسة كبيرة.
الجزء 6 — التفكير بالأدلة. اذكر ملاحظة واحدة، وفرضية واحدة (مع وصفها بأنها فرضية)، ودليلًا واحدًا يمكن أن يختبر هذه الفرضية. إذا اخترت الخيار A، فاستخدم الجدول.
الجزء 7 — الذكاء الاصطناعي في سير العمل. سمِّ مرحلتين يمكن أن يساعد فيهما الذكاء الاصطناعي، وكيف. وسمِّ موضعين يكون فيهما التحقق البشري إلزاميًا، ولماذا. وأضف ملاحظة استخدام الذكاء الاصطناعي في سطرين أو ثلاثة: إذا استخدمته أثناء الكتابة، ففيمَ استخدمته، وما الذي تحققت منه.
الجزء 8 — القرار والقياس. حدِّد من يقرر، وعاملًا واحدًا غير مرتبط بالبيانات عليه أن يزنه، وكيف ستُقاس النتيجة بعد ذلك.
معايير التقييم
كل معيار يحصل على 0 أو 1 أو 2.
| # | المعيار | 2 — يحقق المطلوب | 1 — يحققه جزئيًا | 0 — لم يحققه بعد |
|---|---|---|---|---|
| C1 | صياغة القرار (الجزءان 1–2) | قرار محدد؛ أهمية واضحة للعمل؛ سؤال يمكن للبيانات الإجابة عنه؛ مقياس نجاح قابل للقياس | القرار أو المقياس غامض | لا يوجد قرار حقيقي، أو السؤال غير مرتبط بقرار |
| C2 | سير العمل (الجزء 4) | المراحل الثماني كلها، بترتيب منطقي ومخصصة للحالة، ومن بينها التحقق | مرحلة أو مرحلتان ناقصتان أو عامتان أو في غير ترتيبهما | 3 مراحل أو أكثر ناقصة، أو لا يوجد تحقق |
| C3 | الفروق بين الأدوار (الجزء 5) | 4 أدوار على الأقل بمسؤوليات مميزة ومعقولة؛ يذكر أن الأدوار تختلف من مؤسسة لأخرى؛ صاحب القرار منفصل عن فريق البيانات | الأدوار مذكورة لكنها متداخلة، أو لم يُذكر الاختلاف بين المؤسسات | الأدوار ناقصة أو خاطئة، مثل أن "عالم البيانات هو من يقرر" |
| C4 | التفكير بالأدلة (الجزء 6) | ملاحظة صحيحة؛ فرضية موصوفة بأنها فرضية؛ اختبار مناسب؛ لا مبالغة في ادعاء السببية؛ أي حساب صحيح | عنصر واحد ضعيف، أو مبالغة بسيطة في الادعاء | الفرضية مكتوبة على أنها حقيقة، أو الحسابات خاطئة |
| C5 | موضع الذكاء الاصطناعي والتحقق (الجزء 7) | مساعدة واقعية من الذكاء الاصطناعي؛ مواضع تحقق بشري إلزامي صحيحة؛ احترام الخصوصية؛ وجود ملاحظة استخدام الذكاء الاصطناعي | موضع الذكاء الاصطناعي معقول لكن الفحوصات غامضة، أو ملاحظة الاستخدام غير موجودة | الذكاء الاصطناعي يمتلك القرار، أو أُعطي بيانات خاصة، أو عوملت مخرجاته على أنها دليل |
| C6 | قيمة العمل والقياس (الجزءان 1 و8) | يربط القرار بالقيمة؛ يذكر عاملًا غير مرتبط بالبيانات؛ يحدد القياس بعد القرار | القيمة أو القياس مفهومان ضمنيًا فقط | لا ربط بالقيمة ولا بالقياس |
شروط أساسية (يجب تحقيق كل منها للنجاح)
- G1: لا توجد أي بيانات سرية أو شخصية.
- G2: لا يُعرض أي رقم مخترع على أنه حقيقة عن مؤسسة حقيقية.
- G3: القرار يملكه شخص أو دور، وليس الذكاء الاصطناعي أو نموذج.
النتيجة
- PASS (ناجح): مجموع 9 أو أكثر من 12، ولا يوجد معيار حصل على 0، وكل الشروط الأساسية متحققة.
- REVISE (يحتاج تعديلًا): أي نتيجة أخرى. ستصلك ملاحظات على المعايير المحددة، ويمكنك إعادة التسليم بعد معالجتها.
هذا التقييم يقيس فهمك لمفاهيم U01. وهو ليس شهادة معتمدة، ولا يدّعي أي شيء عن جاهزيتك للعمل.
U02 · Business Foundations for Data Professionalsأساسيات الأعمال لمحترفي البيانات
Stage 1المرحلة 1Free: every lesson in this unit.
مجاني: كل دروس هذه الوحدة.
L05 · How a Business Actually WorksL05 · كيف تعمل الشركات فعلًا Freeمجاني
L05 — How a Business Actually Works
Learner file. Answers and model solutions are in a separate instructor-only file. Version: U02 v1.0 · Content date: 11 October 2026. Time estimates are provisional until learner-tested.
1. Lesson Identity
| Field | Value |
|---|---|
| Title | How a Business Actually Works |
| Stage | Stage 1 — Foundations |
| Unit | U02 — Business Foundations for Data Professionals |
| Lesson ID | L05 |
| Skills | Business literacy |
| Difficulty | Beginner |
| Estimated time | About 1 hour 35 minutes (provisional) |
| Prerequisites | U01, especially the data → evidence → decision chain (L01) and the workflow stages "business problem and decision" and "question and success measure" (L04). No prior business study needed. |
Time breakdown (provisional): concept and worked example, 30 min · guided practice, 10 min · independent practice, 15 min · knowledge check (diagram and glossary), 10 min · AI in Practice and Verification, 10 min · workplace task, 10 min · mini challenge, 5 min · reflection and glossary review, 5 min.
2. Learning Objective
By the end of this lesson, you will be able to explain how a simple business works: its customers, products, operations, revenue, costs and profit. You will also be able to draw the value chain of a simple e-commerce company.
3. Why It Matters
In U01 you learned that data work starts with a business decision. To understand a decision, you need to understand the business behind it: who pays, for what, how the product reaches them, and what it costs to deliver.
A data analysis that ignores how money is made can be accurate but useless. For example, it might recommend selling more of a product that loses money on every sale. This lesson gives you the simple business map you will use in every later unit.
4. Concept
Plain-language version
A business exists because customers have a need. The business offers a product (goods or a service) that meets that need; this is its value. Customers pay for it, which brings in revenue. To create and deliver the product, the business spends money: these are costs. If revenue is larger than costs over a period, the business makes a profit.
Key principle: Customer → value → revenue → cost. Start with the customer and the value they receive. Revenue follows from value. Costs are what it takes to deliver that value. A business that starts from "how do we cut costs?" or "how do we get more revenue?" without understanding customer value often makes poor decisions.
The six building blocks
| Building block | Meaning | Cedar Lane example (fictional store) |
|---|---|---|
| Customer | Who buys (and sometimes a different person uses) | Students, office workers, gift buyers |
| Product | What is sold: physical goods, digital goods or services | Notebooks, pens, desk items |
| Value proposition | Why a customer chooses this business | Well-made stationery, delivered within 3 days |
| Operations | Activities that make and deliver the product | Buying stock, storing it, packing, shipping, answering questions |
| Revenue | Money received from sales in a period | Money from notebook and pen orders this month |
| Cost | Money spent to run the business in a period | Stock purchases, packaging, shipping, rent, wages, advertising |
Profit (simple version) = revenue − costs for the same period. In L06 you will split this into more precise lines (gross profit, operating expenses, net profit).
The value chain
A value chain is the sequence of activities a business performs to create and deliver value. For a simple online store:
- Sourcing: choosing and buying products from suppliers.
- Inventory: storing stock until it is sold.
- Marketing: helping potential customers find the store.
- Website and ordering: showing products and taking orders.
- Payment: collecting money securely.
- Fulfilment: picking, packing and shipping orders.
- Delivery: getting the order to the customer.
- Customer service and returns: answering questions, fixing problems, handling returns.
Every step can create value for the customer (good choice, fast delivery, helpful support) and every step creates cost. Data helps the business see where value and cost come from. Some steps produce revenue directly (ordering and payment). Others protect future revenue: good service brings customers back.
Business model, in one sentence
A business model describes how a business creates value for customers and earns money from it. For example: "Cedar Lane sells quality stationery online to students and office workers, earning revenue on each order and keeping costs low by holding a small range of popular products."
5. Worked Example
Scenario (fictional): Cedar Lane's owner says, "Shipping is getting expensive. Should we stop offering 3-day delivery?"
- Start with the customer. Who uses 3-day delivery? Students who need notebooks before term starts value speed.
- Value. Fast delivery is part of the value proposition in Section 4. Removing it might make Cedar Lane less attractive than other stores.
- Revenue. If fewer students buy, revenue may fall. How much depends on how many orders use 3-day delivery. That is a data question.
- Cost. 3-day delivery costs more per order than slower options. That cost is real.
- Where in the value chain? Step 7, delivery. It links to step 8: late or slow orders create customer-service work.
- Decision framing (from L04). Not "cut shipping costs," but "Which delivery option gives the best balance of customer value, revenue and cost?" Data needed: share of orders using 3-day delivery, delivery cost per order, repeat purchases by delivery type.
Notice the order: customer → value → revenue → cost. Starting only from cost would have hidden the risk to revenue.
6. Visual Explanation
CUSTOMER NEED --> VALUE OFFERED --> CUSTOMER PAYS (REVENUE)
|
Value chain: Sourcing -> Inventory -> Marketing -> Website & ordering -> Payment
-> Fulfilment -> Delivery -> Customer service & returns
|
each step uses money (COSTS)
|
PROFIT = REVENUE - COSTS (same period)
Alt text: A diagram reading top to bottom. A customer need leads to value offered, which leads to the customer paying, labelled revenue. Below is the eight-step value chain of an online store: sourcing, inventory, marketing, website and ordering, payment, fulfilment, delivery, customer service and returns. A note says each step uses money, labelled costs. At the bottom: profit equals revenue minus costs for the same period.
7. Guided Practice
For each Cedar Lane activity, write (a) the value-chain step (1–8 from Section 4), and (b) one cost it creates.
| # | Activity | Step | One cost |
|---|---|---|---|
| 1 | Placing an order of 500 notebooks with a supplier | ||
| 2 | Running an online advertisement for back-to-school | ||
| 3 | Putting notebooks in a box with protective paper | ||
| 4 | Replying to a customer whose parcel arrived damaged | ||
| 5 | Keeping stock on shelves in a small rented storeroom |
Hints: Think about where money leaves the business at that step: products, advertising, packaging materials, staff time, rent. Step numbers are in the Section 4 value-chain list.
8. Independent Practice
New scenario (fictional): Hilltop Honey sells jars of local honey online to customers in its country.
Write: 1. its customer(s) and value proposition (1–2 sentences); 2. its value chain in 6–8 steps (you may adapt the steps in Section 4; honey must be collected and jarred before sourcing stock is possible); 3. one cost and one way to create customer value at three of your steps; 4. a one-sentence business model.
No model answer is shown here.
9. Knowledge Check — Diagram Exercise + Glossary Check
Part A — Glossary check. Match each term (1–8) to its definition (a–h).
| # | Term | Letter | Definition | |
|---|---|---|---|---|
| 1 | Customer | a | Money a business receives from selling products or services in a period | |
| 2 | Product | b | The person or organization that buys (and sometimes uses) what is sold | |
| 3 | Operations | c | What remains after costs are subtracted from revenue for the same period | |
| 4 | Revenue | d | The activities that make and deliver the product, such as buying stock, storing, packing, shipping and support | |
| 5 | Cost | e | The reason a customer chooses this business: the need it meets or the benefit it offers | |
| 6 | Profit | f | Money spent to run the business, such as product purchases, wages, rent and shipping | |
| 7 | Value proposition | g | The sequence of activities a business performs to create and deliver value | |
| 8 | Value chain | h | What the business sells: physical goods, digital goods or services |
Part B — Diagram exercise. Put these eight boxes in value-chain order for an online store. Then, for any two boxes, add one arrow label saying what flows to the next step (for example, products or orders).
Payment · Delivery · Sourcing · Customer service & returns · Website & ordering · Inventory · Fulfilment · Marketing
Part C — Choose the best answer.
C1. In one month, Cedar Lane's revenue is 15,000 USD and its total costs are 14,000 USD. Which statement is correct? - A) Profit is 15,000 USD, because that is what customers paid. - B) Profit is 1,000 USD. - C) Profit is 29,000 USD. - D) Profit cannot be calculated without knowing the number of customers.
C2. Which statement best follows the principle customer → value → revenue → cost? - A) Cut every cost first, then look for customers who accept the result. - B) Revenue comes first; customers and value can be decided later. - C) Costs create value automatically, so higher costs always mean more value. - D) Customers have a need, the business offers value that meets it, customers pay (revenue), and delivering that value creates costs.
C3. Which is an operations activity for Cedar Lane? - A) Setting next year's profit target - B) Choosing the brand's colours - C) Picking, packing and shipping orders - D) A customer reading a product review
10. AI in Practice
Prompt an AI assistant (fictional business, no real data):
"Explain the business model of a fictional online stationery store in simple English: its customers, value proposition, value chain, revenue and main costs. Then give one counterexample: a realistic situation where your explanation would be wrong or incomplete (for example, a business that gives products away free but still earns money)."
Then challenge the explanation yourself with your own counterexample. For example: "What if most customers are businesses ordering in bulk, not individuals?" Ask the AI how its explanation would change.
Why this can help: a counterexample tests whether an explanation really holds. If a small change breaks it, you have found an assumption.
11. AI Verification
- Check each building block against Section 4. Did the AI confuse revenue with profit, or list "profit" as a revenue source? Correct it.
- Check the value chain is in a logical order and that each step is realistic for a small online store.
- Check the counterexample. Is it truly a different business model (for example, free product paid for by advertising), or only a reworded version of the first? Explain in one sentence.
- Remove invented facts. If the AI states figures ("stationery margins are usually 60%") without a source, delete them. They are not evidence (U01, L02).
- Privacy: use only fictional businesses. Do not paste your employer's or any real company's internal information.
12. Business Lens
Write the value chain of a simple e-commerce company. This is the core business skill of this lesson, and you will do it in the Workplace Task.
Why a business cares: a value chain shows where money is spent and where customers experience value. When something goes wrong ("costs are up," "customers are unhappy"), the value chain tells a data professional where to look first.
13. Workplace Task — Business Model Map
Create a one-page business model map for Cedar Lane (or another fictional online store of your choice). It must include:
- customers (at least two groups) and the value proposition;
- products;
- the value chain (at least 7 steps), each with one cost and one source of customer value;
- where revenue enters;
- one business decision (from U01) that this map helps you think about, and which value-chain step it relates to.
A table or a simple text diagram is fine.
14. Mini Challenge
New scenario (fictional): a mobile car-wash service washes cars at customers' homes and offices.
- Who are its customers, and what is its value proposition?
- Write its value chain. Note that it sells a service, not a stored product. Which online-store steps disappear, and which new steps appear?
- Name its two largest likely costs and explain why.
- Write one decision this business might use data for.
Submit before feedback. No solution is provided here.
15. Resources
- Required (about 15 min): AWS Cloud Adoption Framework: Business Perspective — Business insights. Read the opening description and the "Start" recommendations. Notice the emphasis on identifying business decisions and tracking the right metrics. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/business-insights.html (Opened 11 Oct 2026. The page states it is for historical reference only; use it for principles, not current product details.)
- Recommended (about 10 min): OpenStax, Principles of Accounting, Volume 1: Financial Accounting, section 6.6 (income statements for merchandising companies). Skim the overview to see how a store's sales and costs are reported; L06 goes deeper. https://openstax.org/books/principles-financial-accounting/pages/6-6-describe-and-prepare-multi-step-and-simple-income-statements-for-merchandising-companies (Opened 11 Oct 2026; open textbook, CC BY-NC-SA 4.0.)
- Deeper (optional): revisit U01 L04, stage 1 ("business problem and decision"), and rewrite one of your L04 workflow plans using today's business vocabulary.
16. Person to Follow / Role Model
Wes McKinney (assigned by the D.World map). His website (checked 11 Oct 2026) says he wrote Python for Data Analysis, which can be read free online at https://wesmckinney.com/book/. The 3rd edition is updated for pandas 2.0.0 and Python 3.10, per that page.
Why he is listed here, honestly: his work is about practical data analysis with Python. You will meet that work in later units (Python in U04, data handling in Stage 2). For today, notice that analysis tools exist to answer business questions like the ones in this lesson. You do not need to read the book now.
Note: the D.World map's role-model sheet links Wes McKinney mainly to U04; his placement in L05 is recorded as a source-map note.
17. Glossary
| Term | Meaning in this lesson |
|---|---|
| Customer | The person or organization that buys (and sometimes uses) what is sold |
| Product | What is sold: goods or services |
| Value proposition | Why a customer chooses this business |
| Operations | Activities that make and deliver the product |
| Revenue | Money received from sales in a period |
| Cost | Money spent to run the business in a period |
| Profit (simple) | Revenue − costs for the same period |
| Value chain | The ordered activities that create and deliver value |
| Business model | How a business creates value for customers and earns money from it |
| Fulfilment | Picking, packing and shipping orders |
18. Reflection
Think of a business you use often. Before this lesson, would you have described it by what it sells or by the value it gives you? Which one tells you more about how it makes money?
19. Next Step
You now know that profit = revenue − costs, in simple form. In L06 — Revenue, Cost, Profit & Margin, you will separate costs into product costs and operating expenses, and calculate gross profit, gross margin and net profit. You will then see why a business can grow revenue and still earn less profit.
20. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Glossary check (Part A) | You know the core vocabulary | 7 or more of 8 correct |
| Diagram exercise (Part B) | You can order a value chain and describe flows | Correct order (adjacent swaps accepted with a reason) + 2 sensible flow labels |
| Part C (C1–C3) | You can apply the basic building blocks | 3 of 3 = meets; 2 of 3 = review |
| Workplace task (business model map) | You can map a simple e-commerce business | Rubric L05-WT (instructor file) |
| Independent practice and mini challenge | Transfer to new businesses | Rubrics L05-IP and L05-MC |
References
- Amazon Web Services. AWS Cloud Adoption Framework: Business Perspective — Business insights. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/business-insights.html (opened and checked 11 Oct 2026). Supports: the emphasis on identifying business decisions that need insights and on tracking metrics; the page's historical-reference notice.
- OpenStax. Principles of Accounting, Volume 1: Financial Accounting, §6.6. https://openstax.org/books/principles-financial-accounting/pages/6-6-describe-and-prepare-multi-step-and-simple-income-statements-for-merchandising-companies (opened 11 Oct 2026). Supports: the recommended reading on how a store reports sales and costs.
- McKinney, W. Website and book page. https://wesmckinney.com/ and https://wesmckinney.com/book/ (opened 11 Oct 2026). Supports: authorship of Python for Data Analysis, free online access, and the 3rd-edition description.
- D.World Curriculum Map v1.0 (L05 row) and Curriculum Bible v1.0 (business integration standard). Internal.
L05 — كيف تعمل الشركات فعلًا
ملف المتعلّم. الإجابات والحلول النموذجية في ملف منفصل خاص بالمدرّس فقط. الإصدار: U02 v1.0 · تاريخ المحتوى: 11 أكتوبر 2026. تقديرات الوقت مبدئية إلى أن تُجرَّب مع المتعلّمين.
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | كيف تعمل الشركات فعلًا |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U02 — أساسيات الأعمال لمحترفي البيانات |
| رقم الدرس | L05 |
| المهارات | فهم الأعمال |
| المستوى | مبتدئ |
| الوقت المتوقع | حوالي ساعة و35 دقيقة (مبدئي) |
| المتطلبات السابقة | U01، وخاصة سلسلة البيانات ← الدليل ← القرار (L01)، ومرحلتا سير العمل "مشكلة العمل والقرار" و"السؤال ومقياس النجاح" (L04). لا تحتاج دراسة سابقة في إدارة الأعمال. |
تفصيل الوقت (مبدئي): المفهوم والمثال المحلول 30 دقيقة · التدريب الموجَّه 10 دقائق · التدريب المستقل 15 دقيقة · اختبار الفهم (الرسم والمصطلحات) 10 دقائق · الذكاء الاصطناعي في التطبيق والتحقق 10 دقائق · مهمة العمل 10 دقائق · التحدي القصير 5 دقائق · التأمّل ومراجعة المصطلحات 5 دقائق.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تشرح كيف يعمل نشاط تجاري بسيط: عملاؤه، ومنتجاته، وعملياته، وإيراداته، وتكاليفه، وربحه. وستكون قادرًا أيضًا على أن ترسم سلسلة القيمة لشركة تجارة إلكترونية بسيطة.
3. لماذا يهمّك هذا؟
تعلّمت في U01 أن العمل مع البيانات يبدأ من قرار عمل. ولكي تفهم القرار، تحتاج إلى أن تفهم النشاط التجاري الذي يقف خلفه: من يدفع، ومقابل ماذا، وكيف يصل المنتج إليه، وكم يكلّف تقديمه.
التحليل الذي يتجاهل طريقة كسب المال قد يكون دقيقًا لكنه بلا فائدة. مثلًا، قد يوصي ببيع كمية أكبر من منتج يخسر المتجر في كل عملية بيع له. هذا الدرس يعطيك الخريطة البسيطة للأعمال التي ستستخدمها في كل الوحدات القادمة.
4. المفهوم
الشرح بلغة بسيطة
يوجد النشاط التجاري لأن لدى العملاء (customers) حاجة. يقدّم النشاط منتجًا (product)، سلعة أو خدمة، يلبّي هذه الحاجة؛ وهذه هي القيمة (value) التي يقدّمها. يدفع العملاء مقابل ذلك، فتدخل الإيرادات (revenue). ولكي يصنع النشاط المنتج ويوصله، فإنه ينفق المال: وهذه هي التكاليف (costs). وإذا كانت الإيرادات أكبر من التكاليف خلال فترة معيّنة، يحقق النشاط ربحًا (profit).
المبدأ الأساسي: العميل ← القيمة ← الإيرادات ← التكلفة. ابدأ بالعميل وبالقيمة التي يحصل عليها. الإيرادات تأتي نتيجة للقيمة، والتكاليف هي ما يتطلبه تقديم هذه القيمة. النشاط الذي يبدأ من سؤال "كيف نخفض التكاليف؟" أو "كيف نزيد الإيرادات؟" دون أن يفهم قيمة العميل، غالبًا ما يتخذ قرارات ضعيفة.
اللبنات الست
| اللبنة | المعنى | مثال من Cedar Lane (متجر خيالي) |
|---|---|---|
| العميل | من يشتري (وأحيانًا يستخدم المنتج شخص آخر) | الطلاب، والموظفون في المكاتب، ومن يشترون الهدايا |
| المنتج | ما يُباع: سلع مادية، أو سلع رقمية، أو خدمات | الدفاتر، والأقلام، وأدوات المكتب |
| عرض القيمة (value proposition) | لماذا يختار العميل هذا النشاط بالذات | أدوات مكتبية جيدة الصنع، تصل خلال 3 أيام |
| العمليات (operations) | الأنشطة التي تصنع المنتج وتوصله | شراء المخزون، وتخزينه، وتغليف الطلبات، وشحنها، والرد على الأسئلة |
| الإيرادات | المال الذي يدخل من المبيعات خلال فترة معيّنة | المال الذي جاء من طلبات الدفاتر والأقلام هذا الشهر |
| التكلفة | المال الذي يُنفَق لتشغيل النشاط خلال فترة معيّنة | شراء المخزون، ومواد التغليف، والشحن، والإيجار، والأجور، والإعلانات |
الربح (بصيغة مبسطة) = الإيرادات − التكاليف عن الفترة نفسها. في L06 ستقسّم هذه المعادلة إلى بنود أدق (مجمل الربح، ومصروفات التشغيل، وصافي الربح).
سلسلة القيمة
سلسلة القيمة (value chain) هي تتابع الأنشطة التي يقوم بها النشاط التجاري ليصنع القيمة ويقدّمها. في متجر إلكتروني بسيط تكون كالتالي:
- التوريد (sourcing): اختيار المنتجات وشراؤها من الموردين.
- المخزون (inventory): تخزين البضاعة حتى تُباع.
- التسويق (marketing): مساعدة العملاء المحتملين على الوصول إلى المتجر.
- الموقع والطلب: عرض المنتجات واستقبال الطلبات.
- الدفع: تحصيل المال بطريقة آمنة.
- تجهيز الطلبات (fulfilment): انتقاء المنتجات، وتغليفها، وشحنها.
- التوصيل: إيصال الطلب إلى العميل.
- خدمة العملاء والمرتجعات: الرد على الأسئلة، وحل المشكلات، والتعامل مع المرتجعات.
كل خطوة يمكن أن تصنع قيمة للعميل (اختيار جيد، توصيل سريع، دعم مفيد)، وكل خطوة تصنع تكلفة. البيانات تساعد النشاط على أن يرى من أين تأتي القيمة ومن أين تأتي التكلفة. بعض الخطوات تُنتج إيرادات مباشرة (الطلب والدفع)، وأخرى تحمي الإيرادات المستقبلية: فالخدمة الجيدة تجعل العملاء يعودون.
نموذج العمل في جملة واحدة
نموذج العمل (business model) يصف كيف يصنع النشاط التجاري قيمة للعملاء وكيف يكسب المال منها. مثلًا: "تبيع Cedar Lane أدوات مكتبية عالية الجودة على الإنترنت للطلاب والموظفين، وتكسب إيرادات من كل طلب، وتُبقي تكاليفها منخفضة بالاحتفاظ بتشكيلة صغيرة من المنتجات الأكثر طلبًا."
5. مثال محلول
السيناريو (خيالي): يقول صاحب Cedar Lane: "الشحن أصبح مكلفًا. هل نتوقف عن تقديم التوصيل خلال 3 أيام؟"
- ابدأ بالعميل. من يستخدم التوصيل خلال 3 أيام؟ الطلاب الذين يحتاجون الدفاتر قبل بداية الدراسة يقدّرون السرعة.
- القيمة. التوصيل السريع جزء من عرض القيمة في القسم 4. إلغاؤه قد يجعل Cedar Lane أقل جاذبية من المتاجر الأخرى.
- الإيرادات. إذا قلّ عدد الطلاب الذين يشترون، فقد تنخفض الإيرادات. ومقدار الانخفاض يعتمد على عدد الطلبات التي تستخدم التوصيل خلال 3 أيام. وهذا سؤال بيانات.
- التكلفة. التوصيل خلال 3 أيام يكلّف في كل طلب أكثر من الخيارات الأبطأ. وهذه تكلفة حقيقية.
- أين يقع ذلك في سلسلة القيمة؟ في الخطوة 7، التوصيل. وهي مرتبطة بالخطوة 8: الطلبات المتأخرة أو البطيئة تخلق عملًا إضافيًا لخدمة العملاء.
- صياغة القرار (من L04). ليس "خفض تكاليف الشحن"، بل "أي خيار توصيل يعطي أفضل توازن بين قيمة العميل والإيرادات والتكلفة؟" البيانات المطلوبة: نسبة الطلبات التي تستخدم التوصيل خلال 3 أيام، وتكلفة التوصيل لكل طلب، وتكرار الشراء حسب نوع التوصيل.
لاحظ الترتيب: العميل ← القيمة ← الإيرادات ← التكلفة. لو بدأنا من التكلفة وحدها لاختفى عنا الخطر على الإيرادات.
6. شرح بصري
CUSTOMER NEED --> VALUE OFFERED --> CUSTOMER PAYS (REVENUE)
|
Value chain: Sourcing -> Inventory -> Marketing -> Website & ordering -> Payment
-> Fulfilment -> Delivery -> Customer service & returns
|
each step uses money (COSTS)
|
PROFIT = REVENUE - COSTS (same period)
وصف الرسم: رسم يُقرأ من أعلى إلى أسفل. حاجة العميل (Customer need) تؤدي إلى القيمة المقدَّمة (Value offered)، التي تؤدي إلى أن يدفع العميل، ومكتوب عليها الإيرادات (Revenue). وتحتها سلسلة القيمة لمتجر إلكتروني في ثماني خطوات: التوريد، والمخزون، والتسويق، والموقع والطلب، والدفع، وتجهيز الطلبات، والتوصيل، وخدمة العملاء والمرتجعات. وملاحظة تقول إن كل خطوة تستهلك مالًا، ومكتوب عليها التكاليف (Costs). وفي الأسفل: الربح يساوي الإيرادات ناقص التكاليف عن الفترة نفسها.
7. تدريب موجَّه
لكل نشاط من أنشطة Cedar Lane، اكتب (أ) خطوة سلسلة القيمة (من 1 إلى 8 في القسم 4)، و(ب) تكلفة واحدة يخلقها.
| # | النشاط | الخطوة | تكلفة واحدة |
|---|---|---|---|
| 1 | طلب 500 دفتر من أحد الموردين | ||
| 2 | نشر إعلان على الإنترنت لموسم العودة إلى المدارس | ||
| 3 | وضع الدفاتر في صندوق مع ورق حماية | ||
| 4 | الرد على عميل وصله الطرد تالفًا | ||
| 5 | الاحتفاظ بالمخزون على الرفوف في مخزن صغير مستأجر |
تلميحات: فكّر أين يخرج المال من النشاط في هذه الخطوة: المنتجات، والإعلانات، ومواد التغليف، ووقت الموظفين، والإيجار. أرقام الخطوات موجودة في قائمة سلسلة القيمة في القسم 4.
8. تدريب مستقل
سيناريو جديد (خيالي): Hilltop Honey تبيع برطمانات عسل محلي على الإنترنت لعملاء داخل بلدها.
اكتب:
- عملاءها وعرض القيمة الخاص بها (جملة أو جملتان)؛
- سلسلة القيمة الخاصة بها في 6–8 خطوات (يمكنك تعديل خطوات القسم 4؛ فالعسل يجب أن يُجمع ويُعبّأ في البرطمانات قبل أن يصبح هناك مخزون)؛
- تكلفة واحدة وطريقة واحدة لصنع قيمة للعميل في ثلاث من خطواتك؛
- نموذج العمل في جملة واحدة.
لا توجد إجابة نموذجية هنا.
9. اختبار الفهم — تمرين رسم + مراجعة المصطلحات
الجزء A — مراجعة المصطلحات. طابق كل مصطلح (1–8) مع تعريفه (a–h).
| # | المصطلح | الحرف | التعريف | |
|---|---|---|---|---|
| 1 | العميل (Customer) | a | المال الذي يحصل عليه النشاط من بيع المنتجات أو الخدمات خلال فترة معيّنة | |
| 2 | المنتج (Product) | b | الشخص أو المؤسسة التي تشتري ما يُباع (وأحيانًا تستخدمه) | |
| 3 | العمليات (Operations) | c | ما يتبقى بعد طرح التكاليف من الإيرادات عن الفترة نفسها | |
| 4 | الإيرادات (Revenue) | d | الأنشطة التي تصنع المنتج وتوصله، مثل شراء المخزون، والتخزين، والتغليف، والشحن، والدعم | |
| 5 | التكلفة (Cost) | e | سبب اختيار العميل لهذا النشاط: الحاجة التي يلبّيها أو الفائدة التي يقدّمها | |
| 6 | الربح (Profit) | f | المال الذي يُنفَق لتشغيل النشاط، مثل شراء المنتجات، والأجور، والإيجار، والشحن | |
| 7 | عرض القيمة (Value proposition) | g | تتابع الأنشطة التي يقوم بها النشاط ليصنع القيمة ويقدّمها | |
| 8 | سلسلة القيمة (Value chain) | h | ما يبيعه النشاط: سلع مادية، أو سلع رقمية، أو خدمات |
الجزء B — تمرين رسم. رتّب هذه المربعات الثمانية حسب ترتيب سلسلة القيمة في متجر إلكتروني. ثم، لأي مربعين، أضف عنوانًا لسهم يوضح ما الذي ينتقل إلى الخطوة التالية (مثل المنتجات أو الطلبات).
Payment (الدفع) · Delivery (التوصيل) · Sourcing (التوريد) · Customer service & returns (خدمة العملاء والمرتجعات) · Website & ordering (الموقع والطلب) · Inventory (المخزون) · Fulfilment (تجهيز الطلبات) · Marketing (التسويق)
الجزء C — اختر أفضل إجابة.
C1. في شهر واحد، كانت إيرادات Cedar Lane 15,000 دولار وتكاليفها الإجمالية 14,000 دولار. أي عبارة صحيحة؟ - A) الربح 15,000 دولار، لأن هذا ما دفعه العملاء. - B) الربح 1,000 دولار. - C) الربح 29,000 دولار. - D) لا يمكن حساب الربح دون معرفة عدد العملاء.
C2. أي عبارة تتبع المبدأ العميل ← القيمة ← الإيرادات ← التكلفة على أفضل وجه؟ - A) اخفض كل التكاليف أولًا، ثم ابحث عن عملاء يقبلون النتيجة. - B) الإيرادات أولًا؛ ويمكن تحديد العملاء والقيمة لاحقًا. - C) التكاليف تصنع القيمة تلقائيًا، لذلك فالتكاليف الأعلى تعني دائمًا قيمة أكبر. - D) لدى العملاء حاجة، ويقدّم النشاط قيمة تلبّيها، فيدفع العملاء (الإيرادات)، وتقديم هذه القيمة يخلق تكاليف.
C3. أي مما يلي يُعدّ نشاطًا من العمليات في Cedar Lane؟ - A) تحديد هدف الربح للعام القادم - B) اختيار ألوان العلامة التجارية - C) انتقاء الطلبات وتغليفها وشحنها - D) عميل يقرأ تقييمًا لأحد المنتجات
10. الذكاء الاصطناعي في التطبيق
اكتب لمساعد ذكاء اصطناعي الطلب التالي (نشاط خيالي، بلا بيانات حقيقية):
"Explain the business model of a fictional online stationery store in simple English: its customers, value proposition, value chain, revenue and main costs. Then give one counterexample: a realistic situation where your explanation would be wrong or incomplete (for example, a business that gives products away free but still earns money)."
وبالعربية: "اشرح بلغة بسيطة نموذج العمل لمتجر خيالي للأدوات المكتبية على الإنترنت: عملاءه، وعرض القيمة، وسلسلة القيمة، والإيرادات، وأهم التكاليف. ثم أعطني مثالًا مضادًا واحدًا: موقفًا واقعيًا يكون فيه شرحك خاطئًا أو ناقصًا (مثل نشاط يقدّم منتجاته مجانًا لكنه ما زال يكسب المال)."
ثم تحدَّ الشرح بنفسك بمثال مضاد من عندك. مثلًا: "ماذا لو كان أغلب العملاء شركات تطلب بكميات كبيرة، وليس أفرادًا؟" واسأل الذكاء الاصطناعي كيف سيتغيّر شرحه.
لماذا قد يفيد هذا: المثال المضاد يختبر هل يصمد الشرح فعلًا. إذا كسره تغيير صغير، فقد وجدت افتراضًا.
11. التحقق من مخرجات الذكاء الاصطناعي
- راجع كل لبنة مقارنةً بالقسم 4. هل خلط الذكاء الاصطناعي بين الإيرادات والربح، أو ذكر "الربح" على أنه مصدر للإيرادات؟ صحّح ذلك.
- راجع سلسلة القيمة: هل ترتيبها منطقي، وهل كل خطوة واقعية لمتجر إلكتروني صغير؟
- راجع المثال المضاد. هل هو نموذج عمل مختلف فعلًا (مثل منتج مجاني يموّله الإعلان)، أم مجرد إعادة صياغة للأول؟ اشرح في جملة واحدة.
- احذف الحقائق المخترعة. إذا ذكر الذكاء الاصطناعي أرقامًا ("هامش ربح الأدوات المكتبية عادةً 60%") دون مصدر، فاحذفها. فهي ليست دليلًا (U01، L02).
- الخصوصية: استخدم أنشطة خيالية فقط. لا تلصق معلومات داخلية خاصة بجهة عملك أو بأي شركة حقيقية.
12. منظور الأعمال
اكتب سلسلة القيمة لشركة تجارة إلكترونية بسيطة. هذه هي مهارة الأعمال الأساسية في هذا الدرس، وستطبّقها في مهمة العمل.
لماذا يهتم النشاط التجاري بهذا؟ سلسلة القيمة توضح أين يُنفَق المال وأين يشعر العملاء بالقيمة. وعندما يحدث خطأ ما ("التكاليف ارتفعت"، "العملاء غير راضين")، تخبر سلسلة القيمة محترف البيانات أين يبحث أولًا.
13. مهمة عمل — خريطة نموذج العمل
أنشئ خريطة نموذج عمل من صفحة واحدة لـ Cedar Lane (أو لمتجر إلكتروني خيالي آخر من اختيارك). يجب أن تتضمن:
- العملاء (مجموعتان على الأقل) وعرض القيمة؛
- المنتجات؛
- سلسلة القيمة (7 خطوات على الأقل)، ولكل خطوة تكلفة واحدة ومصدر واحد لقيمة العميل؛
- النقطة التي تدخل منها الإيرادات؛
- قرار عمل واحد (من U01) تساعدك هذه الخريطة على التفكير فيه، وبأي خطوة من سلسلة القيمة يرتبط.
يكفي جدول أو رسم نصي بسيط.
14. تحدٍّ قصير
سيناريو جديد (خيالي): خدمة غسيل سيارات متنقلة تغسل السيارات عند منازل العملاء ومكاتبهم.
- من عملاؤها، وما عرض القيمة الخاص بها؟
- اكتب سلسلة القيمة الخاصة بها. لاحظ أنها تبيع خدمة، وليس منتجًا مخزّنًا. أي خطوات المتجر الإلكتروني تختفي، وأي خطوات جديدة تظهر؟
- سمِّ أكبر تكلفتين محتملتين لها، واشرح السبب.
- اكتب قرارًا واحدًا قد يستخدم فيه هذا النشاط البيانات.
سلّم إجابتك قبل أي ملاحظات. لا يوجد حل هنا.
15. المصادر
- مطلوب (حوالي 15 دقيقة): AWS Cloud Adoption Framework: Business Perspective — Business insights. اقرأ الوصف الافتتاحي وتوصيات "Start". لاحظ التركيز على تحديد قرارات العمل ومتابعة المقاييس الصحيحة. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/business-insights.html (فُتحت في 11 أكتوبر 2026. الصفحة تذكر أنها للرجوع التاريخي فقط؛ استخدمها للمبادئ، لا لتفاصيل المنتجات الحالية.)
- مقترح (حوالي 10 دقائق): OpenStax، Principles of Accounting, Volume 1: Financial Accounting، القسم 6.6 (قوائم الدخل للشركات التجارية). تصفّح النظرة العامة لترى كيف تُعرض مبيعات المتجر وتكاليفه؛ وسيتعمّق L06 في ذلك. https://openstax.org/books/principles-financial-accounting/pages/6-6-describe-and-prepare-multi-step-and-simple-income-statements-for-merchandising-companies (فُتح في 11 أكتوبر 2026؛ كتاب مفتوح، CC BY-NC-SA 4.0.)
- للتعمّق (اختياري): عُد إلى L04 في U01، المرحلة 1 ("مشكلة العمل والقرار")، وأعِد كتابة إحدى خطط سير العمل التي كتبتها في L04 باستخدام مفردات الأعمال التي تعلّمتها اليوم.
16. شخصية تتابعها / قدوة
Wes McKinney (محدد في خريطة D.World). يذكر موقعه (تمت مراجعته في 11 أكتوبر 2026) أنه مؤلف كتاب Python for Data Analysis، الذي يمكن قراءته مجانًا على الإنترنت على https://wesmckinney.com/book/. والإصدار الثالث محدّث ليتوافق مع pandas 2.0.0 وPython 3.10، حسب تلك الصفحة.
لماذا هو مذكور هنا، بصراحة: عمله يدور حول تحليل البيانات عمليًا باستخدام Python. ستقابل هذا العمل في وحدات لاحقة (Python في U04، والتعامل مع البيانات في المرحلة 2). أما اليوم، فلاحظ أن أدوات التحليل موجودة للإجابة عن أسئلة عمل مثل التي في هذا الدرس. لا تحتاج إلى قراءة الكتاب الآن.
ملاحظة: ورقة الشخصيات القدوة في خريطة D.World تربط Wes McKinney أساسًا بالوحدة U04؛ ووضعه في L05 مسجّل كملاحظة في خريطة المصادر.
17. المصطلحات
| المصطلح | معناه في هذا الدرس |
|---|---|
| العميل (Customer) | الشخص أو المؤسسة التي تشتري ما يُباع (وأحيانًا تستخدمه) |
| المنتج (Product) | ما يُباع: سلع أو خدمات |
| عرض القيمة (Value proposition) | لماذا يختار العميل هذا النشاط بالذات |
| العمليات (Operations) | الأنشطة التي تصنع المنتج وتوصله |
| الإيرادات (Revenue) | المال الذي يدخل من المبيعات خلال فترة معيّنة |
| التكلفة (Cost) | المال الذي يُنفَق لتشغيل النشاط خلال فترة معيّنة |
| الربح (بصيغة مبسطة) (Profit) | الإيرادات − التكاليف عن الفترة نفسها |
| سلسلة القيمة (Value chain) | الأنشطة المرتبة التي تصنع القيمة وتقدّمها |
| نموذج العمل (Business model) | كيف يصنع النشاط قيمة للعملاء ويكسب المال منها |
| تجهيز الطلبات (Fulfilment) | انتقاء الطلبات وتغليفها وشحنها |
18. تأمّل
فكّر في نشاط تجاري تتعامل معه كثيرًا. قبل هذا الدرس، هل كنت ستصفه بما يبيعه أم بـالقيمة التي يعطيها لك؟ وأيهما يخبرك أكثر عن طريقة كسبه للمال؟
19. الخطوة التالية
أصبحت تعرف أن الربح = الإيرادات − التكاليف، بصيغته المبسطة. في L06 — الإيرادات والتكلفة والربح وهامش الربح، ستفصل التكاليف إلى تكاليف المنتج ومصروفات التشغيل، وتحسب مجمل الربح، وهامش الربح الإجمالي، وصافي الربح. ثم سترى لماذا يمكن أن تنمو إيرادات النشاط بينما يكسب ربحًا أقل.
20. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| مراجعة المصطلحات (الجزء A) | أنك تعرف المفردات الأساسية | 7 إجابات صحيحة أو أكثر من 8 |
| تمرين الرسم (الجزء B) | أنك تستطيع ترتيب سلسلة القيمة ووصف ما ينتقل بين خطواتها | ترتيب صحيح (يُقبل تبديل خطوتين متجاورتين مع ذكر السبب) + عنوانان معقولان لما ينتقل |
| الجزء C (C1–C3) | أنك تستطيع تطبيق اللبنات الأساسية | 3 من 3 = يحقق المطلوب؛ 2 من 3 = يحتاج مراجعة |
| مهمة العمل (خريطة نموذج العمل) | أنك تستطيع رسم خريطة لنشاط تجارة إلكترونية بسيط | معايير L05-WT (في ملف المدرّس) |
| التدريب المستقل والتحدي القصير | نقل المهارة إلى أنشطة تجارية جديدة | معايير L05-IP وL05-MC |
المراجع
- Amazon Web Services. AWS Cloud Adoption Framework: Business Perspective — Business insights. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/business-insights.html (فُتحت وروجعت في 11 أكتوبر 2026). يدعم: التركيز على تحديد قرارات العمل التي تحتاج إلى استنتاجات، وعلى متابعة المقاييس؛ وملاحظة الصفحة بأنها للرجوع التاريخي.
- OpenStax. Principles of Accounting, Volume 1: Financial Accounting، §6.6. https://openstax.org/books/principles-financial-accounting/pages/6-6-describe-and-prepare-multi-step-and-simple-income-statements-for-merchandising-companies (فُتح في 11 أكتوبر 2026). يدعم: القراءة المقترحة عن طريقة عرض المتجر لمبيعاته وتكاليفه.
- McKinney, W. الموقع الشخصي وصفحة الكتاب. https://wesmckinney.com/ و https://wesmckinney.com/book/ (فُتحا في 11 أكتوبر 2026). يدعم: تأليفه لكتاب Python for Data Analysis، وإتاحته مجانًا على الإنترنت، ووصف الإصدار الثالث.
- D.World Curriculum Map v1.0 (صف L05) وCurriculum Bible v1.0 (معيار دمج الأعمال). وثائق داخلية.
L06 · Revenue, Cost, Profit & MarginL06 · الإيرادات والتكلفة والربح وهامش الربح Freeمجاني
L06 — Revenue, Cost, Profit & Margin
Learner file. Answers and model solutions are in a separate instructor-only file. Version: U02 v1.0 · Content date: 11 October 2026. Time estimates are provisional until learner-tested.
1. Lesson Identity
| Field | Value |
|---|---|
| Title | Revenue, Cost, Profit & Margin |
| Stage | Stage 1 — Foundations |
| Unit | U02 — Business Foundations for Data Professionals |
| Lesson ID | L06 |
| Skills | Financial literacy; quantitative reasoning |
| Difficulty | Beginner |
| Estimated time | About 1 hour 55 minutes (provisional) |
| Prerequisites | L05 (revenue, cost, simple profit). Arithmetic: multiplication, subtraction, division, percentages. A calculator is recommended. |
Time breakdown (provisional): concept and worked example, 35 min · guided practice, 15 min · independent practice, 15 min · knowledge check (calculation and scenario quiz), 15 min · AI in Practice and Verification, 15 min · workplace task, 10 min · mini challenge, 10 min.
2. Learning Objective
By the end of this lesson, you will be able to calculate revenue, cost of goods sold, gross profit, gross margin and net profit from a small table, and explain whether a change in price, volume or cost caused a change in profit.
3. Why It Matters
"Sales went up!" sounds like good news. But a business can sell more and earn less: when it cuts prices too far, when its product costs rise, or when it spends heavily on advertising to win those sales.
Managers make pricing, stocking and spending decisions every week. A data professional who can read the main profit lines, and explain what changed profit, helps them avoid celebrating the wrong number. Key principle: revenue ≠ profit.
4. Concept
The profit "ladder" (simplified for this unit)
| Line | Formula | What it tells you |
|---|---|---|
| Revenue | Price × units sold (after any discounts) | How much money came in from sales |
| Cost of goods sold (COGS) | Unit cost × units sold | What the sold products cost the business to buy or make |
| Gross profit | Revenue − COGS | What is left from sales after paying for the products themselves |
| Gross margin (%) | Gross profit ÷ revenue × 100 | How many cents of every 1 USD of revenue remain after product costs |
| Operating expenses (opex) | Sum of running costs: rent, wages, marketing, software | The cost of running the business, mostly not tied to each unit |
| Net profit (simplified) | Gross profit − operating expenses | What is left after product costs and running costs |
Important simplifications in this unit: - Our fictional stores have no loans and no other income, and we ignore taxes. In real accounts there is usually an intermediate line, operating profit (gross profit − operating expenses). Net profit comes after interest, taxes and other items. Here, operating profit and net profit are the same number. - We ignore returns. Real "net sales" subtract returns and allowances from sales.
Words that are easy to mix up
- Revenue vs profit. Revenue is money in; profit is what remains after costs. They can move in opposite directions.
- Gross profit vs gross margin. Gross profit is an amount (USD); gross margin is a percentage. Terminology varies: some accounting textbooks, including the OpenStax book in Resources, use "gross margin" for the USD amount and call the percentage the "gross profit margin ratio". Always check which one a report means.
- Margin vs markup. Margin divides by revenue; markup divides by cost. A notebook bought for 5 USD and sold for 12 USD has a margin of 7 ÷ 12 ≈ 58.3% but a markup of 7 ÷ 5 = 140%. Mixing them up is a common, costly mistake.
- Fixed vs variable costs. Variable costs rise with each unit sold (product cost, packaging per order). Fixed costs stay the same within a month regardless of sales (rent, most salaries, software subscriptions). Marketing spend is a choice; here it is set monthly, so we treat it as fixed within the month.
Three levers that change profit
- Price: what each unit sells for.
- Volume: how many units are sold.
- Cost: unit cost (affects COGS) and operating expenses.
To explain a profit change, calculate how much each lever contributed. That is the skill in this lesson's Business Lens.
5. Worked Example
Synthetic data. Cedar Lane is fictional. To keep the arithmetic clear, this example treats the store as selling one product line (notebooks).
September: price 12 USD; units sold 1,000; unit cost 5 USD. Operating expenses: rent 1,500 + wages 3,000 + marketing 1,200 + software 300 = 6,000 USD.
- Revenue = 12 × 1,000 = 12,000 USD.
- COGS = 5 × 1,000 = 5,000 USD.
- Gross profit = 12,000 − 5,000 = 7,000 USD.
- Gross margin = 7,000 ÷ 12,000 × 100 = 58.33… ≈ 58.3%.
- Net profit (simplified) = 7,000 − 6,000 = 1,000 USD.
October: the price drops to 11 USD for a promotion; units rise to 1,200; unit cost stays at 5 USD. Marketing rises by 600 to promote the offer, so operating expenses = 6,600 USD.
- Revenue = 11 × 1,200 = 13,200 USD (up 1,200, or +10%).
- COGS = 5 × 1,200 = 6,000 USD.
- Gross profit = 13,200 − 6,000 = 7,200 USD (up 200).
- Gross margin = 7,200 ÷ 13,200 × 100 = 54.54… ≈ 54.5% (down from 58.3%).
- Net profit = 7,200 − 6,600 = 600 USD (down 400, or −40%).
What changed profit? - Volume effect: 200 extra units × (12 − 5) = +1,400 USD of gross profit, if the price had stayed at 12. - Price effect: 1 USD lower price × 1,200 units = −1,200 USD. - Operating expense effect: +600 USD more marketing = −600 USD. - Total change in net profit: +1,400 − 1,200 − 600 = −400 USD ✔ (1,000 → 600).
Interpretation: revenue rose 10%, but net profit fell 40%. The extra volume did not fully pay for the lower price plus the extra marketing. Revenue ≠ profit. Note what we have not shown: whether the promotion brought new customers who will buy again. L07 adds that view.
6. Visual Explanation
REVENUE 13,200
- COGS 6,000
= GROSS PROFIT 7,200 (gross margin 54.5%)
- OPERATING EXP. 6,600
= NET PROFIT 600 (simplified: no interest, no tax)
Alt text: A vertical profit ladder for Cedar Lane in October. Revenue 13,200, minus cost of goods sold 6,000, equals gross profit 7,200 with gross margin 54.5 percent. Minus operating expenses 6,600 equals net profit 600, with a note that this is simplified with no interest and no tax.
7. Guided Practice
Synthetic data: Cedar Lane's pens in one month. Price 3.00 USD, units 2,500, unit cost 1.20 USD.
- Revenue = price × units = ______
- COGS = unit cost × units = ______
- Gross profit = revenue − COGS = ______
- Gross margin = gross profit ÷ revenue × 100 = ______ %
- Next month, the price rises to 3.30 USD and units fall to 2,300; unit cost is unchanged. Recalculate steps 1–4. Did gross profit go up or down? Why, even though fewer pens were sold?
Hint: keep the unit cost the same in step 5. Round percentages to one decimal place.
8. Independent Practice
Synthetic data: in November, Cedar Lane's supplier raises the notebook unit cost from 5 USD to 6 USD. The price is back to 12 USD, units are 1,000, and operating expenses are 6,000 USD.
- Calculate revenue, COGS, gross profit, gross margin and net profit.
- Compare with September (Section 5). Which lever (price, volume or cost) changed profit, and by how much?
- In two sentences, explain to the owner why revenue is unchanged but profit is not.
No model answer is shown here.
9. Knowledge Check — Calculation and Scenario Quiz
Choose the best answer. All figures are synthetic.
Q1. Revenue is 8,000 USD and COGS is 3,000 USD. What is gross profit? - A) 11,000 USD - B) 62.5% - C) 5,000 USD - D) 3,000 USD
Q2. Using Q1's figures, what is the gross margin? - A) 166.7% - B) 62.5% - C) 37.5% - D) 5,000 USD
Q3. Using Q1's figures, operating expenses are 4,000 USD (no interest, no tax). What is net profit? - A) 5,000 USD - B) 4,000 USD - C) −1,000 USD - D) 1,000 USD
Q4. A store's revenue rose 20% this quarter, but net profit fell. Which explanation is possible? - A) Costs (product costs, operating expenses, or both) rose faster than revenue. - B) This is impossible; profit always rises when revenue rises. - C) Gross margin must have increased. - D) Revenue and profit are two names for the same number.
Q5. A product sells 500 units. Its price rises from 20 to 22 USD; units and the unit cost (12 USD) are unchanged. How does gross profit change? - A) +400 USD (10% of the old gross profit) - B) +1,100 USD - C) +1,000 USD - D) No change, because volume did not change
Q6. Which is a fixed cost for Cedar Lane within a month? - A) Packaging for each order - B) Monthly rent for the storeroom - C) Purchase cost of each notebook sold - D) Card-payment fee charged on each order
Q7. Gross profit rose by 500 USD this month, but net profit fell. What is the most likely reason? - A) Operating expenses rose by more than 500 USD. - B) COGS fell. - C) The price increased. - D) Gross margin is the same as net profit.
10. AI in Practice
Give an AI assistant this synthetic table only:
| Line | September | October |
|---|---|---|
| Price (USD) | 12 | 11 |
| Units | 1,000 | 1,200 |
| Revenue | 12,000 | 13,200 |
| COGS | 5,000 | 6,000 |
| Gross profit | 7,000 | 7,200 |
| Operating expenses | 6,000 | 6,600 |
| Net profit | 1,000 | 600 |
Prompt:
"This is a fictional store's simplified monthly profit table (no interest, no tax). Explain in plain English why net profit fell even though revenue rose. Split the change into the effect of price, volume and operating expenses. Show every calculation step."
Why this can help: the AI can produce a clear first explanation and a structure (price / volume / cost) you can reuse.
11. AI Verification
- Recalculate every number the AI gives, by hand or with a calculator. AI tools can make arithmetic mistakes, especially with percentages.
- Check that the effects add up to the total change in net profit (−400 USD). If they do not, find the error.
- Check the vocabulary. Did it call gross margin "profit," or confuse margin with markup? Correct it.
- Check for invented context. Did it claim reasons not in the data ("customers disliked the design")? Label them hypotheses (U01, L02), not facts.
- Privacy: only paste synthetic or fully anonymized tables. Never paste your employer's real financial statements into a public AI tool.
- Note: write 2 lines on what the AI got right, and what you corrected.
12. Business Lens
Determine what changed profit when price, volume or cost changes. In practice:
- Before celebrating a revenue increase, check gross profit and net profit for the same period.
- When profit changes, split the change into price, volume and cost effects, as in Section 5, so the decision-maker knows which lever to act on.
- A promotion is a price decision. Whether it is worth it depends on volume gained, extra costs, and (L07) whether it brings customers who come back.
13. Workplace Task — Profit Change Memo
The owner asks: "October was our best sales month, so why is profit lower?" Using the September and October figures, write a memo of up to 150 words that:
- states revenue, gross profit and net profit for both months;
- explains the change using the price, volume and operating-expense effects (with numbers);
- ends with one question the owner should answer before running the same promotion again.
14. Mini Challenge
Synthetic data, fictional business: Spoke & Chain, a small bicycle-repair shop.
| Month 1 | Month 2 | |
|---|---|---|
| Services done | 300 | 270 |
| Price per service (USD) | 40 | 44 |
| Average parts cost per service (USD) | 15 | 15 |
| Operating expenses (rent, wages, other) (USD) | 6,500 | 6,500 |
- Calculate revenue, COGS (parts), gross profit, gross margin and net profit for both months.
- Which lever changed profit, and in which direction?
- Fewer bikes were repaired in Month 2. Write one business risk the owner should watch, even if profit improved.
Submit before feedback. No solution is provided here.
15. Resources
- Required (about 15 min): OpenStax, Principles of Accounting, Volume 1: Financial Accounting, §6.6. Read how a multi-step income statement subtracts cost of goods sold, then operating expenses. Notice the terminology difference described in Section 4. https://openstax.org/books/principles-financial-accounting/pages/6-6-describe-and-prepare-multi-step-and-simple-income-statements-for-merchandising-companies (Opened 11 Oct 2026. Open textbook, CC BY-NC-SA 4.0. US accounting context.)
- Recommended (about 10 min): AWS CAF Business Perspective — Data monetization. Read the definition, "generate measurable business value from data and insights", and the examples of value that are easier or harder to measure. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-monetization.html (Opened 11 Oct 2026. The page states it is for historical reference only.)
- Deeper (optional): redo Section 5 with a price of 11.50 USD instead of 11 USD (other October numbers unchanged) and see how net profit changes.
16. Person to Follow / Role Model
Practitioner perspective (no named person). The D.World map lists "Business analytics practitioner" for this lesson, a type of role rather than a specific person, so no individual is named here.
Try this: if you know someone who works in finance, analytics, or runs a small business, ask them: "Which profit line do you look at first each month, and why?" Compare their answer with this lesson's profit ladder.
17. Glossary
| Term | Meaning in this lesson |
|---|---|
| Revenue | Price × units sold (after discounts), in a period |
| Cost of goods sold (COGS) | Unit cost × units sold; the cost of the products themselves |
| Gross profit | Revenue − COGS (an amount) |
| Gross margin | Gross profit ÷ revenue × 100 (a percentage). Some texts use the term for the amount instead |
| Operating expenses (opex) | Running costs such as rent, wages, marketing, software |
| Operating profit | Gross profit − operating expenses |
| Net profit (simplified) | Gross profit − operating expenses, with no interest, taxes or other items; equal to operating profit in this unit |
| Markup | (Price − cost) ÷ cost; uses cost as the denominator, unlike margin |
| Fixed cost | A cost that does not change with units sold within a period |
| Variable cost | A cost that rises with each unit or order |
18. Reflection
Before this lesson, if a friend said "my shop's sales doubled," would you have assumed their profit doubled too? What would you ask them now?
19. Next Step
You can now explain profit per period. In L07 — Customers, Funnels & Unit Economics, you will look at profit per customer: how visitors become buyers, what each order is worth, what it costs to win a customer, and whether growth is economically sustainable.
20. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Calculation and scenario quiz (Q1–Q7) | Correct formulas and interpretation | 6 or more of 7 = meets |
| Guided and independent practice | Accurate calculation and a lever explanation | Rubric L06-IP: all lines correct; lever identified and quantified; plain explanation |
| Workplace task (profit change memo) | You can explain a profit change for a decision-maker | Rubric L06-WT: correct figures; effects sum to −400; one decision question |
| Mini challenge (bike shop) | Transfer to a service business | Rubric L06-MC |
References
- OpenStax. Principles of Accounting, Volume 1: Financial Accounting, §6.6 "Describe and Prepare Multi-Step and Simple Income Statements for Merchandising Companies" (Franklin, Graybeal, Cooper; 2019). https://openstax.org/books/principles-financial-accounting/pages/6-6-describe-and-prepare-multi-step-and-simple-income-statements-for-merchandising-companies (opened and checked 11 Oct 2026). Supports: COGS is deducted from net sales to obtain gross margin (the amount); operating expenses are deducted next to obtain income from operations; other items, including interest, then give net income; the terminology note. Licence: CC BY-NC-SA 4.0. Linked, not copied.
- Amazon Web Services. AWS CAF Business Perspective — Data monetization. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-monetization.html (opened and checked 11 Oct 2026). Supports: the definition of data monetization as generating measurable business value; the page's historical-reference notice.
- D.World Curriculum Map v1.0 (L06 row) and Curriculum Bible v1.0. Internal.
L06 — الإيرادات والتكلفة والربح وهامش الربح
ملف المتعلّم. الإجابات والحلول النموذجية في ملف منفصل خاص بالمدرّس فقط. الإصدار: U02 v1.0 · تاريخ المحتوى: 11 أكتوبر 2026. تقديرات الوقت مبدئية إلى أن تُجرَّب مع المتعلّمين.
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | الإيرادات والتكلفة والربح وهامش الربح |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U02 — أساسيات الأعمال لمحترفي البيانات |
| رقم الدرس | L06 |
| المهارات | الثقافة المالية؛ التفكير الكمي |
| المستوى | مبتدئ |
| الوقت المتوقع | حوالي ساعة و55 دقيقة (مبدئي) |
| المتطلبات السابقة | L05 (الإيرادات، التكلفة، الربح المبسط). حساب: الضرب، والطرح، والقسمة، والنسب المئوية. يُنصح باستخدام آلة حاسبة. |
تفصيل الوقت (مبدئي): المفهوم والمثال المحلول 35 دقيقة · التدريب الموجَّه 15 دقيقة · التدريب المستقل 15 دقيقة · اختبار الفهم (حسابات ومواقف) 15 دقيقة · الذكاء الاصطناعي في التطبيق والتحقق 15 دقيقة · مهمة العمل 10 دقائق · التحدي القصير 10 دقائق.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تحسب الإيرادات، وتكلفة البضاعة المباعة، ومجمل الربح، وهامش الربح الإجمالي، وصافي الربح من جدول صغير، وأن تشرح هل كان تغيّر السعر أو الكمية أو التكلفة هو سبب تغيّر الربح.
3. لماذا يهمّك هذا؟
"المبيعات زادت!" تبدو خبرًا جيدًا. لكن النشاط التجاري قد يبيع أكثر ويكسب أقل: عندما يخفض الأسعار أكثر من اللازم، أو عندما ترتفع تكاليف منتجاته، أو عندما ينفق كثيرًا على الإعلانات ليحصل على هذه المبيعات.
المديرون يتخذون قرارات التسعير والمخزون والإنفاق كل أسبوع. ومحترف البيانات الذي يستطيع قراءة بنود الربح الأساسية، ويشرح ما الذي غيّر الربح، يساعدهم على ألا يحتفلوا بالرقم الخطأ. المبدأ الأساسي: الإيرادات ≠ الربح.
4. المفهوم
"سُلّم" الربح (مبسّط لهذه الوحدة)
| البند | المعادلة | ماذا يخبرك |
|---|---|---|
| الإيرادات (Revenue) | السعر × الوحدات المباعة (بعد أي خصومات) | كم من المال دخل من المبيعات |
| تكلفة البضاعة المباعة (COGS) | تكلفة الوحدة × الوحدات المباعة | كم كلّفت المنتجات المباعة النشاطَ لشرائها أو تصنيعها |
| مجمل الربح (Gross profit) | الإيرادات − COGS | ما يتبقى من المبيعات بعد دفع ثمن المنتجات نفسها |
| هامش الربح الإجمالي (Gross margin) (%) | مجمل الربح ÷ الإيرادات × 100 | كم سنتًا يتبقى من كل دولار من الإيرادات بعد تكاليف المنتج |
| مصروفات التشغيل (opex) | مجموع تكاليف التشغيل: الإيجار، والأجور، والتسويق، والبرمجيات | تكلفة تشغيل النشاط، وأغلبها غير مرتبط بكل وحدة |
| صافي الربح (Net profit) (مبسّط) | مجمل الربح − مصروفات التشغيل | ما يتبقى بعد تكاليف المنتج وتكاليف التشغيل |
تبسيطات مهمة في هذه الوحدة:
- متاجرنا الخيالية ليس عليها قروض وليس لها دخل آخر، ونحن نتجاهل الضرائب. في الحسابات الحقيقية يوجد عادةً بند وسيط هو الربح التشغيلي (operating profit) (مجمل الربح − مصروفات التشغيل). ويأتي صافي الربح بعد الفوائد والضرائب والبنود الأخرى. هنا، الربح التشغيلي وصافي الربح رقم واحد.
- نتجاهل المرتجعات. "صافي المبيعات" الحقيقي يطرح المرتجعات والتخفيضات من المبيعات.
كلمات يسهل الخلط بينها
- الإيرادات مقابل الربح. الإيرادات هي المال الداخل؛ والربح هو ما يتبقى بعد التكاليف. ويمكن أن يتحركا في اتجاهين متعاكسين.
- مجمل الربح مقابل هامش الربح الإجمالي. مجمل الربح مبلغ (بالدولار)؛ وهامش الربح الإجمالي نسبة مئوية. المصطلحات تختلف: بعض كتب المحاسبة، ومنها كتاب OpenStax المذكور في المصادر، تستخدم "gross margin" للمبلغ بالدولار، وتسمي النسبة "gross profit margin ratio". تأكد دائمًا أيهما يقصد التقرير.
- هامش الربح مقابل نسبة الإضافة (markup). الهامش يُقسَم على الإيرادات؛ ونسبة الإضافة تُقسَم على التكلفة. دفتر اشتُري بـ 5 دولارات وبيع بـ 12 دولارًا هامشه 7 ÷ 12 ≈ 58.3%، لكن نسبة الإضافة فيه 7 ÷ 5 = 140%. الخلط بينهما خطأ شائع ومكلف.
- التكاليف الثابتة مقابل المتغيرة. التكاليف المتغيرة تزيد مع كل وحدة تُباع (تكلفة المنتج، والتغليف لكل طلب). التكاليف الثابتة تبقى كما هي خلال الشهر مهما كانت المبيعات (الإيجار، وأغلب الرواتب، واشتراكات البرمجيات). الإنفاق على التسويق اختيار؛ وهنا يُحدَّد شهريًا، لذلك نعامله على أنه ثابت خلال الشهر.
ثلاث روافع تغيّر الربح
- السعر: ما تُباع به كل وحدة.
- الكمية: عدد الوحدات المباعة.
- التكلفة: تكلفة الوحدة (تؤثر في COGS) ومصروفات التشغيل.
لكي تشرح تغيّر الربح، احسب مساهمة كل رافعة. وهذه هي المهارة في قسم منظور الأعمال في هذا الدرس.
5. مثال محلول
بيانات مصطنعة. Cedar Lane متجر خيالي. ولكي يبقى الحساب واضحًا، يعامل هذا المثال المتجر كأنه يبيع خط منتجات واحدًا (الدفاتر).
سبتمبر: السعر 12 دولارًا؛ الوحدات المباعة 1,000؛ تكلفة الوحدة 5 دولارات. مصروفات التشغيل: إيجار 1,500 + أجور 3,000 + تسويق 1,200 + برمجيات 300 = 6,000 دولار.
- الإيرادات = 12 × 1,000 = 12,000 دولار.
- COGS = 5 × 1,000 = 5,000 دولار.
- مجمل الربح = 12,000 − 5,000 = 7,000 دولار.
- هامش الربح الإجمالي = 7,000 ÷ 12,000 × 100 = 58.33… ≈ 58.3%.
- صافي الربح (مبسّط) = 7,000 − 6,000 = 1,000 دولار.
أكتوبر: انخفض السعر إلى 11 دولارًا بسبب عرض ترويجي؛ وزادت الوحدات إلى 1,200؛ وبقيت تكلفة الوحدة 5 دولارات. وزاد التسويق بمقدار 600 للترويج للعرض، فأصبحت مصروفات التشغيل = 6,600 دولار.
- الإيرادات = 11 × 1,200 = 13,200 دولار (زيادة 1,200، أي +10%).
- COGS = 5 × 1,200 = 6,000 دولار.
- مجمل الربح = 13,200 − 6,000 = 7,200 دولار (زيادة 200).
- هامش الربح الإجمالي = 7,200 ÷ 13,200 × 100 = 54.54… ≈ 54.5% (انخفاض من 58.3%).
- صافي الربح = 7,200 − 6,600 = 600 دولار (انخفاض 400، أي −40%).
ما الذي غيّر الربح؟
- أثر الكمية: 200 وحدة إضافية × (12 − 5) = +1,400 دولار من مجمل الربح، لو بقي السعر 12.
- أثر السعر: سعر أقل بدولار واحد × 1,200 وحدة = −1,200 دولار.
- أثر مصروفات التشغيل: +600 دولار تسويقًا إضافيًا = −600 دولار.
- إجمالي التغيّر في صافي الربح: +1,400 − 1,200 − 600 = −400 دولار ✔ (من 1,000 إلى 600).
التفسير: الإيرادات زادت 10%، لكن صافي الربح انخفض 40%. الكمية الإضافية لم تغطِّ بالكامل السعر الأقل مع التسويق الإضافي. الإيرادات ≠ الربح. ولاحظ ما لم نُظهره: هل جلب العرض عملاء جددًا سيعودون للشراء؟ هذا ما يضيفه L07.
6. شرح بصري
REVENUE 13,200
- COGS 6,000
= GROSS PROFIT 7,200 (gross margin 54.5%)
- OPERATING EXP. 6,600
= NET PROFIT 600 (simplified: no interest, no tax)
وصف الرسم: سُلّم ربح رأسي لـ Cedar Lane في أكتوبر. الإيرادات 13,200، ناقص تكلفة البضاعة المباعة 6,000، يساوي مجمل الربح 7,200 بهامش ربح إجمالي 54.5%. ناقص مصروفات التشغيل 6,600 يساوي صافي الربح 600، مع ملاحظة أن هذا مبسّط بلا فوائد ولا ضرائب.
7. تدريب موجَّه
بيانات مصطنعة: أقلام Cedar Lane في شهر واحد. السعر 3.00 دولار، والوحدات 2,500، وتكلفة الوحدة 1.20 دولار.
- الإيرادات = السعر × الوحدات = ______
- COGS = تكلفة الوحدة × الوحدات = ______
- مجمل الربح = الإيرادات − COGS = ______
- هامش الربح الإجمالي = مجمل الربح ÷ الإيرادات × 100 = ______ %
- في الشهر التالي، يرتفع السعر إلى 3.30 دولار وتنخفض الوحدات إلى 2,300؛ وتكلفة الوحدة لا تتغير. أعِد حساب الخطوات 1–4. هل زاد مجمل الربح أم نقص؟ ولماذا، رغم بيع أقلام أقل؟
تلميح: أبقِ تكلفة الوحدة كما هي في الخطوة 5. وقرّب النسب المئوية إلى منزلة عشرية واحدة.
8. تدريب مستقل
بيانات مصطنعة: في نوفمبر، يرفع المورد تكلفة الدفتر من 5 دولارات إلى 6 دولارات. وعاد السعر إلى 12 دولارًا، والوحدات 1,000، ومصروفات التشغيل 6,000 دولار.
- احسب الإيرادات، وCOGS، ومجمل الربح، وهامش الربح الإجمالي، وصافي الربح.
- قارن بشهر سبتمبر (القسم 5). أي رافعة (السعر أو الكمية أو التكلفة) غيّرت الربح، وبكم؟
- في جملتين، اشرح لصاحب المتجر لماذا لم تتغير الإيرادات بينما تغيّر الربح.
لا توجد إجابة نموذجية هنا.
9. اختبار الفهم — حسابات ومواقف
اختر أفضل إجابة. كل الأرقام مصطنعة.
Q1. الإيرادات 8,000 دولار وCOGS تساوي 3,000 دولار. كم يساوي مجمل الربح؟ - A) 11,000 دولار - B) 62.5% - C) 5,000 دولار - D) 3,000 دولار
Q2. باستخدام أرقام Q1، كم يساوي هامش الربح الإجمالي؟ - A) 166.7% - B) 62.5% - C) 37.5% - D) 5,000 دولار
Q3. باستخدام أرقام Q1، مصروفات التشغيل 4,000 دولار (بلا فوائد ولا ضرائب). كم يساوي صافي الربح؟ - A) 5,000 دولار - B) 4,000 دولار - C) −1,000 دولار - D) 1,000 دولار
Q4. زادت إيرادات متجر بنسبة 20% في هذا الربع، لكن صافي الربح انخفض. أي تفسير ممكن؟ - A) التكاليف (تكاليف المنتج، أو مصروفات التشغيل، أو كلاهما) زادت أسرع من الإيرادات. - B) هذا مستحيل؛ الربح يزيد دائمًا عندما تزيد الإيرادات. - C) لا بد أن هامش الربح الإجمالي زاد. - D) الإيرادات والربح اسمان لرقم واحد.
Q5. منتج يبيع 500 وحدة. ارتفع سعره من 20 إلى 22 دولارًا؛ والوحدات وتكلفة الوحدة (12 دولارًا) لم تتغير. كيف يتغير مجمل الربح؟ - A) +400 دولار (10% من مجمل الربح القديم) - B) +1,100 دولار - C) +1,000 دولار - D) لا يتغير، لأن الكمية لم تتغير
Q6. أي مما يلي تكلفة ثابتة لـ Cedar Lane خلال الشهر؟ - A) التغليف لكل طلب - B) الإيجار الشهري للمخزن - C) تكلفة شراء كل دفتر مباع - D) رسوم الدفع بالبطاقة على كل طلب
Q7. زاد مجمل الربح بمقدار 500 دولار هذا الشهر، لكن صافي الربح انخفض. ما السبب الأرجح؟ - A) زادت مصروفات التشغيل بأكثر من 500 دولار. - B) انخفضت COGS. - C) زاد السعر. - D) هامش الربح الإجمالي هو نفسه صافي الربح.
10. الذكاء الاصطناعي في التطبيق
أعطِ مساعد ذكاء اصطناعي هذا الجدول المصطنع فقط:
| البند | سبتمبر | أكتوبر |
|---|---|---|
| السعر (بالدولار) | 12 | 11 |
| الوحدات | 1,000 | 1,200 |
| الإيرادات | 12,000 | 13,200 |
| COGS | 5,000 | 6,000 |
| مجمل الربح | 7,000 | 7,200 |
| مصروفات التشغيل | 6,000 | 6,600 |
| صافي الربح | 1,000 | 600 |
الطلب:
"This is a fictional store's simplified monthly profit table (no interest, no tax). Explain in plain English why net profit fell even though revenue rose. Split the change into the effect of price, volume and operating expenses. Show every calculation step."
وبالعربية: "هذا جدول ربح شهري مبسّط لمتجر خيالي (بلا فوائد ولا ضرائب). اشرح بلغة بسيطة لماذا انخفض صافي الربح رغم زيادة الإيرادات. قسّم التغيّر إلى أثر السعر، وأثر الكمية، وأثر مصروفات التشغيل. واعرض كل خطوة من خطوات الحساب."
لماذا قد يفيد هذا: يستطيع الذكاء الاصطناعي أن يعطيك شرحًا أوليًا واضحًا وهيكلًا (السعر / الكمية / التكلفة) يمكنك إعادة استخدامه.
11. التحقق من مخرجات الذكاء الاصطناعي
- أعِد حساب كل رقم يعطيه الذكاء الاصطناعي، يدويًا أو بآلة حاسبة. أدوات الذكاء الاصطناعي قد تخطئ في الحساب، خاصة مع النسب المئوية.
- تأكد أن مجموع الآثار يساوي إجمالي التغيّر في صافي الربح (−400 دولار). إن لم يتساويا، فابحث عن الخطأ.
- راجع المصطلحات. هل سمّى هامش الربح الإجمالي "ربحًا"، أو خلط بين الهامش ونسبة الإضافة؟ صحّح ذلك.
- ابحث عن سياق مخترع. هل ادّعى أسبابًا غير موجودة في البيانات ("العملاء لم يعجبهم التصميم")؟ صنّفها فرضيات (U01، L02)، لا حقائق.
- الخصوصية: الصق فقط جداول مصطنعة أو مجهّلة بالكامل. لا تلصق أبدًا القوائم المالية الحقيقية لجهة عملك في أداة ذكاء اصطناعي عامة.
- ملاحظة: اكتب سطرين عما أصاب فيه الذكاء الاصطناعي، وما الذي صحّحته.
12. منظور الأعمال
حدِّد ما الذي غيّر الربح عندما يتغير السعر أو الكمية أو التكلفة. عمليًا:
- قبل أن تحتفل بزيادة الإيرادات، راجع مجمل الربح وصافي الربح عن الفترة نفسها.
- عندما يتغير الربح، قسّم التغيّر إلى أثر السعر وأثر الكمية وأثر التكلفة، كما في القسم 5، حتى يعرف صاحب القرار أي رافعة يحرّك.
- العرض الترويجي قرار تسعير. وهل يستحق؟ هذا يعتمد على الكمية المكتسبة، والتكاليف الإضافية، و(في L07) هل يجلب عملاء يعودون.
13. مهمة عمل — مذكرة عن تغيّر الربح
يسأل صاحب المتجر: "أكتوبر كان أفضل شهر في المبيعات، فلماذا الربح أقل؟" باستخدام أرقام سبتمبر وأكتوبر، اكتب مذكرة لا تزيد على 150 كلمة:
- تذكر الإيرادات ومجمل الربح وصافي الربح للشهرين؛
- تشرح التغيّر باستخدام أثر السعر وأثر الكمية وأثر مصروفات التشغيل (بالأرقام)؛
- تنتهي بسؤال واحد يجب أن يجيب عنه صاحب المتجر قبل تكرار العرض نفسه.
14. تحدٍّ قصير
بيانات مصطنعة، ونشاط خيالي: Spoke & Chain، ورشة صغيرة لإصلاح الدراجات.
| الشهر 1 | الشهر 2 | |
|---|---|---|
| عدد الخدمات المنفّذة | 300 | 270 |
| سعر الخدمة (بالدولار) | 40 | 44 |
| متوسط تكلفة قطع الغيار لكل خدمة (بالدولار) | 15 | 15 |
| مصروفات التشغيل (إيجار، أجور، أخرى) (بالدولار) | 6,500 | 6,500 |
- احسب الإيرادات، وCOGS (قطع الغيار)، ومجمل الربح، وهامش الربح الإجمالي، وصافي الربح للشهرين.
- أي رافعة غيّرت الربح، وفي أي اتجاه؟
- عدد الدراجات التي أُصلحت في الشهر 2 أقل. اكتب خطرًا واحدًا على العمل يجب أن يراقبه صاحب الورشة، حتى لو تحسّن الربح.
سلّم إجابتك قبل أي ملاحظات. لا يوجد حل هنا.
15. المصادر
- مطلوب (حوالي 15 دقيقة): OpenStax، Principles of Accounting, Volume 1: Financial Accounting، §6.6. اقرأ كيف تطرح قائمة الدخل متعددة المراحل تكلفةَ البضاعة المباعة، ثم مصروفات التشغيل. ولاحظ اختلاف المصطلحات الموضح في القسم 4. https://openstax.org/books/principles-financial-accounting/pages/6-6-describe-and-prepare-multi-step-and-simple-income-statements-for-merchandising-companies (فُتح في 11 أكتوبر 2026. كتاب مفتوح، CC BY-NC-SA 4.0. سياق محاسبي أمريكي.)
- مقترح (حوالي 10 دقائق): AWS CAF Business Perspective — Data monetization. اقرأ التعريف، "generate measurable business value from data and insights" (توليد قيمة عمل قابلة للقياس من البيانات والاستنتاجات)، والأمثلة على القيمة التي يسهل أو يصعب قياسها. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-monetization.html (فُتحت في 11 أكتوبر 2026. الصفحة تذكر أنها للرجوع التاريخي فقط.)
- للتعمّق (اختياري): أعِد حل القسم 5 بسعر 11.50 دولار بدل 11 دولارًا (مع بقاء أرقام أكتوبر الأخرى كما هي)، ولاحظ كيف يتغير صافي الربح.
16. شخصية تتابعها / قدوة
منظور الممارس (دون تسمية شخص). تذكر خريطة D.World عبارة "Business analytics practitioner" (ممارس تحليلات الأعمال) لهذا الدرس، وهي نوع من الأدوار وليست شخصًا محددًا، لذلك لا نسمّي هنا أي فرد.
جرّب هذا: إن كنت تعرف شخصًا يعمل في المالية أو التحليلات أو يدير نشاطًا صغيرًا، فاسأله: "أي بند من بنود الربح تنظر إليه أولًا كل شهر، ولماذا؟" وقارن إجابته بسُلّم الربح في هذا الدرس.
17. المصطلحات
| المصطلح | معناه في هذا الدرس |
|---|---|
| الإيرادات (Revenue) | السعر × الوحدات المباعة (بعد الخصومات)، خلال فترة معيّنة |
| تكلفة البضاعة المباعة (COGS) | تكلفة الوحدة × الوحدات المباعة؛ أي تكلفة المنتجات نفسها |
| مجمل الربح (Gross profit) | الإيرادات − COGS (مبلغ) |
| هامش الربح الإجمالي (Gross margin) | مجمل الربح ÷ الإيرادات × 100 (نسبة مئوية). بعض الكتب تستخدم المصطلح للمبلغ بدلًا من النسبة |
| مصروفات التشغيل (opex) | تكاليف التشغيل مثل الإيجار، والأجور، والتسويق، والبرمجيات |
| الربح التشغيلي (Operating profit) | مجمل الربح − مصروفات التشغيل |
| صافي الربح (Net profit) (مبسّط) | مجمل الربح − مصروفات التشغيل، بلا فوائد ولا ضرائب ولا بنود أخرى؛ ويساوي الربح التشغيلي في هذه الوحدة |
| نسبة الإضافة (Markup) | (السعر − التكلفة) ÷ التكلفة؛ تستخدم التكلفة في المقام، على عكس الهامش |
| التكلفة الثابتة (Fixed cost) | تكلفة لا تتغير مع عدد الوحدات المباعة خلال الفترة |
| التكلفة المتغيرة (Variable cost) | تكلفة تزيد مع كل وحدة أو طلب |
18. تأمّل
قبل هذا الدرس، لو قال لك صديق "مبيعات متجري تضاعفت"، هل كنت ستفترض أن ربحه تضاعف أيضًا؟ ماذا ستسأله الآن؟
19. الخطوة التالية
أصبحت تستطيع شرح الربح لكل فترة. في L07 — العملاء ومسارات التحويل واقتصاديات الوحدة، ستنظر إلى الربح لكل عميل: كيف يتحول الزوار إلى مشترين، وكم يساوي كل طلب، وكم يكلّف كسب عميل، وهل النمو مستدام اقتصاديًا.
20. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| اختبار الحسابات والمواقف (Q1–Q7) | معادلات صحيحة وتفسير صحيح | 6 أو أكثر من 7 = يحقق المطلوب |
| التدريب الموجَّه والمستقل | حساب دقيق وشرح للرافعة | معايير L06-IP: كل البنود صحيحة؛ تحديد الرافعة وقياس أثرها؛ شرح بسيط |
| مهمة العمل (مذكرة تغيّر الربح) | أنك تستطيع شرح تغيّر الربح لصاحب القرار | معايير L06-WT: أرقام صحيحة؛ مجموع الآثار يساوي −400؛ سؤال واحد للقرار |
| التحدي القصير (ورشة الدراجات) | نقل المهارة إلى نشاط خدمي | معايير L06-MC |
المراجع
- OpenStax. Principles of Accounting, Volume 1: Financial Accounting، §6.6 "Describe and Prepare Multi-Step and Simple Income Statements for Merchandising Companies" (Franklin, Graybeal, Cooper؛ 2019). https://openstax.org/books/principles-financial-accounting/pages/6-6-describe-and-prepare-multi-step-and-simple-income-statements-for-merchandising-companies (فُتح وروجع في 11 أكتوبر 2026). يدعم: طرح COGS من صافي المبيعات للحصول على gross margin (المبلغ)؛ ثم طرح مصروفات التشغيل للحصول على الدخل من العمليات؛ ثم البنود الأخرى، ومنها الفوائد، للوصول إلى صافي الدخل؛ وملاحظة المصطلحات. الترخيص: CC BY-NC-SA 4.0. مرتبط بالرابط، وليس منسوخًا.
- Amazon Web Services. AWS CAF Business Perspective — Data monetization. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-monetization.html (فُتحت وروجعت في 11 أكتوبر 2026). يدعم: تعريف تحقيق الدخل من البيانات (data monetization) بأنه توليد قيمة عمل قابلة للقياس؛ وملاحظة الصفحة بأنها للرجوع التاريخي.
- D.World Curriculum Map v1.0 (صف L06) وCurriculum Bible v1.0. وثائق داخلية.
L07 · Customers, Funnels & Unit EconomicsL07 · العملاء ومسارات التحويل واقتصاديات الوحدة Freeمجاني
L07 — Customers, Funnels & Unit Economics
Learner file. Answers and model solutions are in a separate instructor-only file. Version: U02 v1.0 · Content date: 11 October 2026. Time estimates are provisional until learner-tested.
1. Lesson Identity
| Field | Value |
|---|---|
| Title | Customers, Funnels & Unit Economics |
| Stage | Stage 1 — Foundations |
| Unit | U02 — Business Foundations for Data Professionals |
| Lesson ID | L07 |
| Skills | Customer analytics; KPI literacy |
| Difficulty | Beginner |
| Estimated time | About 2 hours 5 minutes (provisional) |
| Prerequisites | L06 (revenue, gross profit, gross margin). Percentages and division. A calculator is recommended. |
Time breakdown (provisional): concept and worked example, 40 min · guided practice, 15 min · independent practice, 15 min · knowledge check (numerical case and decision), 15 min · AI in Practice and Verification, 15 min · workplace task, 15 min · mini challenge, 10 min.
2. Learning Objective
By the end of this lesson, you will be able to explain the stages of a purchase funnel and calculate conversion rate, average order value (AOV), customer acquisition cost (CAC) and a simple, assumption-based lifetime value (LTV). You will use these to judge whether acquiring more customers creates value.
3. Why It Matters
Businesses spend money to attract customers. If winning a customer costs more than that customer will ever be worth, growth makes the business poorer, even while revenue and customer numbers rise.
Unit economics ("the economics of one unit," here one customer or one order) lets you see this early. Key principle: growth must be economically sustainable.
4. Concept
The purchase funnel
A funnel shows how many people move through each step towards a purchase. Fewer people reach each step, so the shape narrows like a funnel. For an online store:
Sessions (visits) → product views → add to cart → checkout started → orders
Conversion rate = number of people (or sessions) reaching a step ÷ number at the earlier step × 100, in the same period. Always state: - which two steps you mean (e.g., cart → order, or session → order); - the denominator: sessions or unique visitors? A person who visits three times creates three sessions but is one visitor. The rate changes depending on which you use.
Overall conversion for a store is usually orders ÷ sessions for the period (this lesson's definition). Some businesses use unique visitors instead.
Unit-economics measures (D.World definitions for this unit)
| Measure | Formula used here | What to state |
|---|---|---|
| Average order value (AOV) | Revenue ÷ number of orders, same period | Whether revenue is after discounts (yes, here), whether shipping fees are included (not here), and which orders count |
| Customer acquisition cost (CAC) | Acquisition spend aimed at new customers in a period ÷ new customers acquired in that period | Which costs are included (here: advertising and new-customer promotions only; some businesses add sales staff or tools) and how "new customer" is defined |
| Lifetime value (LTV), simple gross-profit version | AOV × gross margin × expected number of orders per customer over a chosen time horizon | The horizon (e.g., 2 years) and the assumed repeat orders. LTV is an estimate, not a fact |
| Value per new customer | LTV − CAC | Positive means each new customer is expected to add gross profit after acquisition cost, on these assumptions |
Important cautions: - Formulas vary by business. Subscription companies, marketplaces and stores may define these differently. Always write down your definition. - Use gross profit, not revenue, in LTV when comparing with CAC. Revenue-based LTV ignores product costs and overstates what a customer is worth. - Do not trust "rule-of-thumb" ratios (such as a single "healthy" LTV-to-CAC number) without a source, context, geography and date. This unit does not use any such benchmark.
Revenue growth vs profit growth vs sustainable growth
- Revenue growth: more money in.
- Profit growth: more money left after costs (L06).
- Sustainable growth: growth where each new customer is expected to be worth more than it cost to win, so the business can keep growing without losing money on each new customer.
5. Worked Example
Synthetic data. Cedar Lane is fictional. All figures are for October.
| Funnel step | Count |
|---|---|
| Sessions | 20,000 |
| Product views | 8,000 |
| Add to cart | 1,600 |
| Checkout started | 900 |
| Orders | 600 |
Other October figures: revenue 15,000 USD (after discounts, excluding shipping fees); store-wide gross margin 50%; new customers 240 (the other orders came from returning customers); advertising and new-customer promotions 4,800 USD.
Step conversions: - Sessions → product views = 8,000 ÷ 20,000 = 40% - Product views → cart = 1,600 ÷ 8,000 = 20% - Cart → checkout = 900 ÷ 1,600 = 56.25% - Checkout → order = 600 ÷ 900 = 66.7%
Overall conversion = 600 ÷ 20,000 = 3.0%
AOV = 15,000 ÷ 600 = 25.00 USD
CAC = 4,800 ÷ 240 = 20.00 USD
LTV (simple), assuming a new customer places 3 orders over 2 years at the current AOV and margin: - Gross profit per order = 25.00 × 50% = 12.50 USD - LTV = 12.50 × 3 = 37.50 USD
Value per new customer = 37.50 − 20.00 = +17.50 USD, on these assumptions.
Is "acquiring 100 more customers" good? It depends on what they cost: - At the current CAC of 20 USD: 100 × (37.50 − 20.00) = +1,750 USD expected gross profit after acquisition cost. - Through a new, more expensive channel at CAC 45 USD: 100 × (37.50 − 45.00) = −750 USD. Expected revenue would still be 100 × 25 × 3 = 7,500 USD. Higher sales, lower value.
What we do not know: whether customers from the new channel would really order 3 times. That is an assumption to test.
6. Visual Explanation
Sessions 20,000 ████████████████████
Product views 8,000 ████████ 40% of sessions
Add to cart 1,600 ██ 20% of product views
Checkout 900 █ 56.25% of carts
Orders 600 █ 66.7% of checkouts (overall 3.0%)
One new customer: LTV 37.50 vs CAC 20.00 --> +17.50 (on assumptions)
Alt text: A horizontal bar funnel for Cedar Lane in October. Sessions 20,000 (longest bar); product views 8,000 (40 percent of sessions); add to cart 1,600 (20 percent of product views); checkout 900 (56.25 percent of carts); orders 600 (66.7 percent of checkouts), with overall conversion of 3.0 percent. Below: one new customer has an estimated lifetime value of 37.50 USD against an acquisition cost of 20.00 USD, giving plus 17.50 USD on stated assumptions.
7. Guided Practice
Synthetic data: Cedar Lane, November. Sessions 25,000 · product views 9,000 · add to cart 1,800 · checkout 1,000 · orders 750. Revenue 18,000 USD · gross margin 50% · new customers 300 · acquisition spend 6,000 USD. Assume 3 orders per customer over 2 years.
- Calculate the four step conversions and the overall conversion. (Hint: each step ÷ the step before it; overall = orders ÷ sessions.)
- Calculate AOV. (Hint: revenue ÷ orders, not ÷ customers.)
- Calculate CAC. (Hint: only new customers.)
- Calculate LTV and value per new customer.
- Compare with October: which funnel step changed the most?
8. Independent Practice
Synthetic data, fictional business: Greenleaf Plants sells houseplants online. Last month: sessions 12,000 · orders 300 · revenue 13,500 USD · gross margin 40% · new customers 200 · acquisition spend 7,000 USD. The team assumes 1.5 orders per customer over 2 years.
- Calculate overall conversion, AOV, CAC and LTV (simple gross-profit version).
- Is each new customer expected to create or destroy value, on these assumptions? By how much?
- Name two assumptions you would check before deciding to spend more on acquisition.
No model answer is shown here.
9. Knowledge Check — Numerical Case and Decision
Synthetic case, fictional business: Brightwick Candles, one month. Sessions 10,000 · add to cart 800 · orders 400 · revenue 12,000 USD · gross margin 60% · new customers 160 · acquisition spend 4,000 USD. Assume 2 orders per customer over 2 years.
Part A — Calculate (show working): - A1. Overall conversion (orders ÷ sessions) - A2. Cart-to-order conversion - A3. AOV - A4. CAC - A5. LTV (simple gross-profit version)
Part B — Choose the best answer.
B1. A colleague calculates AOV as 12,000 ÷ 160 = 75 USD. What is wrong? - A) Nothing; that is the correct AOV. - B) They divided by new customers instead of all orders in the period. - C) AOV should be divided by sessions. - D) AOV should use profit instead of revenue.
B2. A new advertising channel offers 100 new customers for a total of 4,500 USD. Assuming the same AOV, margin and repeat orders, should Brightwick go ahead at full scale? - A) Yes, because expected revenue rises by 6,000 USD. - B) Yes, because the store's conversion rate is 4%. - C) Not on these assumptions: each customer's expected gross profit is below its acquisition cost, about −900 USD in total. A small test or a lower cost would be wiser. - D) It is impossible to calculate anything from these figures.
B3. Why does this lesson use gross profit rather than revenue when calculating LTV? - A) Because gross profit is always larger than revenue. - B) Because revenue cannot be measured. - C) Because it makes LTV look higher. - D) Because revenue-based LTV ignores product costs and overstates what a customer is worth.
B4. Overall conversion rose from 4% to 5%, but the number of orders fell. How is this possible? - A) The number of sessions (the denominator) fell by more than enough to offset the higher rate. - B) It is impossible; a higher conversion always means more orders. - C) AOV fell. - D) CAC rose.
10. AI in Practice
Prompt an AI assistant (synthetic numbers only):
"Explain the difference between CAC and LTV for a fictional online store using simple numbers. Then create a realistic example where the store's revenue grows each month but it loses more money with every new customer. Show all calculations and list every assumption you make."
Why this can help: AI can quickly produce a worked example to compare with this lesson. Asking for a "higher sales, losing money" case tests whether it understands that growth must be economically sustainable.
11. AI Verification
- Recalculate every number. Check conversion denominators, AOV (÷ orders), CAC (÷ new customers) and LTV (uses gross margin, not revenue alone).
- List its assumptions and compare with yours. Did it hide an assumption, such as repeat orders or the time horizon?
- Check the "losing money" logic: is the loss caused by CAC being higher than gross profit per customer? Or did the AI confuse revenue with profit?
- Reject unsourced benchmarks. If it says "a good LTV-to-CAC ratio is X," treat it as an unverified claim. Do not repeat it without a source, context and date.
- Privacy: never paste real customer lists, emails or company marketing data into public AI tools. Use synthetic numbers.
12. Business Lens
Evaluate whether acquiring 100 more customers creates value. The answer is never just "more customers = good." Ask: - What will it cost to acquire them (CAC for that channel)? - What gross profit will they likely bring over a stated horizon (LTV, with assumptions)? - How sure are we about repeat orders? Can we run a small test first?
This connects directly to U01: the decision ("spend on this channel?") comes first, then the evidence.
13. Workplace Task — Business Case Worksheet
Cedar Lane is offered an influencer campaign: 2,000 USD for an estimated 100 new customers. Use October's AOV (25 USD) and gross margin (50%).
Complete a worksheet with: 1. CAC for this campaign; 2. LTV and value per new customer, assuming 3 orders over 2 years; 3. the same calculation assuming only 1 order per customer (a sensitivity check); 4. a recommendation (go / small test / no-go) in 2–3 sentences, stating which assumption matters most; 5. one metric you would track after launch to check the assumption.
14. Mini Challenge
Synthetic data, fictional business: FreshBox Meals delivers meal kits. It gives new customers 50% off their first box. A box normally sells for 60 USD with a 35% gross margin on the full price. The first discounted box sells for 30 USD and loses 9 USD in gross profit. Acquisition spend is 40 USD per new customer, and the team assumes a new customer buys 4 more full-price boxes after the first.
- Calculate the expected gross profit per new customer over these 5 boxes, and value per new customer after CAC.
- If customers actually buy only 2 more full-price boxes, what happens?
- Write one sentence on why "number of new sign-ups" alone would be a misleading success measure here.
Submit before feedback. No solution is provided here.
15. Resources
- Required (about 10 min): AWS CAF Business Perspective — Data monetization. Read the description of value that is "captured" (e.g., customer retention, cross-sell and upsell), and note why some value is hard to measure. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-monetization.html (Opened 11 Oct 2026; historical-reference whitepaper.)
- Recommended: your own L06 notes. LTV here depends on gross margin, so revisit the profit ladder.
- Deeper (optional): rebuild the Section 5 example with a 2-year horizon of 2 orders instead of 3, and note how the decision changes. (No external resource is assigned here. The map's resource focus, "business case worksheet / unit economics," is an activity, not a specific publication.)
16. Person to Follow / Role Model
Practitioner perspective (no named person). The D.World map lists "Product analytics practitioner," a type of role rather than a specific person.
Try this: read two job descriptions for product-analytics or growth-analytics roles in your region. Note how often funnels, conversion or retention appear, and record the date and location of each advertisement. Treat what you find as examples, not universal rules.
17. Glossary
| Term | Meaning in this lesson |
|---|---|
| Funnel | The sequence of steps from first visit to purchase |
| Session | One visit to the website; one person can create several |
| Conversion rate | People or sessions reaching a later step ÷ those at an earlier step, same period |
| Average order value (AOV) | Revenue ÷ number of orders, same period |
| Customer acquisition cost (CAC) | Acquisition spend aimed at new customers ÷ new customers acquired, same period |
| Lifetime value (LTV, simple) | AOV × gross margin × assumed orders per customer over a stated horizon |
| Value per new customer | LTV − CAC |
| Unit economics | Revenue, costs and profit measured per unit (per customer or per order) |
| Sensitivity check | Recalculating with a different assumption to see whether the decision changes |
| Sustainable growth | Growth in which each new customer is expected to be worth more than it costs to acquire |
18. Reflection
Think of a "free trial" or a "first-order discount" you have used. Did you buy again? What does your own behaviour suggest about the assumptions a company makes when it estimates LTV?
19. Next Step
You can now calculate many numbers: revenue, margin, conversion, AOV, CAC and LTV. But which ones should a team watch? In L08 — KPIs, Metrics & the Business Question, you will learn to choose a small set of metrics tied to a goal and a decision. You will also learn to turn a vague worry like "sales are down" into precise questions.
20. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Numerical case Part A (A1–A5) | Correct formulas, denominators and arithmetic | 4 or more of 5 correct, with working shown |
| Decision questions Part B (B1–B4) | Interpretation and decision-making | 3 or more of 4 correct; B2 must be correct |
| Workplace task (business case worksheet) | Evaluating "100 more customers" with sensitivity | Rubric L07-WT |
| Independent practice and mini challenge | Transfer | Rubrics L07-IP and L07-MC |
References
- Amazon Web Services. AWS CAF Business Perspective — Data monetization. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-monetization.html (opened and checked 11 Oct 2026). Supports: captured value includes customer retention, personalization and cross-sell/upsell; many benefits are hard to quantify; historical-reference notice.
- Formulas for conversion, AOV, CAC and simple LTV are D.World's teaching definitions, stated with their scope and assumptions. They are not taken from a single external standard, because definitions vary across businesses (see the source log).
- D.World Curriculum Map v1.0 (L07 row) and Curriculum Bible v1.0. Internal.
L07 — العملاء ومسارات التحويل واقتصاديات الوحدة
ملف المتعلّم. الإجابات والحلول النموذجية في ملف منفصل خاص بالمدرّس فقط. الإصدار: U02 v1.0 · تاريخ المحتوى: 11 أكتوبر 2026. تقديرات الوقت مبدئية إلى أن تُجرَّب مع المتعلّمين.
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | العملاء ومسارات التحويل واقتصاديات الوحدة |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U02 — أساسيات الأعمال لمحترفي البيانات |
| رقم الدرس | L07 |
| المهارات | تحليلات العملاء؛ فهم مؤشرات الأداء الرئيسية (KPI) |
| المستوى | مبتدئ |
| الوقت المتوقع | حوالي ساعتين و5 دقائق (مبدئي) |
| المتطلبات السابقة | L06 (الإيرادات، مجمل الربح، هامش الربح الإجمالي). النسب المئوية والقسمة. يُنصح باستخدام آلة حاسبة. |
تفصيل الوقت (مبدئي): المفهوم والمثال المحلول 40 دقيقة · التدريب الموجَّه 15 دقيقة · التدريب المستقل 15 دقيقة · اختبار الفهم (حالة رقمية وقرار) 15 دقيقة · الذكاء الاصطناعي في التطبيق والتحقق 15 دقيقة · مهمة العمل 15 دقيقة · التحدي القصير 10 دقائق.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تشرح مراحل مسار الشراء، وأن تحسب معدل التحويل، ومتوسط قيمة الطلب (AOV)، وتكلفة اكتساب العميل (CAC)، وقيمة العميل على المدى الطويل (LTV) بصيغة بسيطة قائمة على افتراضات. وستستخدم هذه المقاييس لكي تحكم هل اكتساب عملاء أكثر يخلق قيمة.
3. لماذا يهمّك هذا؟
الأنشطة التجارية تنفق المال لجذب العملاء. فإذا كان كسب العميل يكلّف أكثر مما سيساويه هذا العميل في أي وقت، فإن النمو يجعل النشاط أفقر، حتى وإن كانت الإيرادات وأعداد العملاء ترتفع.
اقتصاديات الوحدة (unit economics)، أي "اقتصاديات وحدة واحدة"، وهي هنا عميل واحد أو طلب واحد، تتيح لك أن ترى ذلك مبكرًا. المبدأ الأساسي: النمو يجب أن يكون مستدامًا اقتصاديًا.
4. المفهوم
مسار الشراء
مسار التحويل (funnel) يوضح عدد الأشخاص الذين يمرّون بكل خطوة في الطريق إلى الشراء. وكلما تقدمت الخطوات قلّ عدد من يصلون إليها، فيضيق الشكل مثل القمع. في متجر إلكتروني:
الجلسات (الزيارات) ← مشاهدات المنتجات ← الإضافة إلى السلة ← بدء الدفع ← الطلبات
معدل التحويل (conversion rate) = عدد الأشخاص (أو الجلسات) الذين وصلوا إلى خطوة ÷ العدد في الخطوة السابقة × 100، عن الفترة نفسها. واذكر دائمًا:
- أي خطوتين تقصد (مثلًا من السلة إلى الطلب، أو من الجلسة إلى الطلب)؛
- المقام: الجلسات أم الزوار الفريدون؟ الشخص الذي يزور الموقع ثلاث مرات ينشئ ثلاث جلسات لكنه زائر واحد. والمعدل يتغير حسب ما تستخدمه.
التحويل الإجمالي في متجر يكون عادةً الطلبات ÷ الجلسات عن الفترة (وهذا تعريف هذا الدرس). وبعض الأنشطة تستخدم الزوار الفريدين بدلًا من ذلك.
مقاييس اقتصاديات الوحدة (تعريفات D.World لهذه الوحدة)
| المقياس | المعادلة المستخدمة هنا | ما الذي يجب أن تذكره |
|---|---|---|
| متوسط قيمة الطلب (AOV) | الإيرادات ÷ عدد الطلبات، عن الفترة نفسها | هل الإيرادات بعد الخصومات (نعم، هنا)، وهل رسوم الشحن داخلة (ليست داخلة هنا)، وأي الطلبات تُحسب |
| تكلفة اكتساب العميل (CAC) | الإنفاق الموجّه لاكتساب عملاء جدد في فترة ÷ عدد العملاء الجدد المكتسبين في الفترة نفسها | أي التكاليف داخلة (هنا: الإعلانات وعروض العملاء الجدد فقط؛ بعض الأنشطة تضيف فريق المبيعات أو الأدوات)، وكيف يُعرَّف "العميل الجديد" |
| قيمة العميل على المدى الطويل (LTV)، بصيغة بسيطة مبنية على مجمل الربح | AOV × هامش الربح الإجمالي × عدد الطلبات المتوقع لكل عميل خلال أفق زمني مختار | الأفق الزمني (مثلًا سنتان) والطلبات المتكررة المفترضة. LTV تقدير، وليس حقيقة |
| القيمة لكل عميل جديد | LTV − CAC | القيمة الموجبة تعني أن كل عميل جديد يُتوقع أن يضيف مجمل ربح بعد تكلفة اكتسابه، وفق هذه الافتراضات |
تنبيهات مهمة:
- المعادلات تختلف من نشاط لآخر. شركات الاشتراكات، والمنصات الوسيطة (marketplaces)، والمتاجر قد تعرّف هذه المقاييس بطرق مختلفة. اكتب تعريفك دائمًا.
- استخدم مجمل الربح، لا الإيرادات، في حساب LTV عند مقارنته بـ CAC. فـ LTV المبني على الإيرادات يتجاهل تكاليف المنتج ويبالغ في قيمة العميل.
- لا تثق في النسب "المتعارف عليها" (مثل رقم واحد "صحي" لنسبة LTV إلى CAC) دون مصدر وسياق ونطاق جغرافي وتاريخ. هذه الوحدة لا تستخدم أي معيار مقارنة من هذا النوع.
نمو الإيرادات مقابل نمو الربح مقابل النمو المستدام
- نمو الإيرادات: مال أكثر يدخل.
- نمو الربح: مال أكثر يتبقى بعد التكاليف (L06).
- النمو المستدام: نمو يُتوقع فيه أن يساوي كل عميل جديد أكثر مما كلّف كسبه، فيستطيع النشاط أن يستمر في النمو دون أن يخسر مالًا مع كل عميل جديد.
5. مثال محلول
بيانات مصطنعة. Cedar Lane متجر خيالي. كل الأرقام عن شهر أكتوبر.
| خطوة المسار | العدد |
|---|---|
| الجلسات | 20,000 |
| مشاهدات المنتجات | 8,000 |
| الإضافة إلى السلة | 1,600 |
| بدء الدفع | 900 |
| الطلبات | 600 |
أرقام أخرى لشهر أكتوبر: الإيرادات 15,000 دولار (بعد الخصومات، ودون رسوم الشحن)؛ هامش الربح الإجمالي للمتجر كله 50%؛ العملاء الجدد 240 (وبقية الطلبات جاءت من عملاء عائدين)؛ الإعلانات وعروض العملاء الجدد 4,800 دولار.
التحويل بين الخطوات:
- الجلسات ← مشاهدات المنتجات = 8,000 ÷ 20,000 = 40%
- مشاهدات المنتجات ← السلة = 1,600 ÷ 8,000 = 20%
- السلة ← بدء الدفع = 900 ÷ 1,600 = 56.25%
- بدء الدفع ← الطلب = 600 ÷ 900 = 66.7%
التحويل الإجمالي = 600 ÷ 20,000 = 3.0%
AOV = 15,000 ÷ 600 = 25.00 دولار
CAC = 4,800 ÷ 240 = 20.00 دولار
LTV (بصيغة بسيطة)، بافتراض أن العميل الجديد يطلب 3 طلبات خلال سنتين بمتوسط قيمة الطلب والهامش الحاليين:
- مجمل الربح لكل طلب = 25.00 × 50% = 12.50 دولار
- LTV = 12.50 × 3 = 37.50 دولار
القيمة لكل عميل جديد = 37.50 − 20.00 = +17.50 دولار، وفق هذه الافتراضات.
هل "اكتساب 100 عميل إضافي" أمر جيد؟ هذا يعتمد على تكلفتهم:
- بتكلفة الاكتساب الحالية 20 دولارًا: 100 × (37.50 − 20.00) = +1,750 دولار مجمل ربح متوقع بعد تكلفة الاكتساب.
- عبر قناة جديدة أغلى بتكلفة اكتساب 45 دولارًا: 100 × (37.50 − 45.00) = −750 دولار. ومع ذلك ستظل الإيرادات المتوقعة 100 × 25 × 3 = 7,500 دولار. مبيعات أعلى، وقيمة أقل.
ما لا نعرفه: هل سيطلب العملاء القادمون من القناة الجديدة 3 مرات فعلًا؟ هذا افتراض يجب اختباره.
6. شرح بصري
Sessions 20,000 ████████████████████
Product views 8,000 ████████ 40% of sessions
Add to cart 1,600 ██ 20% of product views
Checkout 900 █ 56.25% of carts
Orders 600 █ 66.7% of checkouts (overall 3.0%)
One new customer: LTV 37.50 vs CAC 20.00 --> +17.50 (on assumptions)
وصف الرسم: مسار تحويل بأشرطة أفقية لـ Cedar Lane في أكتوبر. الجلسات 20,000 (أطول شريط)؛ مشاهدات المنتجات 8,000 (40% من الجلسات)؛ الإضافة إلى السلة 1,600 (20% من مشاهدات المنتجات)؛ بدء الدفع 900 (56.25% من السلال)؛ الطلبات 600 (66.7% ممن بدؤوا الدفع)، والتحويل الإجمالي 3.0%. وفي الأسفل: عميل جديد واحد قيمته المقدّرة على المدى الطويل 37.50 دولار مقابل تكلفة اكتساب 20.00 دولار، فتكون النتيجة +17.50 دولار وفق الافتراضات المذكورة.
7. تدريب موجَّه
بيانات مصطنعة: Cedar Lane، شهر نوفمبر. الجلسات 25,000 · مشاهدات المنتجات 9,000 · الإضافة إلى السلة 1,800 · بدء الدفع 1,000 · الطلبات 750. الإيرادات 18,000 دولار · هامش الربح الإجمالي 50% · العملاء الجدد 300 · إنفاق الاكتساب 6,000 دولار. افترض 3 طلبات لكل عميل خلال سنتين.
- احسب معدلات التحويل الأربعة بين الخطوات والتحويل الإجمالي. (تلميح: كل خطوة ÷ الخطوة التي قبلها؛ والإجمالي = الطلبات ÷ الجلسات.)
- احسب AOV. (تلميح: الإيرادات ÷ الطلبات، وليس ÷ العملاء.)
- احسب CAC. (تلميح: العملاء الجدد فقط.)
- احسب LTV والقيمة لكل عميل جديد.
- قارن بأكتوبر: أي خطوة في المسار تغيّرت أكثر من غيرها؟
8. تدريب مستقل
بيانات مصطنعة، ونشاط خيالي: Greenleaf Plants تبيع نباتات منزلية على الإنترنت. في الشهر الماضي: الجلسات 12,000 · الطلبات 300 · الإيرادات 13,500 دولار · هامش الربح الإجمالي 40% · العملاء الجدد 200 · إنفاق الاكتساب 7,000 دولار. ويفترض الفريق 1.5 طلب لكل عميل خلال سنتين.
- احسب التحويل الإجمالي، وAOV، وCAC، وLTV (بالصيغة البسيطة المبنية على مجمل الربح).
- هل يُتوقع أن يخلق كل عميل جديد قيمة أم يهدرها، وفق هذه الافتراضات؟ وبكم؟
- سمِّ افتراضين ستتحقق منهما قبل أن تقرر إنفاق المزيد على الاكتساب.
لا توجد إجابة نموذجية هنا.
9. اختبار الفهم — حالة رقمية وقرار
حالة مصطنعة، ونشاط خيالي: Brightwick Candles، شهر واحد. الجلسات 10,000 · الإضافة إلى السلة 800 · الطلبات 400 · الإيرادات 12,000 دولار · هامش الربح الإجمالي 60% · العملاء الجدد 160 · إنفاق الاكتساب 4,000 دولار. افترض طلبين لكل عميل خلال سنتين.
الجزء A — احسب (مع عرض خطوات الحل):
- A1. التحويل الإجمالي (الطلبات ÷ الجلسات)
- A2. التحويل من السلة إلى الطلب
- A3. AOV
- A4. CAC
- A5. LTV (بالصيغة البسيطة المبنية على مجمل الربح)
الجزء B — اختر أفضل إجابة.
B1. زميل حسب AOV هكذا: 12,000 ÷ 160 = 75 دولارًا. ما الخطأ؟ - A) لا يوجد خطأ؛ هذا هو AOV الصحيح. - B) قسم على العملاء الجدد بدلًا من كل الطلبات في الفترة. - C) يجب قسمة AOV على الجلسات. - D) يجب أن يستخدم AOV الربح بدلًا من الإيرادات.
B2. قناة إعلانية جديدة تعرض 100 عميل جديد مقابل 4,500 دولار إجمالًا. بافتراض AOV والهامش والطلبات المتكررة نفسها، هل يجب أن تنفّذ Brightwick ذلك على نطاق كامل؟ - A) نعم، لأن الإيرادات المتوقعة تزيد بمقدار 6,000 دولار. - B) نعم، لأن معدل التحويل في المتجر 4%. - C) ليس وفق هذه الافتراضات: مجمل الربح المتوقع لكل عميل أقل من تكلفة اكتسابه، بنحو −900 دولار إجمالًا. الأحكم اختبار صغير أو تكلفة أقل. - D) من المستحيل حساب أي شيء من هذه الأرقام.
B3. لماذا يستخدم هذا الدرس مجمل الربح بدلًا من الإيرادات عند حساب LTV؟ - A) لأن مجمل الربح دائمًا أكبر من الإيرادات. - B) لأن الإيرادات لا يمكن قياسها. - C) لأن ذلك يجعل LTV يبدو أعلى. - D) لأن LTV المبني على الإيرادات يتجاهل تكاليف المنتج ويبالغ في قيمة العميل.
B4. ارتفع التحويل الإجمالي من 4% إلى 5%، لكن عدد الطلبات انخفض. كيف يمكن هذا؟ - A) عدد الجلسات (المقام) انخفض بما يكفي وزيادة ليعوّض المعدل الأعلى. - B) مستحيل؛ التحويل الأعلى يعني دائمًا طلبات أكثر. - C) انخفض AOV. - D) ارتفع CAC.
10. الذكاء الاصطناعي في التطبيق
اكتب لمساعد ذكاء اصطناعي الطلب التالي (بأرقام مصطنعة فقط):
"Explain the difference between CAC and LTV for a fictional online store using simple numbers. Then create a realistic example where the store's revenue grows each month but it loses more money with every new customer. Show all calculations and list every assumption you make."
وبالعربية: "اشرح الفرق بين CAC وLTV لمتجر إلكتروني خيالي باستخدام أرقام بسيطة. ثم أنشئ مثالًا واقعيًا تنمو فيه إيرادات المتجر كل شهر، لكنه يخسر مالًا أكثر مع كل عميل جديد. اعرض كل الحسابات واذكر كل افتراض تضعه."
لماذا قد يفيد هذا: يستطيع الذكاء الاصطناعي أن ينتج بسرعة مثالًا محلولًا تقارنه بهذا الدرس. وطلب حالة "مبيعات أعلى مع خسارة" يختبر هل يفهم أن النمو يجب أن يكون مستدامًا اقتصاديًا.
11. التحقق من مخرجات الذكاء الاصطناعي
- أعِد حساب كل رقم. راجع مقامات التحويل، وAOV (÷ الطلبات)، وCAC (÷ العملاء الجدد)، وLTV (يستخدم هامش الربح الإجمالي، لا الإيرادات وحدها).
- اكتب افتراضاته وقارنها بافتراضاتك. هل أخفى افتراضًا، مثل الطلبات المتكررة أو الأفق الزمني؟
- راجع منطق "الخسارة": هل سبب الخسارة أن CAC أعلى من مجمل الربح لكل عميل؟ أم أن الذكاء الاصطناعي خلط بين الإيرادات والربح؟
- ارفض معايير المقارنة بلا مصدر. إذا قال "نسبة LTV إلى CAC الجيدة هي X"، فتعامل معها على أنها ادعاء غير متحقق منه. لا تكررها دون مصدر وسياق وتاريخ.
- الخصوصية: لا تلصق أبدًا قوائم عملاء حقيقية أو عناوين بريد أو بيانات تسويق لشركة في أدوات ذكاء اصطناعي عامة. استخدم أرقامًا مصطنعة.
12. منظور الأعمال
قيِّم هل اكتساب 100 عميل إضافي يخلق قيمة. الإجابة ليست أبدًا مجرد "عملاء أكثر = شيء جيد". اسأل:
- كم سيكلّف اكتسابهم (CAC لـهذه القناة تحديدًا)؟
- كم مجمل ربح يُرجَّح أن يجلبوه خلال أفق زمني محدد (LTV، مع الافتراضات)؟
- إلى أي حد نحن متأكدون من الطلبات المتكررة؟ وهل نستطيع إجراء اختبار صغير أولًا؟
هذا يرتبط مباشرة بـ U01: القرار ("هل ننفق على هذه القناة؟") يأتي أولًا، ثم الدليل.
13. مهمة عمل — ورقة دراسة جدوى
عُرضت على Cedar Lane حملة مع أحد المؤثرين: 2,000 دولار مقابل 100 عميل جديد تقديرًا. استخدم AOV لشهر أكتوبر (25 دولارًا) وهامش الربح الإجمالي (50%).
أكمل ورقة عمل تتضمن:
- CAC لهذه الحملة؛
- LTV والقيمة لكل عميل جديد، بافتراض 3 طلبات خلال سنتين؛
- الحساب نفسه بافتراض طلب واحد فقط لكل عميل (اختبار حساسية)؛
- توصية (تنفيذ / اختبار صغير / عدم تنفيذ) في جملتين أو ثلاث، مع ذكر أي افتراض هو الأهم؛
- مقياس واحد ستتابعه بعد الإطلاق للتحقق من الافتراض.
14. تحدٍّ قصير
بيانات مصطنعة، ونشاط خيالي: FreshBox Meals توصّل صناديق وجبات جاهزة للطهي. وتعطي العملاء الجدد خصم 50% على أول صندوق. الصندوق يُباع عادةً بـ 60 دولارًا بهامش ربح إجمالي 35% على السعر الكامل. أول صندوق مخفّض يُباع بـ 30 دولارًا ويخسر 9 دولارات من مجمل الربح. إنفاق الاكتساب 40 دولارًا لكل عميل جديد، ويفترض الفريق أن العميل الجديد يشتري 4 صناديق إضافية بالسعر الكامل بعد الأول.
- احسب مجمل الربح المتوقع لكل عميل جديد على هذه الصناديق الخمسة، والقيمة لكل عميل جديد بعد CAC.
- إذا اشترى العملاء فعليًا 2 من الصناديق فقط بالسعر الكامل بعد الأول، فماذا يحدث؟
- اكتب جملة واحدة عن سبب كون "عدد التسجيلات الجديدة" وحده مقياس نجاح مضللًا هنا.
سلّم إجابتك قبل أي ملاحظات. لا يوجد حل هنا.
15. المصادر
- مطلوب (حوالي 10 دقائق): AWS CAF Business Perspective — Data monetization. اقرأ وصف القيمة "المتحققة" (captured)، مثل الاحتفاظ بالعملاء، والبيع المتقاطع، والبيع الإضافي (cross-sell and upsell)، ولاحظ لماذا يصعب قياس بعض القيمة. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-monetization.html (فُتحت في 11 أكتوبر 2026؛ ورقة بيضاء للرجوع التاريخي.)
- مقترح: ملاحظاتك من L06. فـ LTV هنا يعتمد على هامش الربح الإجمالي، لذا راجع سُلّم الربح.
- للتعمّق (اختياري): أعِد بناء مثال القسم 5 بأفق سنتين وطلبين بدلًا من 3، ولاحظ كيف يتغير القرار. (لا يوجد مصدر خارجي محدد هنا. تركيز المصادر في الخريطة، "business case worksheet / unit economics"، نشاط عملي وليس منشورًا بعينه.)
16. شخصية تتابعها / قدوة
منظور الممارس (دون تسمية شخص). تذكر خريطة D.World عبارة "Product analytics practitioner" (ممارس تحليلات المنتج)، وهي نوع من الأدوار وليست شخصًا محددًا.
جرّب هذا: اقرأ توصيفين وظيفيين لوظائف تحليلات المنتج أو تحليلات النمو في منطقتك. لاحظ كم مرة تظهر مسارات التحويل أو التحويل أو الاحتفاظ بالعملاء، وسجّل تاريخ كل إعلان ومكانه. وتعامل مع ما تجده على أنه أمثلة، لا قواعد عامة.
17. المصطلحات
| المصطلح | معناه في هذا الدرس |
|---|---|
| مسار التحويل (Funnel) | تتابع الخطوات من الزيارة الأولى إلى الشراء |
| الجلسة (Session) | زيارة واحدة للموقع؛ وقد ينشئ الشخص الواحد عدة جلسات |
| معدل التحويل (Conversion rate) | الأشخاص أو الجلسات التي وصلت إلى خطوة لاحقة ÷ من كانوا في خطوة سابقة، عن الفترة نفسها |
| متوسط قيمة الطلب (AOV) | الإيرادات ÷ عدد الطلبات، عن الفترة نفسها |
| تكلفة اكتساب العميل (CAC) | إنفاق الاكتساب الموجّه للعملاء الجدد ÷ العملاء الجدد المكتسبين، عن الفترة نفسها |
| قيمة العميل على المدى الطويل (LTV، بصيغة بسيطة) | AOV × هامش الربح الإجمالي × الطلبات المفترضة لكل عميل خلال أفق محدد |
| القيمة لكل عميل جديد | LTV − CAC |
| اقتصاديات الوحدة (Unit economics) | الإيرادات والتكاليف والربح مقيسة لكل وحدة (لكل عميل أو لكل طلب) |
| اختبار الحساسية (Sensitivity check) | إعادة الحساب بافتراض مختلف لمعرفة هل يتغير القرار |
| النمو المستدام (Sustainable growth) | نمو يُتوقع فيه أن يساوي كل عميل جديد أكثر مما يكلّف اكتسابه |
18. تأمّل
فكّر في "تجربة مجانية" أو "خصم على أول طلب" استخدمته من قبل. هل اشتريت مرة أخرى؟ وماذا يقول سلوكك أنت عن الافتراضات التي تضعها الشركة عندما تقدّر LTV؟
19. الخطوة التالية
أصبحت تستطيع حساب أرقام كثيرة: الإيرادات، والهامش، والتحويل، وAOV، وCAC، وLTV. لكن أيها يجب أن يراقبه الفريق؟ في L08 — مؤشرات الأداء والمقاييس وسؤال العمل، ستتعلم اختيار مجموعة صغيرة من المقاييس المرتبطة بهدف وقرار. وستتعلم أيضًا تحويل قلق غامض مثل "المبيعات انخفضت" إلى أسئلة دقيقة.
20. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| الحالة الرقمية، الجزء A (A1–A5) | معادلات ومقامات وحسابات صحيحة | 4 إجابات صحيحة أو أكثر من 5، مع عرض خطوات الحل |
| أسئلة القرار، الجزء B (B1–B4) | التفسير واتخاذ القرار | 3 إجابات صحيحة أو أكثر من 4؛ ويجب أن تكون إجابة B2 صحيحة |
| مهمة العمل (ورقة دراسة الجدوى) | تقييم "100 عميل إضافي" مع اختبار الحساسية | معايير L07-WT |
| التدريب المستقل والتحدي القصير | نقل المهارة إلى سياق جديد | معايير L07-IP وL07-MC |
المراجع
- Amazon Web Services. AWS CAF Business Perspective — Data monetization. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-monetization.html (فُتحت وروجعت في 11 أكتوبر 2026). يدعم: أن القيمة المتحققة تشمل الاحتفاظ بالعملاء، والتخصيص، والبيع المتقاطع والإضافي؛ وأن كثيرًا من الفوائد يصعب قياسها؛ وملاحظة الرجوع التاريخي.
- معادلات التحويل وAOV وCAC وLTV البسيط هي تعريفات تعليمية من D.World، مذكورة مع نطاقها وافتراضاتها. ولم تؤخذ من معيار خارجي واحد، لأن التعريفات تختلف بين الأنشطة (راجع سجل المصادر).
- D.World Curriculum Map v1.0 (صف L07) وCurriculum Bible v1.0. وثائق داخلية.
L08 · KPIs, Metrics & the Business QuestionL08 · مؤشرات الأداء والمقاييس وسؤال العمل Freeمجاني
L08 — KPIs, Metrics & the Business Question
Learner file. Answers and model solutions are in a separate instructor-only file. Version: U02 v1.0 · Content date: 11 October 2026. Time estimates are provisional until learner-tested.
1. Lesson Identity
| Field | Value |
|---|---|
| Title | KPIs, Metrics & the Business Question |
| Stage | Stage 1 — Foundations |
| Unit | U02 — Business Foundations for Data Professionals |
| Lesson ID | L08 |
| Skills | KPI design; problem framing |
| Difficulty | Beginner |
| Estimated time | About 1 hour 45 minutes (provisional) |
| Prerequisites | L05–L07 (profit lines, funnel, AOV, CAC, LTV). U01 L02 (observation vs hypothesis) and L04 (decision and success measure). |
Time breakdown (provisional): concept and worked example, 30 min · guided practice, 15 min · independent practice, 15 min · knowledge check (metric selection), 10 min · AI in Practice and Verification, 15 min · workplace task, 15 min · mini challenge, 5 min.
2. Learning Objective
By the end of this lesson, you will be able to distinguish a KPI from a general metric, define a KPI precisely, and translate a business goal or problem into measurable diagnostic questions.
3. Why It Matters
Modern businesses can measure hundreds of things. Dashboards fill up with numbers, and teams argue about which ones matter. Many numbers look impressive but do not help anyone decide anything.
A data professional earns trust by asking first: "What decision are we trying to make, and how will we know it worked?" Then they choose a small number of metrics that answer it. Key principle: start with the decision and the success metric.
4. Concept
Metric vs KPI
- A metric is any measurable quantity: sessions, orders, followers, page views, gross margin.
- A KPI (key performance indicator) is a metric that has been selected because it directly shows progress toward a specific goal linked to a decision. It has a clear definition, a target, a time frame and an owner.
Every KPI is a metric; most metrics are not KPIs. Which metric is "key" depends on the goal. The same metric (for example, conversion rate) can be a KPI for one goal and a supporting metric for another.
A KPI definition card
A KPI is only useful if everyone calculates it the same way:
| Field | Example |
|---|---|
| Name | Monthly gross profit |
| Formula | Revenue (after discounts) − COGS |
| Scope and denominator | All online orders; calendar month |
| Target and time frame | 8,250 USD per month by January |
| Owner | Store owner |
| Linked decision | Which levers to prioritize: conversion, AOV, or supplier costs |
Supporting, guardrail and vanity metrics
- Supporting metrics explain why the KPI moves. For example, gross profit = sessions × conversion × AOV × gross margin, so each factor is a supporting metric.
- Guardrail metrics make sure improving the KPI does not damage something else. Example: return rate, customer complaints, marketing spend.
- Vanity metrics look good, especially when they only go up, but do not inform the decision. Examples: total social-media followers, cumulative registered accounts "since launch," total page views. They are not always useless, but they are usually not KPIs.
From goal to measurable questions
Goal → decision → KPI (with definition) → supporting and guardrail metrics → diagnostic questions
A diagnostic question is a precise, answerable question that helps explain a change. Example: "Did orders fall because fewer people visited, or because a smaller share of visitors bought?"
A useful habit is to break the KPI into its parts. For an online store:
Revenue = sessions × conversion rate × AOV, and gross profit = revenue × gross margin.
When revenue falls, ask which part changed.
5. Worked Example
Synthetic data; fictional store. Cedar Lane's owner says: "I want the business to be healthier." That is too vague to measure.
- Make the goal specific: "Increase monthly gross profit by 10% within 3 months, without increasing marketing spend."
- Decision it supports: which improvement to work on first: website conversion, AOV (e.g., bundles), or supplier costs (gross margin).
- Baseline (October, from L07): gross profit = 15,000 × 50% = 7,500 USD. Check with the parts: 20,000 sessions × 3.0% × 25 USD × 50% = 7,500 ✔.
- KPI: monthly gross profit; target 7,500 × 1.10 = 8,250 USD per month by January. Owner: store owner.
- Supporting metrics: sessions, overall conversion (orders ÷ sessions), AOV (revenue ÷ orders), gross margin (%).
- Guardrails: marketing spend (must not exceed October's level); return rate, so that bundles do not lead to more returns.
- Vanity metrics to leave out: Instagram followers; total page views.
- Diagnostic questions if progress stalls: "Which factor changed: sessions, conversion, AOV or margin?" "Which product category drove it?"
6. Visual Explanation
GOAL: +10% monthly gross profit in 3 months (no extra marketing)
|
DECISION: which lever first?
|
KPI: Monthly gross profit (target 8,250 USD)
|
+-- Sessions x Conversion x AOV = Revenue
| x Gross margin = Gross profit
|
GUARDRAILS: marketing spend <= October; return rate
NOT KPIs: followers, total page views (vanity)
Alt text: A top-down tree. The goal is plus 10 percent monthly gross profit in three months with no extra marketing. Below it, the decision of which lever to try first. Below that, the KPI of monthly gross profit with a target of 8,250 USD. The KPI breaks into sessions times conversion times average order value, which equals revenue, then times gross margin, which equals gross profit. Guardrails listed: marketing spend no higher than October, and return rate. Listed as not KPIs: followers and total page views, labelled vanity.
7. Guided Practice
Goal (fictional, continuing U01 L04): Cedar Lane wants to reduce late deliveries so customers keep buying.
- Write the decision this goal supports. (Hint: think about the delivery company or how peak weeks are handled.)
- Complete a KPI definition card (name, formula, scope/denominator, target and time frame, owner). (Hint: a share of orders delivered on time needs a denominator: which orders?)
- Name two supporting metrics that could explain changes in your KPI.
- Name one guardrail metric. (Hint: what could get worse if you push delivery speed too hard? Think about cost.)
- Name one vanity metric someone might suggest, and say why it is not useful here.
8. Independent Practice
Fictional business: Pulse Studio, a small fitness studio, says: "Too many members are leaving."
- Rewrite this as a specific goal with a time frame.
- Define one KPI fully (use the KPI card fields).
- List two supporting metrics and one guardrail metric.
- Write three diagnostic questions.
No model answer is shown here.
9. Knowledge Check — Metric Selection Exercise
Part A — Choose the best answer. Goal (fictional store): "Increase the share of first-time customers who place a second order within 60 days, from 20% to 25% by the end of next quarter."
A1. Which is the best KPI for this goal? - A) Total website sessions - B) Total social-media followers - C) 60-day repeat rate: first-time customers who place a second order within 60 days ÷ all first-time customers in the same period - D) Total revenue
A2. Which is a vanity metric for this goal? - A) Open rate of the follow-up email sent to first-time customers - B) Total registered accounts since the store launched - C) Average days between first and second order - D) Unsubscribe rate of the follow-up emails
A3. The team plans to email first-time customers more often. Which is the best guardrail metric? - A) Total page views - B) Number of products on the website - C) Revenue from the store's best-selling product - D) Unsubscribe and complaint rate for those emails
A4. A dashboard shows "Repeat rate: 23%" with no other detail. What is the most important missing information? - A) The denominator and time window: which customers, and within how many days - B) The colour of the chart - C) The name of the software that produced it - D) The number of decimal places
Part B — Classify each metric for this goal: "Increase average order value from 25 to 28 USD within 2 months, without reducing gross margin." Label each as KPI, Supporting, Guardrail or Vanity / not useful. Add a reason if you think another label is justified.
| # | Metric | Label |
|---|---|---|
| 1 | Average order value (revenue ÷ orders, monthly) | |
| 2 | Average items per order | |
| 3 | Share of orders that include a product bundle | |
| 4 | Gross margin (%) | |
| 5 | Overall conversion rate | |
| 6 | Total page views | |
| 7 | Instagram followers | |
| 8 | Number of products listed on the website |
10. AI in Practice
Prompt an AI assistant (fictional business only):
"A fictional online stationery store wants to increase monthly gross profit by 10% in 3 months without increasing marketing spend. Propose 8 metrics it could track. For each, say whether it should be the KPI, a supporting metric, a guardrail, or a vanity metric, and give a one-line reason. Give a precise definition (formula, denominator, period) for the KPI."
Then reject every vanity metric the AI proposes as a KPI, and write why.
Why this can help: AI produces a long list quickly, and the useful skill is in cutting it down. Practising rejection builds your judgment.
11. AI Verification
- Check the KPI is tied to the goal (gross profit), not to a convenient number (e.g., sessions).
- Check definitions: does each metric have a formula, a denominator and a period? Rewrite any that are vague.
- Check the arithmetic logic: do the supporting metrics actually multiply or add up to the KPI (sessions × conversion × AOV × margin)?
- Spot vanity metrics the AI labelled as important. Write your reason for rejecting each.
- Reject invented benchmarks ("a good conversion rate is 3%") unless you can find a credible, dated source with context.
- Privacy: do not paste real dashboards or customer data into public AI tools.
12. Business Lens
Turn "sales are down" into five diagnostic data questions. A vague complaint leads to random fixes. Precise questions lead to the right data and a better decision. Strong diagnostic questions usually cover:
- Compared with what? Which period, and is the comparison fair (seasonality, holidays)?
- Which part of the formula changed? Sessions, conversion, AOV?
- Which segment? Product category, traffic source, new vs returning customers, region?
- Where in the funnel? Which step's conversion dropped?
- Is the data right? Did tracking, definitions or reporting change?
13. Workplace Task — From "Sales Are Down" to Five Questions
Synthetic data; Cedar Lane. The owner says: "Sales are down this month. What's wrong?"
| Metric | November | December |
|---|---|---|
| Sessions | 25,000 | 22,000 |
| Orders | 750 | 550 |
| Revenue (USD) | 18,000 | 13,200 |
- Calculate the change in revenue (USD and %), and November's and December's overall conversion and AOV.
- Write five diagnostic data questions, at least one from each category in Section 12, that would help explain the drop. Make each question specific enough to answer with data.
- State one hypothesis (labelled as such, see U01 L02) and the data that would test it.
14. Mini Challenge
Fictional business: LinguaLeap, a language-learning app, says: "We want more people to actually learn, not just download the app."
- Write a specific goal with a time frame.
- Choose one KPI and define it fully.
- Name two supporting metrics, one guardrail and one vanity metric (and why it is vanity).
- Write three diagnostic questions for a month where your KPI falls.
Submit before feedback. No solution is provided here.
15. Resources
- Required (about 15 min): AWS CAF Business Perspective — Business insights. Read the "Start" recommendations about identifying the business decisions that need insights and tracking metrics to measure performance and customer experience. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/business-insights.html (Opened 11 Oct 2026; historical-reference whitepaper.)
- Recommended: your L06 profit ladder and L07 funnel notes. Each formula there can become a KPI or a supporting metric.
- Deeper (optional): take any dashboard you can see publicly or in your own work (without copying confidential data). Label each number on it as KPI, supporting, guardrail or vanity, and write the goal you assumed.
16. Person to Follow / Role Model
Practitioner perspective (no named person). The D.World map lists "Analytics leader / business data practitioner," a type of role rather than a specific person.
Try this: if you can, ask someone who leads a team (in any field) which one number they would want to see every Monday morning, and why. Then ask what decision that number helps them make.
17. Glossary
| Term | Meaning in this lesson |
|---|---|
| Metric | Any measurable quantity |
| KPI (key performance indicator) | A metric chosen to track progress toward a specific goal linked to a decision, with a definition, target, time frame and owner |
| Supporting metric | A metric that helps explain why the KPI changes |
| Guardrail metric | A metric watched to make sure improving the KPI does not cause harm elsewhere |
| Vanity metric | A number that looks impressive but does not inform the decision |
| Diagnostic question | A precise, answerable question that helps explain a change |
| Baseline | The starting value used for comparison |
| Target | The value the KPI should reach by a given time |
| Segment | A subgroup, such as a product category, a traffic source, or new vs returning customers |
| Seasonality | Regular patterns linked to time of year (e.g., back-to-school, holidays) |
18. Reflection
Think of a number you track in your own life (steps, study hours, savings, followers). Is it closer to a KPI or a vanity metric for what you actually want to achieve? What would a better KPI be?
19. Next Step
U02 is complete after the U02 Exit Assessment: you will receive a business case and define a goal, a coherent metric set and diagnostic questions. Next comes U03 — AI for Data Work, where you will learn to use AI tools responsibly in depth. That includes how to write context-rich prompts and how to catch AI errors in exactly the kind of business reasoning you practised here.
20. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Metric selection Part A (A1–A4) | Distinguishes KPI, vanity and guardrail metrics, and definition needs | 3 or more of 4 correct |
| Metric selection Part B (1–8) | Classifies metrics against a goal | 6 or more of 8, with justified alternatives accepted |
| Workplace task (five diagnostic questions) | Turns a vague problem into measurable questions | Rubric L08-WT |
| Guided and independent practice, mini challenge | KPI cards and transfer | Rubrics L08-IP and L08-MC |
References
- Amazon Web Services. AWS CAF Business Perspective — Business insights. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/business-insights.html (opened and checked 11 Oct 2026). Supports: identifying the business decisions that need high-quality insights; tracking metrics to measure performance and customer experience; automating KPI tracking; historical-reference notice.
- The KPI, supporting, guardrail and vanity distinctions and the KPI card are D.World teaching definitions. They are common in analytics practice, but no single external standard is cited (see the source log).
- D.World Curriculum Map v1.0 (L08 row) and Curriculum Bible v1.0. Internal.
L08 — مؤشرات الأداء والمقاييس وسؤال العمل
ملف المتعلّم. الإجابات والحلول النموذجية في ملف منفصل خاص بالمدرّس فقط. الإصدار: U02 v1.0 · تاريخ المحتوى: 11 أكتوبر 2026. تقديرات الوقت مبدئية إلى أن تُجرَّب مع المتعلّمين.
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | مؤشرات الأداء والمقاييس وسؤال العمل |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U02 — أساسيات الأعمال لمحترفي البيانات |
| رقم الدرس | L08 |
| المهارات | تصميم مؤشرات الأداء الرئيسية (KPI)؛ صياغة المشكلة |
| المستوى | مبتدئ |
| الوقت المتوقع | حوالي ساعة و45 دقيقة (مبدئي) |
| المتطلبات السابقة | L05–L07 (بنود الربح، مسار التحويل، AOV، CAC، LTV). وL02 في U01 (الملاحظة مقابل الفرضية) وL04 (القرار ومقياس النجاح). |
تفصيل الوقت (مبدئي): المفهوم والمثال المحلول 30 دقيقة · التدريب الموجَّه 15 دقيقة · التدريب المستقل 15 دقيقة · اختبار الفهم (اختيار المقاييس) 10 دقائق · الذكاء الاصطناعي في التطبيق والتحقق 15 دقيقة · مهمة العمل 15 دقيقة · التحدي القصير 5 دقائق.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تميّز بين مؤشر الأداء الرئيسي والمقياس العام، وأن تعرّف مؤشر الأداء تعريفًا دقيقًا، وأن تحوّل هدف عمل أو مشكلة إلى أسئلة تشخيصية قابلة للقياس.
3. لماذا يهمّك هذا؟
الأنشطة التجارية الحديثة تستطيع قياس مئات الأشياء. فتمتلئ لوحات المتابعة بالأرقام، وتتجادل الفرق حول أيها يهم. وكثير من الأرقام يبدو مبهرًا لكنه لا يساعد أحدًا على أن يقرر أي شيء.
محترف البيانات يكسب الثقة عندما يسأل أولًا: "ما القرار الذي نحاول اتخاذه، وكيف سنعرف أنه نجح؟" ثم يختار عددًا صغيرًا من المقاييس التي تجيب عن ذلك. المبدأ الأساسي: ابدأ بالقرار وبمقياس النجاح.
4. المفهوم
المقياس مقابل مؤشر الأداء الرئيسي
- المقياس (metric) هو أي كمية قابلة للقياس: الجلسات، والطلبات، والمتابعون، ومشاهدات الصفحات، وهامش الربح الإجمالي.
- مؤشر الأداء الرئيسي (KPI) مقياس اختير لأنه يُظهر مباشرة التقدم نحو هدف محدد مرتبط بقرار. وله تعريف واضح، وقيمة مستهدفة، وإطار زمني، ومسؤول.
كل مؤشر أداء رئيسي هو مقياس، لكن أغلب المقاييس ليست مؤشرات أداء رئيسية. وكون المقياس "رئيسيًا" يعتمد على الهدف. المقياس نفسه (مثل معدل التحويل) قد يكون مؤشر أداء رئيسيًا لهدف ما، ومقياسًا مساعدًا لهدف آخر.
بطاقة تعريف مؤشر الأداء
مؤشر الأداء لا يفيد إلا إذا حسبه الجميع بالطريقة نفسها:
| البند | مثال |
|---|---|
| الاسم | مجمل الربح الشهري |
| المعادلة | الإيرادات (بعد الخصومات) − COGS |
| النطاق والمقام | كل الطلبات على الإنترنت؛ الشهر الميلادي |
| القيمة المستهدفة والإطار الزمني | 8,250 دولار شهريًا بحلول يناير |
| المسؤول | صاحب المتجر |
| القرار المرتبط | أي الروافع نعطيها الأولوية: التحويل، أم AOV، أم تكاليف الموردين |
المقاييس المساعدة، ومقاييس الحماية، ومقاييس التباهي
- المقاييس المساعدة (supporting metrics) تشرح لماذا يتحرك مؤشر الأداء. مثلًا، مجمل الربح = الجلسات × التحويل × AOV × هامش الربح الإجمالي، فكل عامل من هذه العوامل مقياس مساعد.
- مقاييس الحماية (guardrail metrics) تضمن ألا يضر تحسين مؤشر الأداء بشيء آخر. مثال: معدل المرتجعات، وشكاوى العملاء، والإنفاق على التسويق.
- مقاييس التباهي (vanity metrics) تبدو جيدة، خاصة عندما لا تفعل شيئًا سوى الارتفاع، لكنها لا تفيد القرار. أمثلة: إجمالي المتابعين على وسائل التواصل، والحسابات المسجلة التراكمية "منذ الإطلاق"، وإجمالي مشاهدات الصفحات. هي ليست بلا فائدة دائمًا، لكنها عادةً ليست مؤشرات أداء رئيسية.
من الهدف إلى أسئلة قابلة للقياس
الهدف ← القرار ← مؤشر الأداء (بتعريفه) ← المقاييس المساعدة ومقاييس الحماية ← الأسئلة التشخيصية
السؤال التشخيصي (diagnostic question) سؤال دقيق يمكن الإجابة عنه، ويساعد على تفسير تغيّر ما. مثال: "هل انخفضت الطلبات لأن عدد الزوار قلّ، أم لأن نسبة أقل من الزوار اشترت؟"
من العادات المفيدة أن تفكك مؤشر الأداء إلى أجزائه. في متجر إلكتروني:
الإيرادات = الجلسات × معدل التحويل × AOV، ومجمل الربح = الإيرادات × هامش الربح الإجمالي.
عندما تنخفض الإيرادات، اسأل أي جزء تغيّر.
5. مثال محلول
بيانات مصطنعة؛ متجر خيالي. يقول صاحب Cedar Lane: "أريد أن يصبح النشاط في حال أفضل." هذا غامض جدًا ولا يمكن قياسه.
- اجعل الهدف محددًا: "زيادة مجمل الربح الشهري بنسبة 10% خلال 3 أشهر، دون زيادة الإنفاق على التسويق."
- القرار الذي يدعمه: أي تحسين نبدأ به أولًا: التحويل في الموقع، أم AOV (مثلًا عبر الباقات)، أم تكاليف الموردين (هامش الربح الإجمالي).
- خط الأساس (أكتوبر، من L07): مجمل الربح = 15,000 × 50% = 7,500 دولار. تحقّق بالأجزاء: 20,000 جلسة × 3.0% × 25 دولارًا × 50% = 7,500 ✔.
- مؤشر الأداء: مجمل الربح الشهري؛ القيمة المستهدفة 7,500 × 1.10 = 8,250 دولار شهريًا بحلول يناير. المسؤول: صاحب المتجر.
- المقاييس المساعدة: الجلسات، والتحويل الإجمالي (الطلبات ÷ الجلسات)، وAOV (الإيرادات ÷ الطلبات)، وهامش الربح الإجمالي (%).
- مقاييس الحماية: الإنفاق على التسويق (يجب ألا يتجاوز مستوى أكتوبر)؛ ومعدل المرتجعات، حتى لا تؤدي الباقات إلى مرتجعات أكثر.
- مقاييس تباهٍ نستبعدها: متابعو Instagram؛ وإجمالي مشاهدات الصفحات.
- أسئلة تشخيصية إذا توقف التقدم: "أي عامل تغيّر: الجلسات، أم التحويل، أم AOV، أم الهامش؟" "أي فئة منتجات كانت وراء ذلك؟"
6. شرح بصري
GOAL: +10% monthly gross profit in 3 months (no extra marketing)
|
DECISION: which lever first?
|
KPI: Monthly gross profit (target 8,250 USD)
|
+-- Sessions x Conversion x AOV = Revenue
| x Gross margin = Gross profit
|
GUARDRAILS: marketing spend <= October; return rate
NOT KPIs: followers, total page views (vanity)
وصف الرسم: شجرة من أعلى إلى أسفل. الهدف (Goal): زيادة مجمل الربح الشهري 10% خلال ثلاثة أشهر دون تسويق إضافي. تحته القرار (Decision): أي رافعة نجرّب أولًا. وتحته مؤشر الأداء (KPI): مجمل الربح الشهري بقيمة مستهدفة 8,250 دولار. ويتفرع المؤشر إلى الجلسات × التحويل × متوسط قيمة الطلب، ويساوي ذلك الإيرادات، ثم × هامش الربح الإجمالي، فيساوي مجمل الربح. مقاييس الحماية (Guardrails) المذكورة: الإنفاق على التسويق لا يزيد على أكتوبر، ومعدل المرتجعات. والمذكور على أنه ليس مؤشرات أداء: المتابعون وإجمالي مشاهدات الصفحات، ومكتوب عليها مقاييس تباهٍ (vanity).
7. تدريب موجَّه
الهدف (خيالي، استكمالًا لـ L04 في U01): تريد Cedar Lane أن تقلل التوصيلات المتأخرة حتى يستمر العملاء في الشراء.
- اكتب القرار الذي يدعمه هذا الهدف. (تلميح: فكّر في شركة التوصيل أو في طريقة التعامل مع أسابيع الذروة.)
- أكمل بطاقة تعريف مؤشر الأداء (الاسم، والمعادلة، والنطاق/المقام، والقيمة المستهدفة والإطار الزمني، والمسؤول). (تلميح: نسبة الطلبات المسلّمة في الموعد تحتاج إلى مقام: أي طلبات؟)
- سمِّ مقياسين مساعدين يمكن أن يفسّرا التغيّرات في مؤشرك.
- سمِّ مقياس حماية واحدًا. (تلميح: ما الذي قد يسوء إذا ضغطت على سرعة التوصيل أكثر من اللازم؟ فكّر في التكلفة.)
- سمِّ مقياس تباهٍ واحدًا قد يقترحه أحدهم، وقل لماذا لا يفيد هنا.
8. تدريب مستقل
نشاط خيالي: Pulse Studio، استوديو لياقة صغير، يقول: "عدد كبير جدًا من الأعضاء يتركوننا."
- أعِد كتابة هذا كهدف محدد له إطار زمني.
- عرّف مؤشر أداء واحدًا تعريفًا كاملًا (استخدم بنود بطاقة مؤشر الأداء).
- اذكر مقياسين مساعدين ومقياس حماية واحدًا.
- اكتب ثلاثة أسئلة تشخيصية.
لا توجد إجابة نموذجية هنا.
9. اختبار الفهم — تمرين اختيار المقاييس
الجزء A — اختر أفضل إجابة. الهدف (متجر خيالي): "زيادة نسبة العملاء لأول مرة الذين يطلبون طلبًا ثانيًا خلال 60 يومًا، من 20% إلى 25% بنهاية الربع القادم."
A1. ما أفضل مؤشر أداء رئيسي لهذا الهدف؟ - A) إجمالي جلسات الموقع - B) إجمالي المتابعين على وسائل التواصل - C) معدل التكرار خلال 60 يومًا: العملاء لأول مرة الذين طلبوا طلبًا ثانيًا خلال 60 يومًا ÷ كل العملاء لأول مرة في الفترة نفسها - D) إجمالي الإيرادات
A2. أي مما يلي مقياس تباهٍ بالنسبة لهذا الهدف؟ - A) معدل فتح رسالة المتابعة المرسلة إلى العملاء لأول مرة - B) إجمالي الحسابات المسجلة منذ إطلاق المتجر - C) متوسط الأيام بين الطلب الأول والثاني - D) معدل إلغاء الاشتراك في رسائل المتابعة
A3. يخطط الفريق لمراسلة العملاء لأول مرة بالبريد الإلكتروني أكثر. ما أفضل مقياس حماية؟ - A) إجمالي مشاهدات الصفحات - B) عدد المنتجات على الموقع - C) الإيرادات من المنتج الأكثر مبيعًا في المتجر - D) معدل إلغاء الاشتراك والشكاوى الخاص بهذه الرسائل
A4. لوحة متابعة تعرض "معدل التكرار: 23%" دون أي تفاصيل أخرى. ما أهم معلومة ناقصة؟ - A) المقام والنافذة الزمنية: أي عملاء، وخلال كم يومًا - B) لون الرسم البياني - C) اسم البرنامج الذي أنتجه - D) عدد المنازل العشرية
الجزء B — صنّف كل مقياس بالنسبة لهذا الهدف: "زيادة متوسط قيمة الطلب من 25 إلى 28 دولارًا خلال شهرين، دون خفض هامش الربح الإجمالي." صنّف كل مقياس على أنه KPI (مؤشر أداء رئيسي)، أو Supporting (مساعد)، أو Guardrail (حماية)، أو Vanity / not useful (تباهٍ / غير مفيد). وأضف سببًا إذا رأيت أن تصنيفًا آخر له ما يبرره.
| # | المقياس | التصنيف |
|---|---|---|
| 1 | متوسط قيمة الطلب (الإيرادات ÷ الطلبات، شهريًا) | |
| 2 | متوسط عدد المنتجات في الطلب | |
| 3 | نسبة الطلبات التي تتضمن باقة منتجات | |
| 4 | هامش الربح الإجمالي (%) | |
| 5 | معدل التحويل الإجمالي | |
| 6 | إجمالي مشاهدات الصفحات | |
| 7 | متابعو Instagram | |
| 8 | عدد المنتجات المعروضة على الموقع |
10. الذكاء الاصطناعي في التطبيق
اكتب لمساعد ذكاء اصطناعي الطلب التالي (نشاط خيالي فقط):
"A fictional online stationery store wants to increase monthly gross profit by 10% in 3 months without increasing marketing spend. Propose 8 metrics it could track. For each, say whether it should be the KPI, a supporting metric, a guardrail, or a vanity metric, and give a one-line reason. Give a precise definition (formula, denominator, period) for the KPI."
وبالعربية: "متجر خيالي للأدوات المكتبية على الإنترنت يريد زيادة مجمل الربح الشهري بنسبة 10% خلال 3 أشهر دون زيادة الإنفاق على التسويق. اقترح 8 مقاييس يمكنه متابعتها. لكل مقياس، قل هل يجب أن يكون مؤشر الأداء الرئيسي، أم مقياسًا مساعدًا، أم مقياس حماية، أم مقياس تباهٍ، مع سبب في سطر واحد. وأعطِ تعريفًا دقيقًا (المعادلة، والمقام، والفترة) لمؤشر الأداء الرئيسي."
ثم ارفض كل مقياس تباهٍ يقترحه الذكاء الاصطناعي على أنه مؤشر أداء رئيسي، واكتب السبب.
لماذا قد يفيد هذا: الذكاء الاصطناعي ينتج قائمة طويلة بسرعة، والمهارة الحقيقية في تقليصها. والتدرّب على الرفض يبني حكمك.
11. التحقق من مخرجات الذكاء الاصطناعي
- تأكد أن مؤشر الأداء مرتبط بالهدف (مجمل الربح)، وليس برقم سهل الحصول عليه (مثل الجلسات).
- راجع التعريفات: هل لكل مقياس معادلة ومقام وفترة؟ أعِد كتابة أي تعريف غامض.
- راجع منطق الحساب: هل حاصل ضرب المقاييس المساعدة أو مجموعها يعطي مؤشر الأداء فعلًا (الجلسات × التحويل × AOV × الهامش)؟
- اكتشف مقاييس التباهي التي وصفها الذكاء الاصطناعي بأنها مهمة. واكتب سبب رفضك لكل منها.
- ارفض معايير المقارنة المخترعة ("معدل التحويل الجيد 3%") ما لم تجد مصدرًا موثوقًا ومؤرخًا مع سياقه.
- الخصوصية: لا تلصق لوحات متابعة حقيقية أو بيانات عملاء في أدوات ذكاء اصطناعي عامة.
12. منظور الأعمال
حوّل عبارة "المبيعات انخفضت" إلى خمسة أسئلة بيانات تشخيصية. الشكوى الغامضة تؤدي إلى حلول عشوائية، والأسئلة الدقيقة تؤدي إلى البيانات الصحيحة وقرار أفضل. الأسئلة التشخيصية القوية تغطي عادةً:
- مقارنةً بماذا؟ أي فترة، وهل المقارنة عادلة (الموسمية، والعطلات)؟
- أي جزء من المعادلة تغيّر؟ الجلسات، أم التحويل، أم AOV؟
- أي شريحة؟ فئة المنتج، أم مصدر الزيارات، أم العملاء الجدد مقابل العائدين، أم المنطقة؟
- أين في مسار التحويل؟ تحويل أي خطوة انخفض؟
- هل البيانات صحيحة؟ هل تغيّرت طريقة التتبع أو التعريفات أو التقارير؟
13. مهمة عمل — من "المبيعات انخفضت" إلى خمسة أسئلة
بيانات مصطنعة؛ Cedar Lane. يقول صاحب المتجر: "المبيعات انخفضت هذا الشهر. ما المشكلة؟"
| المقياس | نوفمبر | ديسمبر |
|---|---|---|
| الجلسات | 25,000 | 22,000 |
| الطلبات | 750 | 550 |
| الإيرادات (بالدولار) | 18,000 | 13,200 |
- احسب التغيّر في الإيرادات (بالدولار وبالنسبة المئوية)، والتحويل الإجمالي وAOV لشهري نوفمبر وديسمبر.
- اكتب خمسة أسئلة بيانات تشخيصية، منها سؤال واحد على الأقل من كل فئة في القسم 12، تساعد على تفسير الانخفاض. واجعل كل سؤال محددًا بما يكفي للإجابة عنه بالبيانات.
- اذكر فرضية واحدة (موصوفة بأنها فرضية، راجع L02 في U01) والبيانات التي تختبرها.
14. تحدٍّ قصير
نشاط خيالي: LinguaLeap، تطبيق لتعلّم اللغات، يقول: "نريد أن يتعلم الناس فعلًا، لا أن يحمّلوا التطبيق فقط."
- اكتب هدفًا محددًا له إطار زمني.
- اختر مؤشر أداء رئيسيًا واحدًا وعرّفه تعريفًا كاملًا.
- سمِّ مقياسين مساعدين، ومقياس حماية واحدًا، ومقياس تباهٍ واحدًا (ولماذا هو مقياس تباهٍ).
- اكتب ثلاثة أسئلة تشخيصية لشهر ينخفض فيه مؤشرك.
سلّم إجابتك قبل أي ملاحظات. لا يوجد حل هنا.
15. المصادر
- مطلوب (حوالي 15 دقيقة): AWS CAF Business Perspective — Business insights. اقرأ توصيات "Start" عن تحديد قرارات العمل التي تحتاج إلى استنتاجات، ومتابعة المقاييس لقياس الأداء وتجربة العملاء. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/business-insights.html (فُتحت في 11 أكتوبر 2026؛ ورقة بيضاء للرجوع التاريخي.)
- مقترح: ملاحظاتك عن سُلّم الربح في L06 ومسار التحويل في L07. كل معادلة هناك يمكن أن تصبح مؤشر أداء رئيسيًا أو مقياسًا مساعدًا.
- للتعمّق (اختياري): خذ أي لوحة متابعة يمكنك رؤيتها علنًا أو في عملك (دون نسخ بيانات سرية). صنّف كل رقم فيها: مؤشر أداء رئيسي، أو مساعد، أو حماية، أو تباهٍ، واكتب الهدف الذي افترضته.
16. شخصية تتابعها / قدوة
منظور الممارس (دون تسمية شخص). تذكر خريطة D.World عبارة "Analytics leader / business data practitioner" (قائد تحليلات / ممارس بيانات أعمال)، وهي نوع من الأدوار وليست شخصًا محددًا.
جرّب هذا: إن استطعت، اسأل شخصًا يقود فريقًا (في أي مجال) عن الرقم الواحد الذي يريد أن يراه صباح كل يوم إثنين، ولماذا. ثم اسأله ما القرار الذي يساعده هذا الرقم على اتخاذه.
17. المصطلحات
| المصطلح | معناه في هذا الدرس |
|---|---|
| المقياس (Metric) | أي كمية قابلة للقياس |
| مؤشر الأداء الرئيسي (KPI) | مقياس اختير لمتابعة التقدم نحو هدف محدد مرتبط بقرار، وله تعريف وقيمة مستهدفة وإطار زمني ومسؤول |
| المقياس المساعد (Supporting metric) | مقياس يساعد على تفسير سبب تغيّر مؤشر الأداء |
| مقياس الحماية (Guardrail metric) | مقياس يُراقَب للتأكد من أن تحسين مؤشر الأداء لا يسبب ضررًا في مكان آخر |
| مقياس التباهي (Vanity metric) | رقم يبدو مبهرًا لكنه لا يفيد القرار |
| السؤال التشخيصي (Diagnostic question) | سؤال دقيق يمكن الإجابة عنه ويساعد على تفسير تغيّر ما |
| خط الأساس (Baseline) | القيمة الابتدائية المستخدمة للمقارنة |
| القيمة المستهدفة (Target) | القيمة التي يجب أن يصل إليها مؤشر الأداء بحلول وقت محدد |
| الشريحة (Segment) | مجموعة فرعية، مثل فئة منتج، أو مصدر زيارات، أو العملاء الجدد مقابل العائدين |
| الموسمية (Seasonality) | أنماط منتظمة مرتبطة بوقت السنة (مثل العودة إلى المدارس، والعطلات) |
18. تأمّل
فكّر في رقم تتابعه في حياتك (الخطوات، أو ساعات المذاكرة، أو المدخرات، أو المتابعين). هل هو أقرب إلى مؤشر أداء رئيسي أم إلى مقياس تباهٍ بالنسبة لما تريد تحقيقه فعلًا؟ وما المؤشر الأفضل؟
19. الخطوة التالية
تكتمل U02 بعد تقييم نهاية الوحدة U02: ستحصل على حالة عمل، وتحدد هدفًا، ومجموعة مقاييس متماسكة، وأسئلة تشخيصية. بعدها تأتي U03 — الذكاء الاصطناعي في العمل مع البيانات، حيث ستتعلم استخدام أدوات الذكاء الاصطناعي بمسؤولية وبعمق. ويشمل ذلك كتابة طلبات غنية بالسياق، واكتشاف أخطاء الذكاء الاصطناعي في نوع التفكير التجاري نفسه الذي تدرّبت عليه هنا.
20. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| اختيار المقاييس، الجزء A (A1–A4) | التمييز بين مؤشر الأداء ومقياس التباهي ومقياس الحماية، ومتطلبات التعريف | 3 إجابات صحيحة أو أكثر من 4 |
| اختيار المقاييس، الجزء B (1–8) | تصنيف المقاييس بالنسبة لهدف | 6 أو أكثر من 8، مع قبول البدائل المبرَّرة |
| مهمة العمل (خمسة أسئلة تشخيصية) | تحويل مشكلة غامضة إلى أسئلة قابلة للقياس | معايير L08-WT |
| التدريب الموجَّه والمستقل، والتحدي القصير | بطاقات مؤشرات الأداء ونقل المهارة | معايير L08-IP وL08-MC |
المراجع
- Amazon Web Services. AWS CAF Business Perspective — Business insights. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/business-insights.html (فُتحت وروجعت في 11 أكتوبر 2026). يدعم: تحديد قرارات العمل التي تحتاج إلى استنتاجات عالية الجودة؛ ومتابعة المقاييس لقياس الأداء وتجربة العملاء؛ وأتمتة متابعة مؤشرات الأداء؛ وملاحظة الرجوع التاريخي.
- الفروق بين مؤشر الأداء والمقاييس المساعدة ومقاييس الحماية ومقاييس التباهي، وبطاقة مؤشر الأداء، تعريفات تعليمية من D.World. وهي شائعة في ممارسة التحليلات، لكن لم يُستشهد بمعيار خارجي واحد لها (راجع سجل المصادر).
- D.World Curriculum Map v1.0 (صف L08) وCurriculum Bible v1.0. وثائق داخلية.
U02 Exit Assessment — Business Foundations for Data Professionalsتقييم نهاية الوحدة U02 — أساسيات الأعمال لمحترفي البيانات Freeمجاني
U02 Exit Assessment — Business Foundations for Data Professionals
Learner-facing instructions and rubric. Model answers and marking notes are in the instructor-only file (05). Version: U02 v1.0 · 11 October 2026.
Unit exit criterion (D.World map): Given a business scenario, define a goal, metric set, and diagnostic questions.
Estimated time: 75 minutes (provisional) · Format: written brief, 500–800 words (tables allowed) · Allowed: your U02 notes, a calculator, and an AI assistant only as described in Part F. Use the synthetic data below only.
The case (fictional business, synthetic data)
Kestrel Cycle Supply is a fictional online shop selling bicycle accessories. The owner writes:
"We're growing fast: more visitors, more orders, more followers. But cash feels tight. Should we keep doubling our advertising?"
Quarterly data (synthetic)
| Metric | Q1 | Q2 |
|---|---|---|
| Sessions | 30,000 | 45,000 |
| Orders | 900 | 1,200 |
| Revenue (USD, after discounts) | 36,000 | 43,200 |
| COGS (USD) | 21,600 | 28,080 |
| Advertising aimed at new customers (USD) | 6,000 | 12,000 |
| Other operating expenses (USD) | 7,000 | 7,000 |
| New customers acquired | 300 | 400 |
| Social-media followers (end of quarter) | 2,000 | 6,500 |
Assumptions given by the owner: no loans, no taxes considered (simplified net profit). A typical customer places 2 orders over 2 years.
What to submit
Part A — Calculations. Show your working for both quarters: - revenue growth (%); - gross profit and gross margin; - simplified net profit (gross profit − advertising − other operating expenses); - overall conversion and AOV; - CAC and LTV (simple gross-profit version), plus value per new customer.
Part B — Business goal. Write one specific goal with a time frame that responds to the owner's situation. Name the decision it supports.
Part C — Metric set. - One KPI with a full definition card: name, formula, scope/denominator, target and time frame, owner. - Three to five supporting metrics, each with a one-line definition. - At least one guardrail metric. - Identify one vanity metric in the owner's message or the data, and explain why it should not be the KPI.
Part D — Diagnostic questions. Write at least five diagnostic data questions that would help explain what is happening. Cover at least three of these: - comparison; - formula parts; - segments; - funnel steps; - data quality.
Part E — Interpretation. In 4–6 sentences, explain what the numbers suggest about growth vs profit. Label any explanation that is a hypothesis, and do not state causes as facts.
Part F — AI-use note. If you used AI, write 2–3 lines on what it was used for, what you checked and what remained your judgment. If you did not use AI, write "No AI used."
Rubric (each criterion 0–2)
| # | Criterion | 2 — Meets | 1 — Partly | 0 — Not yet |
|---|---|---|---|---|
| C1 | Calculations (Part A) | All values correct, with working; units and percentages right | 1–2 minor errors that do not change conclusions | Several errors, or errors that reverse the conclusion |
| C2 | Goal and decision (Part B) | Specific, time-bound goal that responds to the case; decision stated | Goal vague or not linked to a decision | No goal, or a goal unrelated to the case |
| C3 | KPI definition (Part C) | KPI tied to the goal; complete definition card with denominator, period, target, owner | KPI sensible but the definition incomplete | KPI is a vanity metric or unrelated to the goal |
| C4 | Metric set coherence (Part C) | Supporting metrics explain the KPI; guardrail present and sensible; vanity metric correctly identified with reason | One element missing or weak | Set is a random list, or vanity metric not recognized |
| C5 | Diagnostic questions (Part D) | At least 5 specific, data-answerable questions covering at least 3 categories | Questions vague, fewer than 5, or only 1–2 categories | Questions are not answerable with data |
| C6 | Interpretation and responsible reasoning (Parts E–F) | Distinguishes revenue growth from profit and value per customer; hypotheses labelled; AI-use note present | Some confusion of revenue and profit, or a hypothesis stated too strongly | Treats revenue growth as success without checking profit, or states causes as facts |
Gate conditions (all must be met to pass)
- G1: The KPI is tied to the stated goal and is not a vanity metric.
- G2: Part A shows Q2 simplified net profit correctly (sign and approximate value).
- G3: No cause is stated as a proven fact without evidence.
Result
- PASS: a total of 9 or more out of 12, no criterion scored 0, all gates met.
- REVISE: anything else; feedback names the criteria to improve, and one resubmission is allowed.
Why this threshold? It requires solid performance overall (75%) while allowing small weaknesses in one or two areas. The gates protect the skills that matter most in this unit: correct profit reasoning, KPI-goal alignment, and not over-claiming causes. The threshold is a design judgment, not statistically validated. It should be reviewed after learner pilot data is available.
This assessment checks understanding of U02 concepts. It is not a certification and makes no claim about job readiness.
تقييم نهاية الوحدة U02 — أساسيات الأعمال لمحترفي البيانات
تعليمات ومعايير تقييم موجّهة للمتعلّم. الإجابات النموذجية وملاحظات التصحيح موجودة في ملف المدرّس فقط (05). الإصدار: U02 v1.0 · 11 أكتوبر 2026.
معيار إنهاء الوحدة (خريطة D.World): في سيناريو عمل معطى، حدِّد هدفًا ومجموعة مقاييس وأسئلة تشخيصية.
الوقت المتوقع: 75 دقيقة (مبدئي) · الشكل: مذكرة مكتوبة من 500 إلى 800 كلمة (يُسمح بالجداول) · المسموح: ملاحظاتك من U02، وآلة حاسبة، ومساعد ذكاء اصطناعي فقط بالطريقة الموضحة في الجزء F. استخدم البيانات المصطنعة التالية فقط.
الحالة (نشاط خيالي، بيانات مصطنعة)
Kestrel Cycle Supply متجر خيالي على الإنترنت يبيع إكسسوارات الدراجات. يكتب صاحب المتجر:
"نحن ننمو بسرعة: زوار أكثر، وطلبات أكثر، ومتابعون أكثر. لكن السيولة تبدو ضيقة. هل نستمر في مضاعفة الإنفاق على الإعلانات؟"
بيانات ربع سنوية (مصطنعة)
| المقياس | Q1 (الربع الأول) | Q2 (الربع الثاني) |
|---|---|---|
| الجلسات | 30,000 | 45,000 |
| الطلبات | 900 | 1,200 |
| الإيرادات (بالدولار، بعد الخصومات) | 36,000 | 43,200 |
| COGS (بالدولار) | 21,600 | 28,080 |
| الإعلانات الموجّهة للعملاء الجدد (بالدولار) | 6,000 | 12,000 |
| مصروفات التشغيل الأخرى (بالدولار) | 7,000 | 7,000 |
| العملاء الجدد المكتسبون | 300 | 400 |
| متابعو وسائل التواصل (في نهاية الربع) | 2,000 | 6,500 |
افتراضات من صاحب المتجر: لا قروض، ولا ضرائب في الحساب (صافي ربح مبسّط). العميل المعتاد يطلب طلبين خلال سنتين.
ما الذي تسلّمه
الجزء A — الحسابات. اعرض خطوات الحل للربعين:
- نمو الإيرادات (%)؛
- مجمل الربح وهامش الربح الإجمالي؛
- صافي الربح المبسّط (مجمل الربح − الإعلانات − مصروفات التشغيل الأخرى)؛
- التحويل الإجمالي وAOV؛
- CAC وLTV (بالصيغة البسيطة المبنية على مجمل الربح)، والقيمة لكل عميل جديد.
الجزء B — هدف العمل. اكتب هدفًا واحدًا محددًا وله إطار زمني، يستجيب لوضع صاحب المتجر. وسمِّ القرار الذي يدعمه.
الجزء C — مجموعة المقاييس.
- مؤشر أداء رئيسي (KPI) واحد ببطاقة تعريف كاملة: الاسم، والمعادلة، والنطاق/المقام، والقيمة المستهدفة والإطار الزمني، والمسؤول.
- من ثلاثة إلى خمسة مقاييس مساعدة، لكل منها تعريف في سطر واحد.
- مقياس حماية واحد على الأقل.
- حدِّد مقياس تباهٍ واحدًا في رسالة صاحب المتجر أو في البيانات، واشرح لماذا لا ينبغي أن يكون هو مؤشر الأداء الرئيسي.
الجزء D — الأسئلة التشخيصية. اكتب خمسة أسئلة بيانات تشخيصية على الأقل تساعد على تفسير ما يحدث. وغطِّ ثلاث فئات على الأقل من هذه الفئات:
- المقارنة؛
- أجزاء المعادلة؛
- الشرائح؛
- خطوات مسار التحويل؛
- جودة البيانات.
الجزء E — التفسير. في 4–6 جمل، اشرح ما تشير إليه الأرقام عن النمو مقابل الربح. وصِف أي تفسير هو فرضية بأنه فرضية، ولا تذكر الأسباب على أنها حقائق.
الجزء F — ملاحظة استخدام الذكاء الاصطناعي. إذا استخدمت الذكاء الاصطناعي، فاكتب سطرين أو ثلاثة عن الغرض من استخدامه، وما الذي راجعته، وما الذي بقي حكمك أنت. وإذا لم تستخدمه، فاكتب "No AI used" (لم أستخدم الذكاء الاصطناعي).
معايير التقييم (كل معيار من 0 إلى 2)
| # | المعيار | 2 — يحقق المطلوب | 1 — يحققه جزئيًا | 0 — لم يحققه بعد |
|---|---|---|---|---|
| C1 | الحسابات (الجزء A) | كل القيم صحيحة، مع خطوات الحل؛ والوحدات والنسب المئوية صحيحة | خطأ أو خطآن بسيطان لا يغيّران الخلاصات | أخطاء عديدة، أو أخطاء تقلب الخلاصة |
| C2 | الهدف والقرار (الجزء B) | هدف محدد ومقيد بزمن يستجيب للحالة؛ والقرار مذكور | الهدف غامض أو غير مرتبط بقرار | لا يوجد هدف، أو الهدف لا علاقة له بالحالة |
| C3 | تعريف مؤشر الأداء (الجزء C) | المؤشر مرتبط بالهدف؛ وبطاقة التعريف كاملة بالمقام والفترة والقيمة المستهدفة والمسؤول | المؤشر معقول لكن التعريف ناقص | المؤشر مقياس تباهٍ أو لا علاقة له بالهدف |
| C4 | تماسك مجموعة المقاييس (الجزء C) | المقاييس المساعدة تفسّر المؤشر؛ ومقياس الحماية موجود ومعقول؛ ومقياس التباهي محدد بشكل صحيح مع السبب | عنصر واحد ناقص أو ضعيف | المجموعة قائمة عشوائية، أو لم يُتعرَّف على مقياس التباهي |
| C5 | الأسئلة التشخيصية (الجزء D) | 5 أسئلة على الأقل، محددة ويمكن الإجابة عنها بالبيانات، وتغطي 3 فئات على الأقل | الأسئلة غامضة، أو أقل من 5، أو من فئة أو فئتين فقط | الأسئلة لا يمكن الإجابة عنها بالبيانات |
| C6 | التفسير والتفكير المسؤول (الجزءان E–F) | يميّز بين نمو الإيرادات والربح والقيمة لكل عميل؛ والفرضيات موصوفة بأنها فرضيات؛ وملاحظة استخدام الذكاء الاصطناعي موجودة | بعض الخلط بين الإيرادات والربح، أو فرضية مذكورة بقوة زائدة | يعامل نمو الإيرادات على أنه نجاح دون مراجعة الربح، أو يذكر الأسباب على أنها حقائق |
شروط أساسية (يجب تحقيقها كلها للنجاح)
- G1: مؤشر الأداء الرئيسي مرتبط بالهدف المذكور، وليس مقياس تباهٍ.
- G2: يُظهر الجزء A صافي الربح المبسّط للربع Q2 بشكل صحيح (الإشارة والقيمة التقريبية).
- G3: لا يُذكر أي سبب على أنه حقيقة مثبتة دون دليل.
النتيجة
- PASS (ناجح): مجموع 9 أو أكثر من 12، ولا يوجد معيار حصل على 0، وكل الشروط الأساسية متحققة.
- REVISE (يحتاج تعديلًا): أي نتيجة أخرى؛ وتحدد الملاحظات المعايير التي تحتاج إلى تحسين، ويُسمح بإعادة التسليم مرة واحدة.
لماذا هذا الحد؟ لأنه يتطلب أداءً قويًا في المجمل (75%) مع السماح بنقاط ضعف صغيرة في مجال أو مجالين. والشروط الأساسية تحمي أهم المهارات في هذه الوحدة: التفكير الصحيح في الربح، وارتباط مؤشر الأداء بالهدف، وعدم المبالغة في ادعاء الأسباب. هذا الحد حكم تصميمي، وليس مُثبتًا إحصائيًا، ويجب مراجعته بعد توفر بيانات التجربة مع المتعلّمين.
هذا التقييم يقيس فهمك لمفاهيم U02. وهو ليس شهادة معتمدة، ولا يدّعي أي شيء عن جاهزيتك للعمل.
U03 · AI for Data Workالذكاء الاصطناعي في العمل مع البيانات
Stage 1المرحلة 1Free: every lesson in this unit.
مجاني: كل دروس هذه الوحدة.
L09 · AI, Generative AI & LLMs for Data WorkL09 · الذكاء الاصطناعي والذكاء الاصطناعي التوليدي والنماذج اللغوية الكبيرة في العمل مع البيانات Freeمجاني
L09 — AI, Generative AI & LLMs for Data Work
Learner file. Answers and model solutions are in a separate instructor-only file. Version: U03 v1.0 · Content date: 12 October 2026. Time estimates are provisional until learner-tested.
1. Lesson Identity
| Field | Value |
|---|---|
| Title | AI, Generative AI & LLMs for Data Work |
| Stage | Stage 1 — Foundations |
| Unit | U03 — AI for Data Work |
| Lesson ID | L09 |
| Skills | AI literacy; terminology |
| Difficulty | Beginner |
| Estimated time | About 1 hour 40 minutes (provisional) |
| Prerequisites | U01 (especially L02: observation vs hypothesis, and L04: where AI fits in the workflow). U02 metrics (revenue, conversion, AOV, gross margin) are used in examples. No coding needed. |
Time breakdown (provisional): concept and worked example, 30 min · guided practice, 15 min · independent practice, 15 min · knowledge check, 10 min · AI in Practice and Verification, 15 min · workplace task, 10 min · mini challenge, 5 min.
2. Learning Objective
By the end of this lesson, you will be able to explain the role and limits of generative AI and large language models (LLMs) in data work, and classify claims in an AI response as supported by the input, a calculation to check, or unsupported.
D.World map objective (verbatim): Explain the role and limits of generative AI/LLMs in data work.
3. Why It Matters
AI assistants can write a summary, an explanation or a piece of code in seconds. That speed is useful. But the text they produce sounds equally confident whether it is right or wrong.
In data work, a wrong number or an invented "fact" can travel from an AI chat into a report and then into a business decision. To use AI well, you need an accurate picture of what these tools do, and what they do not do. Key principle: AI output is generated, not automatically verified.
4. Concept
Three terms, from broad to narrow
- Artificial intelligence (AI): a broad term for computer systems that perform tasks we associate with human intelligence, such as recognising patterns, making predictions or producing language.
- Generative AI: AI systems that create new content (text, images, code, audio) based on patterns learned from training data.
- Large language model (LLM): a type of generative AI trained on very large amounts of text. In simple terms, it produces text by repeatedly predicting a likely next piece of text (a token) given everything before it. Chat assistants are usually built on LLMs.
What this means for data work
An LLM generates plausible text. Plausible is not the same as verified:
| An LLM is… | An LLM is not automatically… |
|---|---|
| A fast drafter of explanations, summaries, code and plans | A database of checked facts |
| Good at re-wording, structuring and brainstorming | Aware of your business data unless you provide it (or a connected tool gives it access) |
| Able to produce code and SQL that often looks correct | A guarantee that the code runs or gives the right answer |
| Able to propose hypotheses | Evidence that a hypothesis is true |
Common limits (general, not tool-specific)
- Confabulation ("hallucination"). NIST defines confabulation as "the production of confidently stated but erroneous or false content" and notes it is known colloquially as "hallucinations" or "fabrications" (NIST AI 600-1). Examples: an invented statistic, a made-up source, a reason that is not in the data.
- Calculation slips. An answer may contain arithmetic or formula errors, even when the method sounds right.
- Knowledge limits. A model learns from data up to some point in time. Unless the product connects it to search or other tools, it may not know recent facts. Products differ, and features change over time.
- Variation. The same question can produce different answers on different attempts, and small wording changes can change the output.
- Missing context. The model only knows what you tell it (plus general patterns). If key information is missing, it may fill the gap with something plausible instead of asking.
Not all AI tools behave the same. Some can run code, search the web or read files; others cannot. Always check what your specific tool can do, and treat claims about its features as dated.
Supported, check, or unsupported?
When you read an AI response about data, label each claim:
- Supported by the input: you can point to where the input shows it.
- Calculation to check: derived from the input, so recompute it yourself.
- Unsupported: not in the input and not derivable from it. Examples: invented benchmarks, causes, predictions or sources. Remove it, or turn it into a clearly labelled hypothesis to test.
5. Worked Example
Fictional business, synthetic data. Cedar Lane (the online stationery store from U01–U02) gave an AI assistant this input:
October: 20,000 sessions; 600 orders; revenue 15,000 USD; gross margin 50%.
The response below is illustrative. D.World wrote it to show typical problems; it is not output from any specific tool.
"In October, Cedar Lane had 20,000 sessions and 600 orders. Its conversion rate was 3%, and its average order value was 25 USD. Gross profit was 7,500 USD. This conversion rate is above the e-commerce industry average of 2.5%. Most customers came from Instagram, and revenue grew 12% compared with September."
Claim check:
| # | Claim | Label | Reasoning |
|---|---|---|---|
| 1 | 20,000 sessions and 600 orders | Supported | Both are in the input |
| 2 | Conversion 3% | Calculation to check | 600 ÷ 20,000 = 0.03 = 3% ✔ |
| 3 | AOV 25 USD | Calculation to check | 15,000 ÷ 600 = 25 ✔ |
| 4 | Gross profit 7,500 USD | Calculation to check | 15,000 × 50% = 7,500 ✔ |
| 5 | "Above the industry average of 2.5%" | Unsupported | No source given; benchmarks need a credible, dated source with context (U02 rule) |
| 6 | "Most customers came from Instagram" | Unsupported | No traffic-source data in the input |
| 7 | "Revenue grew 12% vs September" | Unsupported | No September figure in the input |
Three claims needed recalculation, and all three were correct this time. Three claims were invented, yet they sound just as confident as the correct ones. A reader who skimmed the response would likely repeat all seven.
6. Visual Explanation
YOUR INPUT ──► LLM generates likely text ──► RESPONSE
(data, question) (patterns, not checking) |
▼
┌──────── You label every claim ────────┐
│ Supported │ Calculation │ Unsupported │
│ (point │ (recompute │ (remove or │
│ to input)│ it) │ label as │
│ │ │ hypothesis)│
└───────────────────────────────────────┘
▼
Only verified claims reach a decision
Alt text: A left-to-right flow. Your input (data and a question) goes into an LLM, which generates likely text from patterns without checking it, producing a response. Below the response, a box shows three labels you apply to every claim: supported (point to the input), calculation (recompute it), and unsupported (remove it or label it as a hypothesis). An arrow leads to the final line: only verified claims reach a decision.
7. Guided Practice
Input (fictional, synthetic): Cedar Lane, November: 25,000 sessions; 750 orders; revenue 18,000 USD.
Illustrative AI-style response (written by D.World):
"November had 25,000 sessions and 750 orders, a conversion rate of 3%. Average order value was 24 USD. Revenue rose because of Black Friday promotions. Customers who arrive via email convert twice as well as other customers. November revenue was 18,000 USD."
- Split the response into separate claims (there are six). (Hint: "25,000 sessions and 750 orders" is one claim; the conversion rate is another.)
- Label each claim Supported, Calculation to check or Unsupported.
- Recompute every calculation and mark ✔ or ✘.
- Rewrite any unsupported causal claim as a hypothesis with the data needed to test it.
8. Independent Practice
Input (fictional, synthetic): Hilltop Honey, August: 400 jars sold at 10 USD each; unit cost 4 USD per jar.
Illustrative AI-style response (written by D.World):
"Hilltop Honey sold 400 jars, for revenue of 4,000 USD. Its gross margin was 40%. This margin is higher than most food producers achieve. Sales will grow 20% next month because honey season is starting."
- Label each claim and recompute every calculation.
- For each problem, write one sentence explaining why an LLM might produce it (use the limits in Section 4).
- Write a corrected two-sentence summary that contains only claims you have checked.
No model answer is shown here.
9. Knowledge Check — Concept Check
Choose the best answer.
1. Which statement best describes how an LLM produces an answer? - A) It looks up the answer in a verified database of facts. - B) It generates likely text from patterns learned in training, given your input. - C) It always runs a calculation before writing any number. - D) It copies the answer from the most popular web page.
2. An AI response contains a precise statistic with no source. What should you do first? - A) Accept it, because precise numbers are usually researched. - B) Ask the same AI whether it is sure, and accept a "yes". - C) Remove it from your report because all AI numbers are wrong. - D) Treat it as unsupported until you find a credible, dated source or can derive it from your data.
3. Which task is the best fit for an AI assistant, with normal checking? - A) Drafting a plain-English explanation of what "gross margin" means - B) Deciding which customer accounts to close - C) Reporting the exact revenue figure from a system the AI cannot access - D) Confirming that a supplier's contract is legally valid
4. "Generative AI" is best described as… - A) any software that uses a spreadsheet. - B) a database of verified answers. - C) AI that creates new content, such as text, images or code, from learned patterns. - D) a system that only classifies images.
5. You ask the same question twice and get two different answers. What does this most likely show? - A) The tool is broken and should never be used. - B) Outputs can vary, so important results need independent checking. - C) The second answer is always the correct one. - D) The first answer was copied from the internet.
6. Which response from an AI assistant should make you most cautious? - A) "I don't have September data, so I can't compare months." - B) "Here is the formula I used: revenue ÷ orders." - C) "Revenue fell because a competitor lowered prices," when your input contained no competitor data. - D) "Please check this calculation against your own records."
10. AI in Practice
Ask an AI assistant (use no real company or personal data):
"I am a beginner learning data analysis. In a table, compare what large language models are typically good at and what their common limitations are when helping with data work. For each row, give one example. Then list any claims in your own answer that I should verify against an authoritative source, and say why."
Then pick three claims from the response and verify each one against the NIST Generative AI Profile (Resources) or this lesson. Mark each Confirmed, Not confirmed or Contradicted.
Why this can help: a comparison table gives you a quick overview. Asking the AI to flag its own claims shows where checking is needed. That list is a starting point, not a substitute for your own check.
11. AI Verification
- Claim by claim: split the response into individual claims; never verify "the whole thing" at once.
- Source check: for each claim you chose, find the matching statement in the NIST Profile or this lesson. If you cannot find it, mark it Not confirmed, not "true".
- Watch for absolutes: words like "always", "never", "all models" or "guaranteed" usually signal an over-general claim. Tools differ and change.
- Dates and features: treat claims about specific products, model versions or "latest" features as dated, and check the vendor's current documentation.
- Self-checks are not evidence: an AI saying "I am confident" does not verify anything.
- Privacy: use only general questions and synthetic data. Do not paste real customer or company data into public AI tools; follow your organization's policy and applicable law.
12. Business Lens
Decide which data tasks are good candidates for AI assistance. AI is an accelerator, not a decision authority. A quick way to judge a task is to ask five questions:
| Question | Points toward "good candidate" | Points toward "use with caution" or "do not use" |
|---|---|---|
| 1. Can I check the output? | Yes, easily (recalculate, run, compare with source) | Hard or impossible to verify |
| 2. What data must I share? | None, public, or synthetic data | Personal, confidential or secret data |
| 3. How high is the impact if it is wrong? | Low; a draft a human will edit | High: money, people, legal, safety |
| 4. Does the AI have what it needs? | All needed input is in the prompt | Needs access to systems or facts it does not have |
| 5. Am I supposed to be learning this skill? | No, or AI helps me understand it | Yes, and AI would replace my practice |
A task can be a good candidate, a candidate with conditions (e.g., synthetic data only, expert review), or not suitable.
13. Workplace Task — AI-Assistance Triage
Fictional business: Cedar Lane. The owner lists seven tasks and asks, "Where can AI help us?" For each, choose Good candidate, With conditions (state them) or Not suitable, and give a one-line reason using the five questions in Section 12.
| # | Task |
|---|---|
| a | Draft a friendly email telling customers that deliveries will be delayed by two days |
| b | Explain to a new team member what "conversion rate" means |
| c | Decide which staff member to let go, using their performance reviews |
| d | Summarize 40 synthetic, anonymised product reviews into themes |
| e | Paste the full customer list (names, emails, addresses) into a free public chatbot to find duplicates |
| f | Report last month's exact revenue from the store's accounting system, which the AI cannot access |
| g | Brainstorm possible reasons why conversion fell in December |
14. Mini Challenge
Fictional business: Riverside Bikes, a small bike-repair shop. The manager wants to use an AI assistant for: (1) writing social-media posts about opening hours; (2) estimating next month's spare-parts order from last year's sales file; (3) answering customers' questions about warranty rights in their country.
- Classify each use as Good candidate / With conditions / Not suitable.
- For each, name the main risk and one verification step.
- In two sentences, explain to the manager the difference between "the AI wrote it" and "it is correct".
Submit before feedback. No solution is provided here.
15. Resources
- Required (about 15 min): NIST, Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile (NIST AI 600-1, July 2024). Read the abstract on the publication page. In the PDF, find the list of 12 risks in Section 2 and read the short descriptions of Confabulation and Data Privacy. Publication page: https://www.nist.gov/publications/artificial-intelligence-risk-management-framework-generative-artificial-intelligence · PDF: https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.600-1.pdf (Both opened and checked 12 Oct 2026.)
- Recommended: the U01 L04 workflow diagram. Mark where an AI assistant could help, and where a human must check.
- Deeper (optional): AI for Everyone (DeepLearning.AI), a course its page describes as non-technical. See Section 16.
16. Person to Follow / Role Model
Andrew Ng (mapped by D.World for U03).
- Verified facts (12 Oct 2026): the DeepLearning.AI course pages list him as "Founder, DeepLearning.AI; Co-founder, Coursera". He is the listed instructor of AI for Everyone, which its course page describes as "a non-technical course". https://www.deeplearning.ai/courses/ai-for-everyone/
- Why D.World recommends him: clear, practical AI education aimed at helping people understand where AI can and cannot be applied.
- Try this: open the AI for Everyone course page and, if it is available to you, watch the opening material. Access terms are set by the provider and may change; no purchase is required for this lesson. Note one example of a task that is a good fit for AI and one that is not, and compare them with your Section 13 answers.
Roles change over time; check his own pages for current details.
17. Glossary
| Term | Meaning in this lesson |
|---|---|
| Artificial intelligence (AI) | Broad term for computer systems performing tasks associated with human intelligence |
| Generative AI | AI that creates new content (text, images, code) from learned patterns |
| Large language model (LLM) | Generative AI trained on large amounts of text; produces text by predicting likely next tokens |
| Token | A small piece of text (a word or part of a word) that an LLM processes |
| Prompt | The instructions and input you give an AI tool |
| Confabulation / hallucination | Confidently stated but false or unsupported content (NIST term: confabulation) |
| Supported claim | A claim you can point to in the input |
| Unsupported claim | A claim not in the input and not derivable from it |
| Training data | The data a model learned its patterns from |
18. Reflection
Before this lesson, when an AI answer sounded confident, how did you decide whether to trust it? What one habit will you now use every time AI gives you a number?
19. Next Step
You now know why AI output must be checked. In L10 — Prompting: Context, Constraints & Examples, you will learn how to write prompts as clear specifications. Good prompts give the AI the right input, so you get fewer invented gaps and output that is easier to verify.
20. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Concept check (Q1–Q6) | Understands what LLMs do and their limits | 5 or more of 6 correct |
| Guided and independent practice (claim labelling) | Separates supported, calculated and unsupported claims | Rubrics L09-GP and L09-IP |
| Workplace task (AI triage) | Judges suitability of tasks for AI assistance | Rubric L09-WT |
| AI in Practice record and mini challenge | Verifies AI claims against a source; explains risk | Rubrics L09-AI and L09-MC |
References
- NIST. Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile (NIST AI 600-1), published 26 July 2024 (page updated 8 April 2026). https://www.nist.gov/publications/artificial-intelligence-risk-management-framework-generative-artificial-intelligence and https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.600-1.pdf (both opened and checked 12 Oct 2026). Supports: definition of confabulation and its colloquial names; the list of 12 GAI risks including Confabulation and Data Privacy.
- DeepLearning.AI. AI for Everyone course page. https://www.deeplearning.ai/courses/ai-for-everyone/ (opened and checked 12 Oct 2026). Supports: instructor and role description; "non-technical course".
- The "supported / calculation / unsupported" labels and the five-question triage are D.World teaching tools, not an external standard.
- D.World Curriculum Map v1.0 (L09 row) and Curriculum Bible v1.0 (AI Integration Standard). Internal.
L09 — الذكاء الاصطناعي والذكاء الاصطناعي التوليدي والنماذج اللغوية الكبيرة في العمل مع البيانات
ملف المتعلّم. الإجابات والحلول النموذجية في ملف منفصل خاص بالمدرّس فقط. الإصدار: U03 v1.0 · تاريخ المحتوى: 12 أكتوبر 2026. تقديرات الوقت مبدئية إلى أن تُجرَّب مع المتعلّمين.
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | الذكاء الاصطناعي والذكاء الاصطناعي التوليدي والنماذج اللغوية الكبيرة في العمل مع البيانات |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U03 — الذكاء الاصطناعي في العمل مع البيانات |
| رقم الدرس | L09 |
| المهارات | الوعي بالذكاء الاصطناعي؛ المصطلحات |
| المستوى | مبتدئ |
| الوقت المتوقع | حوالي ساعة و40 دقيقة (مبدئي) |
| المتطلبات السابقة | U01 (خاصة L02: الملاحظة مقابل الفرضية، وL04: أين يدخل الذكاء الاصطناعي في سير العمل). مقاييس U02 (الإيرادات، والتحويل، وAOV، وهامش الربح الإجمالي) مستخدمة في الأمثلة. لا تحتاج إلى البرمجة. |
تفصيل الوقت (مبدئي): المفهوم والمثال المحلول 30 دقيقة · التدريب الموجَّه 15 دقيقة · التدريب المستقل 15 دقيقة · اختبار الفهم 10 دقائق · الذكاء الاصطناعي في التطبيق والتحقق 15 دقيقة · مهمة العمل 10 دقائق · التحدي القصير 5 دقائق.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تشرح دور الذكاء الاصطناعي التوليدي والنماذج اللغوية الكبيرة (LLMs) وحدودها في العمل مع البيانات، وأن تصنّف الادعاءات في رد الذكاء الاصطناعي إلى: مدعوم بالمدخلات، أو حساب يجب التحقق منه، أو غير مدعوم.
هدف خريطة D.World (بنصه): Explain the role and limits of generative AI/LLMs in data work.
3. لماذا يهمّك هذا؟
مساعدات الذكاء الاصطناعي تستطيع كتابة ملخص أو شرح أو جزء من الكود في ثوانٍ. هذه السرعة مفيدة. لكن النص الذي تنتجه يبدو واثقًا بالقدر نفسه سواء كان صحيحًا أم خاطئًا.
في العمل مع البيانات، يمكن لرقم خاطئ أو "حقيقة" مخترعة أن تنتقل من محادثة مع الذكاء الاصطناعي إلى تقرير، ثم إلى قرار عمل. ولكي تستخدم الذكاء الاصطناعي جيدًا، تحتاج إلى صورة دقيقة لما تفعله هذه الأدوات، وما لا تفعله. المبدأ الأساسي: مخرجات الذكاء الاصطناعي مولَّدة، وليست متحققًا منها تلقائيًا.
4. المفهوم
ثلاثة مصطلحات، من الأوسع إلى الأضيق
- الذكاء الاصطناعي (Artificial intelligence, AI): مصطلح واسع يشمل الأنظمة الحاسوبية التي تؤدي مهام نربطها بالذكاء البشري، مثل التعرّف على الأنماط، أو التنبؤ، أو إنتاج اللغة.
- الذكاء الاصطناعي التوليدي (Generative AI): أنظمة ذكاء اصطناعي تنشئ محتوى جديدًا (نصوصًا، وصورًا، وكودًا، وصوتًا) اعتمادًا على أنماط تعلّمتها من بيانات التدريب.
- النموذج اللغوي الكبير (Large language model, LLM): نوع من الذكاء الاصطناعي التوليدي دُرِّب على كميات ضخمة جدًا من النصوص. وبعبارة بسيطة، ينتج النص بأن يتنبأ مرة بعد مرة بالجزء التالي المرجّح من النص (ويسمى token) بناءً على كل ما سبقه. ومساعدات المحادثة مبنية عادةً على نماذج لغوية كبيرة.
ماذا يعني هذا للعمل مع البيانات
النموذج اللغوي الكبير يولّد نصًا معقولًا. والمعقول ليس هو نفسه المتحقَّق منه:
| النموذج اللغوي الكبير… | النموذج اللغوي الكبير ليس تلقائيًا… |
|---|---|
| كاتب سريع لمسودات الشروح والملخصات والكود والخطط | قاعدة بيانات لحقائق مراجَعة |
| جيد في إعادة الصياغة والتنظيم والعصف الذهني | مطّلعًا على بيانات عملك ما لم تقدّمها له (أو تمنحه أداة متصلة صلاحية الوصول إليها) |
| قادر على إنتاج كود وSQL يبدو صحيحًا في أغلب الأحيان | ضمانًا بأن الكود يعمل أو يعطي الإجابة الصحيحة |
| قادر على اقتراح فرضيات | دليلًا على أن الفرضية صحيحة |
حدود شائعة (عامة، لا تخص أداة بعينها)
- الاختلاق (Confabulation) أو "الهلوسة". تعرّف NIST الاختلاق بأنه "the production of confidently stated but erroneous or false content" (إنتاج محتوى خاطئ أو زائف يُقال بثقة)، وتذكر أنه معروف بالعامية باسم "hallucinations" أو "fabrications" (NIST AI 600-1). أمثلة: إحصائية مخترعة، أو مصدر مختلق، أو سبب غير موجود في البيانات.
- أخطاء الحساب. قد تحتوي الإجابة على أخطاء حسابية أو أخطاء في المعادلات، حتى عندما تبدو الطريقة صحيحة.
- حدود المعرفة. يتعلم النموذج من بيانات حتى نقطة زمنية معيّنة. وما لم يربطه المنتج بالبحث أو بأدوات أخرى، فقد لا يعرف الحقائق الحديثة. والمنتجات تختلف، والخصائص تتغير مع الوقت.
- التباين. السؤال نفسه قد يعطي إجابات مختلفة في محاولات مختلفة، وتغييرات بسيطة في الصياغة قد تغيّر المخرجات.
- نقص السياق. النموذج يعرف فقط ما تخبره به (إضافة إلى الأنماط العامة). وإذا كانت معلومة أساسية ناقصة، فقد يملأ الفراغ بشيء معقول بدلًا من أن يسأل.
ليست كل أدوات الذكاء الاصطناعي متشابهة. بعضها يستطيع تشغيل الكود، أو البحث في الإنترنت، أو قراءة الملفات، وبعضها لا يستطيع. تأكد دائمًا مما تستطيعه أداتك تحديدًا، وتعامل مع الادعاءات عن خصائصها على أنها مرتبطة بتاريخ معيّن.
مدعوم، أم يحتاج إلى تحقق، أم غير مدعوم؟
عندما تقرأ ردًا من الذكاء الاصطناعي عن البيانات، صنّف كل ادعاء:
- مدعوم بالمدخلات: تستطيع أن تشير إلى المكان الذي تُظهره فيه المدخلات.
- حساب يجب التحقق منه: مشتق من المدخلات، لذلك أعِد حسابه بنفسك.
- غير مدعوم: ليس في المدخلات ولا يمكن اشتقاقه منها. أمثلة: معايير مقارنة مخترعة، أو أسباب، أو تنبؤات، أو مصادر. احذفه، أو حوّله إلى فرضية موصوفة بوضوح لكي تختبرها.
5. مثال محلول
نشاط خيالي، وبيانات مصطنعة. أعطت Cedar Lane (المتجر الإلكتروني للأدوات المكتبية من U01–U02) مساعد ذكاء اصطناعي هذه المدخلات:
أكتوبر: 20,000 جلسة؛ 600 طلب؛ الإيرادات 15,000 دولار؛ هامش الربح الإجمالي 50%.
الرد التالي توضيحي. كتبته D.World لتُظهر مشكلات معتادة؛ وهو ليس مخرجات أداة بعينها.
"في أكتوبر، كان لدى Cedar Lane 20,000 جلسة و600 طلب. وكان معدل التحويل 3%، ومتوسط قيمة الطلب 25 دولارًا. وكان مجمل الربح 7,500 دولار. ومعدل التحويل هذا أعلى من متوسط قطاع التجارة الإلكترونية البالغ 2.5%. وأغلب العملاء جاؤوا من Instagram، وزادت الإيرادات 12% مقارنةً بسبتمبر."
فحص الادعاءات:
| # | الادعاء | التصنيف | السبب |
|---|---|---|---|
| 1 | 20,000 جلسة و600 طلب | مدعوم | كلاهما موجود في المدخلات |
| 2 | التحويل 3% | حساب يجب التحقق منه | 600 ÷ 20,000 = 0.03 = 3% ✔ |
| 3 | AOV يساوي 25 دولارًا | حساب يجب التحقق منه | 15,000 ÷ 600 = 25 ✔ |
| 4 | مجمل الربح 7,500 دولار | حساب يجب التحقق منه | 15,000 × 50% = 7,500 ✔ |
| 5 | "أعلى من متوسط القطاع البالغ 2.5%" | غير مدعوم | لا يوجد مصدر؛ ومعايير المقارنة تحتاج إلى مصدر موثوق ومؤرخ مع سياقه (قاعدة U02) |
| 6 | "أغلب العملاء جاؤوا من Instagram" | غير مدعوم | لا توجد بيانات عن مصادر الزيارات في المدخلات |
| 7 | "زادت الإيرادات 12% مقارنةً بسبتمبر" | غير مدعوم | لا يوجد رقم لشهر سبتمبر في المدخلات |
ثلاثة ادعاءات احتاجت إلى إعادة حساب، وكانت الثلاثة صحيحة هذه المرة. وثلاثة ادعاءات كانت مخترعة، ومع ذلك تبدو واثقة تمامًا مثل الادعاءات الصحيحة. والقارئ الذي يمر على الرد سريعًا سيكرر غالبًا الادعاءات السبعة كلها.
6. شرح بصري
YOUR INPUT ──► LLM generates likely text ──► RESPONSE
(data, question) (patterns, not checking) |
▼
┌──────── You label every claim ────────┐
│ Supported │ Calculation │ Unsupported │
│ (point │ (recompute │ (remove or │
│ to input)│ it) │ label as │
│ │ │ hypothesis)│
└───────────────────────────────────────┘
▼
Only verified claims reach a decision
وصف الرسم: تدفق من اليسار إلى اليمين. مدخلاتك (بيانات وسؤال) تدخل إلى النموذج اللغوي الكبير، الذي يولّد نصًا مرجّحًا من الأنماط دون أن يتحقق منه، فينتج ردًا. وتحت الرد مربع يعرض ثلاثة تصنيفات تطبقها على كل ادعاء: مدعوم (أشِر إلى المدخلات)، وحساب (أعِد حسابه)، وغير مدعوم (احذفه أو صنّفه فرضية). ويقود سهم إلى السطر الأخير: الادعاءات المتحقَّق منها فقط تصل إلى القرار.
7. تدريب موجَّه
المدخلات (خيالية، مصطنعة): Cedar Lane، نوفمبر: 25,000 جلسة؛ 750 طلبًا؛ الإيرادات 18,000 دولار.
رد توضيحي بأسلوب الذكاء الاصطناعي (كتبته D.World):
"كان في نوفمبر 25,000 جلسة و750 طلبًا، أي معدل تحويل 3%. وكان متوسط قيمة الطلب 24 دولارًا. وارتفعت الإيرادات بسبب عروض Black Friday. والعملاء الذين يصلون عبر البريد الإلكتروني يتحولون إلى مشترين بضعف معدل العملاء الآخرين. وكانت إيرادات نوفمبر 18,000 دولار."
- قسّم الرد إلى ادعاءات منفصلة (عددها ستة). (تلميح: "25,000 جلسة و750 طلبًا" ادعاء واحد؛ ومعدل التحويل ادعاء آخر.)
- صنّف كل ادعاء: مدعوم، أو حساب يجب التحقق منه، أو غير مدعوم.
- أعِد حساب كل عملية حسابية وضع علامة ✔ أو ✘.
- أعِد كتابة أي ادعاء سببي غير مدعوم على شكل فرضية، مع البيانات اللازمة لاختبارها.
8. تدريب مستقل
المدخلات (خيالية، مصطنعة): Hilltop Honey، أغسطس: بيع 400 برطمان بسعر 10 دولارات للبرطمان؛ وتكلفة البرطمان 4 دولارات.
رد توضيحي بأسلوب الذكاء الاصطناعي (كتبته D.World):
"باعت Hilltop Honey عدد 400 برطمان، بإيرادات 4,000 دولار. وكان هامش الربح الإجمالي 40%. وهذا الهامش أعلى مما يحققه أغلب منتجي الأغذية. وستزيد المبيعات 20% الشهر القادم لأن موسم العسل يبدأ."
- صنّف كل ادعاء وأعِد حساب كل عملية حسابية.
- لكل مشكلة، اكتب جملة واحدة تشرح لماذا قد ينتجها نموذج لغوي كبير (استخدم الحدود المذكورة في القسم 4).
- اكتب ملخصًا مصحّحًا من جملتين لا يحتوي إلا على ادعاءات تحققت منها.
لا توجد إجابة نموذجية هنا.
9. اختبار الفهم — مراجعة المفاهيم
اختر أفضل إجابة.
1. أي عبارة تصف على أفضل وجه كيف ينتج النموذج اللغوي الكبير إجابته؟ - A) يبحث عن الإجابة في قاعدة بيانات حقائق متحقَّق منها. - B) يولّد نصًا مرجّحًا من أنماط تعلّمها في التدريب، بناءً على مدخلاتك. - C) يجري دائمًا عملية حسابية قبل كتابة أي رقم. - D) ينسخ الإجابة من أكثر صفحة إنترنت شهرة.
2. رد من الذكاء الاصطناعي يحتوي على إحصائية دقيقة بلا مصدر. ماذا تفعل أولًا؟ - A) أقبلها، لأن الأرقام الدقيقة تكون عادةً مبنية على بحث. - B) أسأل الذكاء الاصطناعي نفسه هل هو متأكد، وأقبل إجابة "نعم". - C) أحذفها من تقريري لأن كل أرقام الذكاء الاصطناعي خاطئة. - D) أعاملها على أنها غير مدعومة حتى أجد مصدرًا موثوقًا ومؤرخًا أو أستطيع اشتقاقها من بياناتي.
3. أي مهمة هي الأنسب لمساعد ذكاء اصطناعي، مع المراجعة المعتادة؟ - A) كتابة مسودة شرح بلغة بسيطة لمعنى "هامش الربح الإجمالي" - B) تقرير أي حسابات العملاء يجب إغلاقها - C) ذكر رقم الإيرادات الدقيق من نظام لا يستطيع الذكاء الاصطناعي الوصول إليه - D) تأكيد أن عقد أحد الموردين صحيح قانونيًا
4. أفضل وصف لـ "الذكاء الاصطناعي التوليدي" هو… - A) أي برنامج يستخدم جدول بيانات. - B) قاعدة بيانات لإجابات متحقَّق منها. - C) ذكاء اصطناعي ينشئ محتوى جديدًا، مثل النصوص أو الصور أو الكود، من أنماط تعلّمها. - D) نظام يصنّف الصور فقط.
5. سألت السؤال نفسه مرتين وحصلت على إجابتين مختلفتين. ماذا يُظهر هذا على الأرجح؟ - A) الأداة معطلة ولا يجب استخدامها أبدًا. - B) المخرجات قد تتباين، لذلك تحتاج النتائج المهمة إلى تحقق مستقل. - C) الإجابة الثانية هي الصحيحة دائمًا. - D) الإجابة الأولى منسوخة من الإنترنت.
6. أي رد من مساعد ذكاء اصطناعي يجب أن يجعلك أكثر حذرًا؟ - A) "ليس لدي بيانات سبتمبر، لذلك لا أستطيع المقارنة بين الشهرين." - B) "هذه هي المعادلة التي استخدمتها: الإيرادات ÷ الطلبات." - C) "انخفضت الإيرادات لأن أحد المنافسين خفّض أسعاره"، بينما لم تتضمن مدخلاتك أي بيانات عن المنافسين. - D) "يُرجى مراجعة هذا الحساب مقارنةً بسجلاتك."
10. الذكاء الاصطناعي في التطبيق
اسأل مساعد ذكاء اصطناعي (دون أي بيانات حقيقية لشركة أو لأشخاص):
"I am a beginner learning data analysis. In a table, compare what large language models are typically good at and what their common limitations are when helping with data work. For each row, give one example. Then list any claims in your own answer that I should verify against an authoritative source, and say why."
وبالعربية: "أنا مبتدئ أتعلم تحليل البيانات. في جدول، قارن بين ما تجيده النماذج اللغوية الكبيرة عادةً وبين حدودها الشائعة عندما تساعد في العمل مع البيانات. أعطِ مثالًا واحدًا لكل صف. ثم اذكر أي ادعاءات في إجابتك يجب أن أتحقق منها من مصدر موثوق، وقل لماذا."
ثم اختر ثلاثة ادعاءات من الرد وتحقق من كل منها مقارنةً بـ NIST Generative AI Profile (راجع المصادر) أو بهذا الدرس. وضع علامة على كل منها: مؤكَّد، أو غير مؤكَّد، أو متناقض.
لماذا قد يفيد هذا: جدول المقارنة يعطيك نظرة عامة سريعة. وطلبك من الذكاء الاصطناعي أن يحدد ادعاءاته بنفسه يُظهر أين يلزم التحقق. هذه القائمة نقطة بداية، وليست بديلًا عن تحققك أنت.
11. التحقق من مخرجات الذكاء الاصطناعي
- ادعاءً بادعاء: قسّم الرد إلى ادعاءات منفصلة؛ ولا تتحقق من "الرد كله" دفعة واحدة أبدًا.
- فحص المصدر: لكل ادعاء اخترته، ابحث عن العبارة المقابلة في NIST Profile أو في هذا الدرس. إن لم تجدها، فضع عليه علامة غير مؤكَّد، لا "صحيح".
- انتبه للتعميمات المطلقة: كلمات مثل "دائمًا" و"أبدًا" و"كل النماذج" و"مضمون" تدل عادةً على ادعاء مبالغ في تعميمه. فالأدوات تختلف وتتغير.
- التواريخ والخصائص: تعامل مع الادعاءات عن منتجات أو إصدارات نماذج أو خصائص "أحدث" بعينها على أنها مرتبطة بتاريخ، وراجع الوثائق الحالية للشركة المنتجة.
- الفحص الذاتي ليس دليلًا: قول الذكاء الاصطناعي "أنا واثق" لا يثبت أي شيء.
- الخصوصية: استخدم أسئلة عامة وبيانات مصطنعة فقط. لا تلصق بيانات حقيقية لعملاء أو لشركة في أدوات ذكاء اصطناعي عامة؛ واتبع سياسة مؤسستك والقانون المعمول به.
12. منظور الأعمال
قرّر أي مهام البيانات مناسبة للاستعانة بالذكاء الاصطناعي. الذكاء الاصطناعي أداة تسريع، وليس سلطة قرار. ومن الطرق السريعة للحكم على مهمة أن تسأل خمسة أسئلة:
| السؤال | يشير إلى "مرشح جيد" | يشير إلى "استخدمه بحذر" أو "لا تستخدمه" |
|---|---|---|
| 1. هل أستطيع التحقق من المخرجات؟ | نعم، بسهولة (إعادة الحساب، أو التشغيل، أو المقارنة بالمصدر) | التحقق صعب أو مستحيل |
| 2. ما البيانات التي يجب أن أشاركها؟ | لا شيء، أو بيانات عامة، أو مصطنعة | بيانات شخصية، أو سرية، أو أسرار |
| 3. ما حجم الأثر إذا كانت خاطئة؟ | منخفض؛ مسودة سيعدّلها إنسان | مرتفع: مال، أو أشخاص، أو قانون، أو سلامة |
| 4. هل لدى الذكاء الاصطناعي ما يحتاجه؟ | كل المدخلات اللازمة موجودة في الطلب | يحتاج إلى الوصول إلى أنظمة أو حقائق ليست لديه |
| 5. هل يُفترض أن أتعلم هذه المهارة؟ | لا، أو الذكاء الاصطناعي يساعدني على فهمها | نعم، والذكاء الاصطناعي سيحل محل تدرّبي |
المهمة قد تكون مرشحًا جيدًا، أو مرشحًا بشروط (مثل بيانات مصطنعة فقط، أو مراجعة خبير)، أو غير مناسبة.
13. مهمة عمل — فرز المهام للاستعانة بالذكاء الاصطناعي
نشاط خيالي: Cedar Lane. يذكر صاحب المتجر سبع مهام ويسأل: "أين يمكن أن يساعدنا الذكاء الاصطناعي؟" لكل مهمة، اختر مرشح جيد، أو بشروط (واذكرها)، أو غير مناسبة، واذكر سببًا في سطر واحد باستخدام الأسئلة الخمسة في القسم 12.
| # | المهمة |
|---|---|
| a | كتابة مسودة رسالة ودودة تخبر العملاء بأن التوصيل سيتأخر يومين |
| b | شرح معنى "معدل التحويل" لعضو جديد في الفريق |
| c | تقرير أي موظف سيتم الاستغناء عنه، باستخدام تقييمات أدائهم |
| d | تلخيص 40 تقييمًا مصطنعًا ومجهّلًا للمنتجات في محاور |
| e | لصق قائمة العملاء كاملة (الأسماء، والبريد الإلكتروني، والعناوين) في روبوت محادثة عام ومجاني للعثور على المكرر |
| f | ذكر إيرادات الشهر الماضي بدقة من النظام المحاسبي للمتجر، الذي لا يستطيع الذكاء الاصطناعي الوصول إليه |
| g | العصف الذهني حول الأسباب المحتملة لانخفاض التحويل في ديسمبر |
14. تحدٍّ قصير
نشاط خيالي: Riverside Bikes، ورشة صغيرة لإصلاح الدراجات. يريد المدير استخدام مساعد ذكاء اصطناعي في: (1) كتابة منشورات على وسائل التواصل عن مواعيد العمل؛ (2) تقدير طلبية قطع الغيار للشهر القادم من ملف مبيعات العام الماضي؛ (3) الرد على أسئلة العملاء عن حقوق الضمان في بلدهم.
- صنّف كل استخدام: مرشح جيد / بشروط / غير مناسب.
- لكل استخدام، سمِّ الخطر الرئيسي وخطوة تحقق واحدة.
- في جملتين، اشرح للمدير الفرق بين "الذكاء الاصطناعي كتبه" و"إنه صحيح".
سلّم إجابتك قبل أي ملاحظات. لا يوجد حل هنا.
15. المصادر
- مطلوب (حوالي 15 دقيقة): NIST، Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile (NIST AI 600-1، يوليو 2024). اقرأ الملخص في صفحة المنشور. وفي ملف PDF، ابحث عن قائمة المخاطر الاثني عشر في القسم 2، واقرأ الوصف القصير لـ Confabulation وData Privacy. صفحة المنشور: https://www.nist.gov/publications/artificial-intelligence-risk-management-framework-generative-artificial-intelligence · ملف PDF: https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.600-1.pdf (كلاهما فُتح وروجع في 12 أكتوبر 2026.)
- مقترح: رسم سير العمل في L04 من U01. حدِّد أين يمكن أن يساعد مساعد الذكاء الاصطناعي، وأين يجب أن يتحقق الإنسان.
- للتعمّق (اختياري): AI for Everyone (DeepLearning.AI)، وهي دورة تصفها صفحتها بأنها غير تقنية. راجع القسم 16.
16. شخصية تتابعها / قدوة
Andrew Ng (حددته D.World للوحدة U03).
- حقائق متحقَّق منها (12 أكتوبر 2026): صفحات دورات DeepLearning.AI تذكره بصفة "Founder, DeepLearning.AI; Co-founder, Coursera" (مؤسس DeepLearning.AI؛ وأحد مؤسسي Coursera). وهو المدرّس المذكور لدورة AI for Everyone، التي تصفها صفحتها بأنها "a non-technical course" (دورة غير تقنية). https://www.deeplearning.ai/courses/ai-for-everyone/
- لماذا توصي به D.World: تعليم واضح وعملي عن الذكاء الاصطناعي، يهدف إلى مساعدة الناس على فهم أين يمكن تطبيق الذكاء الاصطناعي وأين لا يمكن.
- جرّب هذا: افتح صفحة دورة AI for Everyone، وإن كانت متاحة لك، شاهد المادة الافتتاحية. شروط الوصول يحددها مقدّم الدورة وقد تتغير؛ ولا يتطلب هذا الدرس أي شراء. سجّل مثالًا واحدًا لمهمة مناسبة للذكاء الاصطناعي وأخرى غير مناسبة، وقارنهما بإجاباتك في القسم 13.
المناصب تتغير مع الوقت؛ راجع صفحاته الخاصة لمعرفة التفاصيل الحالية.
17. المصطلحات
| المصطلح | معناه في هذا الدرس |
|---|---|
| الذكاء الاصطناعي (AI) | مصطلح واسع للأنظمة الحاسوبية التي تؤدي مهام مرتبطة بالذكاء البشري |
| الذكاء الاصطناعي التوليدي (Generative AI) | ذكاء اصطناعي ينشئ محتوى جديدًا (نصوصًا، وصورًا، وكودًا) من أنماط تعلّمها |
| النموذج اللغوي الكبير (LLM) | ذكاء اصطناعي توليدي دُرِّب على كميات كبيرة من النصوص؛ ينتج النص بالتنبؤ بالأجزاء التالية المرجّحة (tokens) |
| Token | جزء صغير من النص (كلمة أو جزء من كلمة) يعالجه النموذج اللغوي الكبير |
| الطلب (Prompt) | التعليمات والمدخلات التي تعطيها لأداة الذكاء الاصطناعي |
| الاختلاق / الهلوسة (Confabulation / hallucination) | محتوى خاطئ أو غير مدعوم يُقال بثقة (مصطلح NIST: confabulation) |
| ادعاء مدعوم | ادعاء تستطيع أن تشير إليه في المدخلات |
| ادعاء غير مدعوم | ادعاء ليس في المدخلات ولا يمكن اشتقاقه منها |
| بيانات التدريب (Training data) | البيانات التي تعلّم منها النموذج أنماطه |
18. تأمّل
قبل هذا الدرس، عندما كانت إجابة الذكاء الاصطناعي تبدو واثقة، كيف كنت تقرر هل تثق بها؟ وما العادة الواحدة التي ستستخدمها من الآن في كل مرة يعطيك فيها الذكاء الاصطناعي رقمًا؟
19. الخطوة التالية
أصبحت تعرف لماذا يجب التحقق من مخرجات الذكاء الاصطناعي. في L10 — كتابة الطلبات: السياق والقيود والأمثلة، ستتعلم كتابة الطلبات كمواصفات واضحة. الطلبات الجيدة تعطي الذكاء الاصطناعي المدخلات الصحيحة، فتحصل على فراغات مخترعة أقل، ومخرجات أسهل في التحقق منها.
20. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| مراجعة المفاهيم (Q1–Q6) | فهم ما تفعله النماذج اللغوية الكبيرة وحدودها | 5 إجابات صحيحة أو أكثر من 6 |
| التدريب الموجَّه والمستقل (تصنيف الادعاءات) | الفصل بين الادعاءات المدعومة والمحسوبة وغير المدعومة | معايير L09-GP وL09-IP |
| مهمة العمل (فرز المهام للذكاء الاصطناعي) | الحكم على مدى مناسبة المهام للاستعانة بالذكاء الاصطناعي | معايير L09-WT |
| سجل الذكاء الاصطناعي في التطبيق والتحدي القصير | التحقق من ادعاءات الذكاء الاصطناعي مقارنةً بمصدر؛ وشرح الخطر | معايير L09-AI وL09-MC |
المراجع
- NIST. Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile (NIST AI 600-1)، نُشر في 26 يوليو 2024 (حُدّثت الصفحة في 8 أبريل 2026). https://www.nist.gov/publications/artificial-intelligence-risk-management-framework-generative-artificial-intelligence و https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.600-1.pdf (كلاهما فُتح وروجع في 12 أكتوبر 2026). يدعم: تعريف الاختلاق وأسماءه العامية؛ وقائمة مخاطر الذكاء الاصطناعي التوليدي الاثني عشر، ومنها Confabulation وData Privacy.
- DeepLearning.AI. صفحة دورة AI for Everyone. https://www.deeplearning.ai/courses/ai-for-everyone/ (فُتحت وروجعت في 12 أكتوبر 2026). يدعم: اسم المدرّس ووصف منصبه؛ وعبارة "non-technical course".
- تصنيفات "مدعوم / حساب / غير مدعوم" وأسئلة الفرز الخمسة أدوات تعليمية من D.World، وليست معيارًا خارجيًا.
- D.World Curriculum Map v1.0 (صف L09) وCurriculum Bible v1.0 (معيار دمج الذكاء الاصطناعي). وثائق داخلية.
L10 · Prompting: Context, Constraints & ExamplesL10 · كتابة الطلبات: السياق والقيود والأمثلة Freeمجاني
L10 — Prompting: Context, Constraints & Examples
Learner file. Answers and model solutions are in a separate instructor-only file. Version: U03 v1.0 · Content date: 12 October 2026. Time estimates are provisional until learner-tested.
1. Lesson Identity
| Field | Value |
|---|---|
| Title | Prompting: Context, Constraints & Examples |
| Stage | Stage 1 — Foundations |
| Unit | U03 — AI for Data Work |
| Lesson ID | L10 |
| Skills | Prompt design; task specification |
| Difficulty | Beginner |
| Estimated time | About 1 hour 50 minutes (provisional) |
| Prerequisites | L09 (what LLMs do; supported vs unsupported claims). U02 L08 ("sales are down" table) is reused. No coding needed. |
Time breakdown (provisional): concept and worked example, 30 min · guided practice, 15 min · independent practice, 15 min · knowledge check (prompt revision), 10 min · AI in Practice and Verification, 20 min · workplace task, 15 min · mini challenge, 5 min.
2. Learning Objective
By the end of this lesson, you will be able to write structured prompts that state the role and task, relevant context, inputs, constraints and output format (plus examples and verification requirements where useful), and compare the outputs of a vague and a structured prompt.
D.World map objective (verbatim): Write structured prompts with role, context, inputs, constraints, and output format.
3. Why It Matters
An AI assistant only knows what you give it. If you write "check this data", it has to guess what "check" means, what the data is for, and what a problem looks like. It will fill those gaps with assumptions, and you may not notice which ones.
A good prompt works like a specification you might give a new colleague: what to do, why, with what, within which limits, and in what form. It does not guarantee a correct answer, but it makes the output more relevant and much easier to verify. Key principle: more context is useful when it is relevant and explicit.
4. Concept
A prompt as a specification
There is no single "magic formula". These parts help in most data tasks:
| Part | Question it answers | Example (data-quality check) |
|---|---|---|
| 1. Role and task | Who should the AI act as, and what exactly should it do? | "Act as a careful data analyst. Review the order table below for data-quality issues." |
| 2. Context | Why is this being done; what does "good" mean here? | "The table will be used to calculate November revenue for a small online store." |
| 3. Inputs | What material must it use? (Separate it clearly.) | The table, placed between """ marks |
| 4. Constraints | What limits apply? | "Do not change or delete any rows. Use only the data provided." |
| 5. Output format | What shape should the answer take? | "A table with columns: row, column, issue, why it matters, suggested check." |
| 6. Examples (optional) | What does one good answer look like? | One example row of the output table |
| 7. Verification requirements | How should it show uncertainty? | "List your assumptions. If something cannot be decided from the data, say 'needs human check'." |
Practical habits (from OpenAI's prompting guidance)
OpenAI's help-centre article on prompt engineering recommends several habits that apply to data work:
- Put instructions at the beginning, and separate them from the input with markers such as
###or""". - Be specific and descriptive about context, outcome, length and format.
- Show the output format you want, for example with a sample.
- Start without examples ("zero-shot"); if results are not good enough, add examples ("few-shot").
- Replace vague words ("short", "a few") with precise ones ("3 bullet points").
- Say what to do, not only what not to do.
Relevant context vs noise
More context helps when it is relevant and explicit: the purpose, the definitions, the rules. Pasting everything you have can hurt instead. It adds noise, can hide the real task, and may include data you must not share (L12). Before adding context, ask: "Does the AI need this to do the task well?"
Iterate and compare
Prompting is a loop: write → run → check the output against the input → revise the prompt → compare. Change one or two parts at a time so you can see which change helped. Even with a strong prompt, every result still needs verifying (L09).
5. Worked Example
Task (synthetic data, Cedar Lane): improve a prompt for a data-quality check.
Version 1 (vague):
"Check this data for problems."
What is missing: - Context: problems for what purpose? - Constraints: may it delete rows? - Format: list, table or paragraph? - Uncertainty: how should it say when it is unsure?
The AI must guess all four.
Version 2 (structured):
"Act as a careful data analyst. Review the order table below for data-quality issues before it is used to calculate November revenue for a small online store.
Rules: use only the data provided; do not change or delete rows; do not guess values that are missing.
Output: a table with columns row number, column, issue, why it matters for revenue, suggested check. After the table, list any assumptions you made. If an issue cannot be decided from the data alone, write 'needs human check'.
Table: """ (table here) """
What changed: 1. Role and task are stated. 2. The purpose (November revenue) tells the AI which issues matter most. 3. Constraints stop it from "fixing" data on its own. 4. A fixed output format makes the result quick to check row by row. 5. The uncertainty rule invites "needs human check" instead of invented certainty.
You will run both versions in Section 10.
6. Visual Explanation
VAGUE PROMPT STRUCTURED PROMPT
"Check this data" ┌ Role & task
│ ├ Context (purpose)
▼ ├ Inputs """ table """
AI fills gaps with ├ Constraints (don't delete, don't guess)
its own assumptions ├ Output format (table columns)
│ ├ Example (optional)
▼ └ Verification (assumptions, "needs human check")
Output: hard to check │
▼
Output: easier to check — but STILL check it
Alt text: Two columns. On the left, a vague prompt, "Check this data", leads to the AI filling gaps with its own assumptions and to output that is hard to check. On the right, a structured prompt lists seven parts: role and task, context or purpose, inputs inside quotation-mark delimiters, constraints such as do not delete and do not guess, output format as table columns, an optional example, and verification requirements such as listing assumptions and writing "needs human check". It leads to output that is easier to check, with the note that it must still be checked.
7. Guided Practice
Weak prompt:
"Tell me why sales went down and what to do."
Rewrite it using the U02 L08 table (synthetic, Cedar Lane): November 25,000 sessions, 750 orders, 18,000 USD revenue; December 22,000 sessions, 550 orders, 13,200 USD revenue.
- Write the role and task. (Hint: should the AI give a final answer or possible explanations?)
- Add context: who is asking, and which decision it supports.
- Put the input table between
"""marks. - Add at least two constraints. (Hint: what should it do about causes it cannot see in the data?)
- Specify an output format.
- Add one verification requirement.
Then label each sentence of your prompt with the part number (1–7) from Section 4.
8. Independent Practice
Fictional business: Greenleaf Plants has 12 synthetic customer comments. It wants them grouped into themes before a product meeting.
Write a structured prompt that: 1. asks for no more than four themes, each with a count and one short supporting quote taken word for word from the input; 2. forbids inventing comments or themes not present in the input; 3. requests a fixed output table and a final line listing comments that fit no theme; 4. includes one verification requirement of your choice.
Then write two checks you would perform on the output. (Example check type: count the comments per theme yourself.)
No model answer is shown here.
9. Knowledge Check — Prompt Revision Exercise
Part A — Choose the best answer.
A1. Which addition would most improve the prompt "Summarize this sales table"? - A) "Please be very good." - B) "Use your knowledge of the whole internet." - C) "Summarize it in 3 bullet points for a store owner deciding next month's stock order, using only the figures in the table." - D) Adding the same table twice
A2. Why separate the input data from the instructions with markers such as """?
- A) It makes clear which text is the material to work on and which text is the instruction.
- B) It encrypts the data so it is private.
- C) It guarantees the answer will be correct.
- D) It is required by law.
A3. A learner pastes the full company sales database "for context" into a prompt about one product's weekly sales. What is the main problem? - A) The prompt becomes too short. - B) The AI will refuse to answer. - C) More data always gives better answers, so there is no problem. - D) Most of it is irrelevant noise, and it may share data that should not be shared.
A4. Your structured prompt gives a better-looking answer than your vague prompt. What should you do next? - A) Use the answer directly, because a structured prompt guarantees correctness. - B) Check the answer against the input, as you would any AI output. - C) Delete the vague prompt's answer and forget the comparison. - D) Ask the AI to rate its own answer out of 10 and accept a high score.
Part B — Revise this prompt.
"Look at our customer data and find the best customers and tell me everything about them."
- List three problems with this prompt, including one privacy problem.
- Rewrite it as a structured prompt using synthetic data only, with at least five of the seven parts from Section 4.
10. AI in Practice
Build a prompt for a data-quality task, iterate it, and compare outputs.
Synthetic input (fictional Cedar Lane orders, November):
| row | order_id | order_date | country | product | qty | unit_price |
|---|---|---|---|---|---|---|
| 1 | 2001 | 2026-11-03 | UK | Notebook | 2 | 12.00 |
| 2 | 2002 | 03/11/2026 | United Kingdom | Notebook | 1 | 12.00 |
| 3 | 2003 | 2026-11-04 | DE | Pen set | -1 | 8.00 |
| 4 | 2003 | 2026-11-04 | DE | Pen set | -1 | 8.00 |
| 5 | 2004 | 2026-11-05 | Notebook | 3 | 120.00 | |
| 6 | 2005 | 2026-11-31 | FR | Planner | 1 | 20.00 |
(Cedar Lane's list prices: Notebook 12.00, Pen set 8.00, Planner 20.00.)
- Run Version 1 ("Check this data for problems.") with the table. Save the output.
- Run Version 2 (the structured prompt from Section 5) with the same table. Save the output.
- Iterate once: change one part of Version 2, for example by adding one example output row or the list prices as context. Run it and save the output as Version 3.
- Compare the three outputs in a table: issues found; issues missed; anything invented; whether it tried to delete or "fix" data; how easy it was to check.
Why this can help: comparing versions shows you directly what each part of a specification contributes.
11. AI Verification
- Build your own answer first: before reading the AI's outputs, list every issue you can find in the six rows. This is your checklist.
- Row-by-row check: for each issue the AI reports, find the exact row and value. If you cannot find it, mark it invented.
- Missed issues: compare against your checklist. Which issues did each version miss?
- Judgement calls: some issues cannot be decided from the data alone (for example, is a negative quantity a return or an error?). A good output says "needs human check"; it does not decide silently.
- No silent fixes: reject any output that deletes rows or fills missing values without being asked and without saying so.
- Privacy: this table is synthetic. With real data, follow L12: no personal or confidential data in unapproved tools.
12. Business Lens
Ask AI to produce two alternative analysis plans under stated constraints; evaluate both. AI can draft options quickly; the business value comes from choosing well between them.
Use this prompt (synthetic data from U02 L08):
"Act as an analytics planner. A small online store's revenue fell from 18,000 USD in November to 13,200 USD in December. Sessions went from 25,000 to 22,000 and orders from 750 to 550. Propose two different analysis plans to find out why.
Constraints: the analyst has 2 hours; available data is an order export (no customer personal data) and a website analytics summary; no paid tools; results are needed for the owner's meeting on Friday.
For each plan, give: the steps, the data used for each step, the expected output and one risk. Do not state causes as facts. Label any explanation as a hypothesis."
Evaluate both plans with these criteria (score each 0–2):
- Answers the business question.
- Fits the constraints (time, data, tools).
- Uses only data that is actually available.
- Has steps that can be checked.
- Labels hypotheses as hypotheses.
13. Workplace Task — Prompt and Plan Memo
Fictional business: Cedar Lane.
- Run the Section 12 prompt. If you have no AI access, your instructor will provide two plans for you to evaluate.
- Fill in the evaluation table for both plans.
- Write a 120–180-word memo to the owner covering four points: - which plan you recommend and why; - one change you would make to it; - one thing in either plan that you rejected (e.g., it used data you do not have, or it stated a cause as fact); - how you checked that.
- Attach your final prompt and note one revision you made to it, and why.
14. Mini Challenge
Fictional business: Greenleaf Plants has a synthetic product catalogue with columns product_id, name, category, price, stock. You suspect some prices are missing, some categories are spelled in different ways, and some stock values are negative.
- Write a structured prompt for a data-quality review that includes one example output row (a few-shot example).
- Add a constraint that prevents the AI from changing any data.
- Write one sentence explaining why including an example row may help, and one risk of the example (e.g., the AI copying it too closely).
Submit before feedback. No solution is provided here.
15. Resources
- Required (about 15 min): OpenAI Help Center, Best practices for prompt engineering with the OpenAI API. Read the numbered recommendations on instructions placement, specificity, output format, zero-shot vs few-shot, and saying what to do instead of what not to do. https://help.openai.com/en/articles/6654000-best-practices-for-prompt-engineering-with-chatgpt (Opened and checked 12 Oct 2026. The page is written mainly for API users, and its exact title differs from the address. Some recommendations concern specific models or product features and may change; this lesson uses only the general habits.)
- Recommended: your L09 claim-labelling table. Use it to verify any output you get in this lesson.
- Deeper (optional): ChatGPT Prompt Engineering for Developers (DeepLearning.AI with OpenAI). See Section 16. It is designed for developers and uses code notebooks, so it is optional at this stage.
16. Person to Follow / Role Model
Andrew Ng (mapped by D.World for U03; also featured in L09).
- Verified facts (12 Oct 2026): the course page lists him, alongside Isa Fulford ("Member of Technical Staff, OpenAI"), as an instructor of the short course ChatGPT Prompt Engineering for Developers. His listed title there is "Founder, DeepLearning.AI; Co-founder, Coursera". https://www.deeplearning.ai/short-courses/chatgpt-prompt-engineering-for-developers/
- Why this matters here: the course treats prompting as a skill you practise and refine, which matches this lesson's write → run → check → revise loop.
- Try this: read the course description and note one prompting principle it mentions. Then find the same idea in the OpenAI guidance, or note that it is not there.
17. Glossary
| Term | Meaning in this lesson |
|---|---|
| Prompt specification | A prompt that states the role and task, context, inputs, constraints, output format, and (optionally) examples and verification requirements |
| Context | Background the AI needs: purpose, definitions, rules |
| Constraint | A limit on what the AI may do or use |
| Delimiter | Markers such as """ or ### that separate instructions from input |
| Output format | The required shape of the answer (table, bullets, word count) |
| Zero-shot prompt | A prompt with no worked examples |
| Few-shot prompt | A prompt that includes one or more examples of the desired output |
| Iteration | Revising a prompt and comparing outputs |
| Data-quality issue | A problem that may make data wrong or misleading: duplicates, missing values, invalid or inconsistent formats, suspicious values |
18. Reflection
Compare your Version 1 and Version 2 outputs. Which part of the specification made the biggest difference? Did any part make no visible difference? What does that tell you?
19. Next Step
A clear prompt helps most when the AI's output can be tested. In L11 — AI for Coding, SQL & Analysis, you will ask AI to explain and draft small pieces of code and SQL. Then you will check them by tracing them by hand on a tiny table, and you will catch a plausible-looking AI error.
20. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Prompt revision exercise, Part A (A1–A4) | Understands what makes a prompt effective and safe | 3 or more of 4 correct |
| Prompt revision exercise, Part B | Rewrites a weak prompt as a specification, including privacy | Rubric L10-KCB |
| AI in Practice comparison (V1/V2/V3) | Iterates a prompt and compares outputs against own checklist | Rubric L10-AI |
| Guided and independent practice, workplace memo, mini challenge | Writes structured prompts; evaluates alternative plans | Rubrics L10-GP, L10-IP, L10-WT, L10-MC |
References
- OpenAI Help Center. Best practices for prompt engineering with the OpenAI API. https://help.openai.com/en/articles/6654000-best-practices-for-prompt-engineering-with-chatgpt (opened and checked 12 Oct 2026; page shows "Updated 2 months ago"). Supports: instructions at the beginning with
###or"""delimiters; be specific and descriptive; articulate output format through examples; zero-shot then few-shot; reduce imprecise descriptions; say what to do instead of what not to do. - DeepLearning.AI. ChatGPT Prompt Engineering for Developers course page. https://www.deeplearning.ai/short-courses/chatgpt-prompt-engineering-for-developers/ (opened and checked 12 Oct 2026). Supports: instructors and titles listed.
- The seven-part prompt specification and the plan-evaluation criteria are D.World teaching tools, not an external standard.
- D.World Curriculum Map v1.0 (L10 row) and Curriculum Bible v1.0. Internal.
L10 — كتابة الطلبات: السياق والقيود والأمثلة
ملف المتعلّم. الإجابات والحلول النموذجية في ملف منفصل خاص بالمدرّس فقط. الإصدار: U03 v1.0 · تاريخ المحتوى: 12 أكتوبر 2026. تقديرات الوقت مبدئية إلى أن تُجرَّب مع المتعلّمين.
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | كتابة الطلبات: السياق والقيود والأمثلة |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U03 — الذكاء الاصطناعي في العمل مع البيانات |
| رقم الدرس | L10 |
| المهارات | تصميم الطلبات (prompts)؛ تحديد مواصفات المهمة |
| المستوى | مبتدئ |
| الوقت المتوقع | حوالي ساعة و50 دقيقة (مبدئي) |
| المتطلبات السابقة | L09 (ما تفعله النماذج اللغوية الكبيرة؛ الادعاءات المدعومة مقابل غير المدعومة). ونعيد استخدام جدول "المبيعات انخفضت" من L08 في U02. لا تحتاج إلى البرمجة. |
تفصيل الوقت (مبدئي): المفهوم والمثال المحلول 30 دقيقة · التدريب الموجَّه 15 دقيقة · التدريب المستقل 15 دقيقة · اختبار الفهم (تحسين طلب) 10 دقائق · الذكاء الاصطناعي في التطبيق والتحقق 20 دقيقة · مهمة العمل 15 دقيقة · التحدي القصير 5 دقائق.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تكتب طلبات منظّمة تحدد الدور والمهمة، والسياق المناسب، والمدخلات، والقيود، وشكل المخرجات (إضافة إلى الأمثلة ومتطلبات التحقق عند الحاجة)، وأن تقارن بين مخرجات طلب غامض وطلب منظّم.
هدف خريطة D.World (بنصه): Write structured prompts with role, context, inputs, constraints, and output format.
3. لماذا يهمّك هذا؟
مساعد الذكاء الاصطناعي لا يعرف إلا ما تعطيه له. إذا كتبت "راجع هذه البيانات"، فعليه أن يخمّن ماذا تعني "راجع"، ولأي غرض البيانات، وكيف تبدو المشكلة. وسيملأ هذه الفراغات بافتراضات، وقد لا تلاحظ أيها افترض.
الطلب الجيد يعمل مثل مواصفات تعطيها لزميل جديد: ماذا يفعل، ولماذا، وبماذا، وفي أي حدود، وبأي شكل. هذا لا يضمن إجابة صحيحة، لكنه يجعل المخرجات أكثر ارتباطًا بالمطلوب وأسهل كثيرًا في التحقق منها. المبدأ الأساسي: السياق الإضافي مفيد عندما يكون ذا صلة وصريحًا.
4. المفهوم
الطلب كمواصفات
لا توجد "معادلة سحرية" واحدة. لكن هذه الأجزاء تساعد في أغلب مهام البيانات:
| الجزء | السؤال الذي يجيب عنه | مثال (فحص جودة البيانات) |
|---|---|---|
| 1. الدور والمهمة | بأي دور يتصرف الذكاء الاصطناعي، وماذا يفعل بالضبط؟ | "تصرّف كمحلل بيانات دقيق. راجع جدول الطلبات التالي بحثًا عن مشكلات في جودة البيانات." |
| 2. السياق | لماذا نفعل هذا؛ وماذا يعني "جيد" هنا؟ | "سيُستخدم الجدول لحساب إيرادات نوفمبر لمتجر إلكتروني صغير." |
| 3. المدخلات | ما المادة التي يجب أن يستخدمها؟ (افصلها بوضوح.) | الجدول، موضوعًا بين علامتي """ |
| 4. القيود | ما الحدود المفروضة؟ | "لا تغيّر أي صف ولا تحذفه. استخدم البيانات المعطاة فقط." |
| 5. شكل المخرجات | ما شكل الإجابة المطلوب؟ | "جدول بالأعمدة: الصف، العمود، المشكلة، لماذا تهم، الفحص المقترح." |
| 6. الأمثلة (اختياري) | كيف تبدو إجابة جيدة واحدة؟ | صف واحد كمثال من جدول المخرجات |
| 7. متطلبات التحقق | كيف يُظهر عدم التأكد؟ | "اذكر افتراضاتك. وإذا تعذّر الحسم في شيء من البيانات، فاكتب 'needs human check' (يحتاج إلى مراجعة بشرية)." |
عادات عملية (من إرشادات OpenAI لكتابة الطلبات)
توصي مقالة مركز المساعدة في OpenAI عن هندسة الطلبات (prompt engineering) بعدة عادات تنطبق على العمل مع البيانات:
- ضع التعليمات في البداية، وافصلها عن المدخلات بعلامات مثل
###أو""". - كن محددًا ووصفيًا في السياق والنتيجة المطلوبة والطول والشكل.
- اعرض شكل المخرجات الذي تريده، مثلًا بنموذج.
- ابدأ دون أمثلة ("zero-shot")؛ وإذا لم تكن النتائج جيدة بما يكفي، فأضف أمثلة ("few-shot").
- استبدل الكلمات الغامضة ("قصير"، "بعض") بكلمات دقيقة ("3 نقاط").
- قل ماذا يفعل، لا ما لا يفعله فقط.
السياق المفيد مقابل الضوضاء
السياق الإضافي يساعد عندما يكون ذا صلة وصريحًا: الغرض، والتعريفات، والقواعد. أما لصق كل ما لديك فقد يضر بدلًا من أن يفيد. فهو يضيف ضوضاء، وقد يُخفي المهمة الحقيقية، وقد يتضمن بيانات لا يجوز لك مشاركتها (L12). قبل أن تضيف سياقًا، اسأل: "هل يحتاج الذكاء الاصطناعي هذا لكي يؤدي المهمة جيدًا؟"
كرّر وقارن
كتابة الطلبات حلقة: اكتب ← شغّل ← قارن المخرجات بالمدخلات ← عدّل الطلب ← قارن. غيّر جزءًا أو جزأين في كل مرة حتى ترى أي تغيير ساعد. وحتى مع طلب قوي، تظل كل نتيجة بحاجة إلى تحقق (L09).
5. مثال محلول
المهمة (بيانات مصطنعة، Cedar Lane): تحسين طلب لفحص جودة البيانات.
النسخة 1 (غامضة):
"Check this data for problems." (راجع هذه البيانات بحثًا عن مشكلات.)
ما الناقص:
- السياق: مشكلات بالنسبة لأي غرض؟
- القيود: هل يجوز له حذف صفوف؟
- الشكل: قائمة، أم جدول، أم فقرة؟
- عدم التأكد: كيف يقول إنه غير متأكد؟
على الذكاء الاصطناعي أن يخمّن الأربعة كلها.
النسخة 2 (منظّمة):
"Act as a careful data analyst. Review the order table below for data-quality issues before it is used to calculate November revenue for a small online store.
Rules: use only the data provided; do not change or delete rows; do not guess values that are missing.
Output: a table with columns row number, column, issue, why it matters for revenue, suggested check. After the table, list any assumptions you made. If an issue cannot be decided from the data alone, write 'needs human check'.
Table: """ (table here) """
وبالعربية:
"تصرّف كمحلل بيانات دقيق. راجع جدول الطلبات التالي بحثًا عن مشكلات في جودة البيانات قبل استخدامه لحساب إيرادات نوفمبر لمتجر إلكتروني صغير.
القواعد: استخدم البيانات المعطاة فقط؛ لا تغيّر الصفوف ولا تحذفها؛ لا تخمّن القيم المفقودة.
المخرجات: جدول بالأعمدة رقم الصف، العمود، المشكلة، لماذا تهم للإيرادات، الفحص المقترح. وبعد الجدول، اذكر أي افتراضات وضعتها. وإذا تعذّر الحسم في مشكلة من البيانات وحدها، فاكتب 'needs human check'.
الجدول: """ (الجدول هنا) """
ما الذي تغيّر:
- الدور والمهمة مذكوران.
- الغرض (إيرادات نوفمبر) يخبر الذكاء الاصطناعي أي المشكلات أهم.
- القيود تمنعه من "إصلاح" البيانات من تلقاء نفسه.
- شكل المخرجات الثابت يجعل النتيجة سريعة المراجعة صفًا بصف.
- قاعدة عدم التأكد تشجّعه على كتابة "needs human check" بدلًا من يقين مخترع.
ستشغّل النسختين في القسم 10.
6. شرح بصري
VAGUE PROMPT STRUCTURED PROMPT
"Check this data" ┌ Role & task
│ ├ Context (purpose)
▼ ├ Inputs """ table """
AI fills gaps with ├ Constraints (don't delete, don't guess)
its own assumptions ├ Output format (table columns)
│ ├ Example (optional)
▼ └ Verification (assumptions, "needs human check")
Output: hard to check │
▼
Output: easier to check — but STILL check it
وصف الرسم: عمودان. على اليسار طلب غامض (Vague prompt)، "Check this data"، يؤدي إلى أن يملأ الذكاء الاصطناعي الفراغات بافتراضاته، وإلى مخرجات يصعب التحقق منها. وعلى اليمين طلب منظّم (Structured prompt) يضم سبعة أجزاء: الدور والمهمة، والسياق أو الغرض، والمدخلات بين علامات تنصيص فاصلة، والقيود مثل لا تحذف ولا تخمّن، وشكل المخرجات كأعمدة جدول، ومثال اختياري، ومتطلبات التحقق مثل ذكر الافتراضات وكتابة "needs human check". وهو يؤدي إلى مخرجات أسهل في التحقق منها، مع ملاحظة أنه يجب التحقق منها رغم ذلك.
7. تدريب موجَّه
طلب ضعيف:
"Tell me why sales went down and what to do." (قل لي لماذا انخفضت المبيعات وماذا أفعل.)
أعِد كتابته باستخدام جدول L08 في U02 (مصطنع، Cedar Lane): نوفمبر 25,000 جلسة، و750 طلبًا، وإيرادات 18,000 دولار؛ ديسمبر 22,000 جلسة، و550 طلبًا، وإيرادات 13,200 دولار.
- اكتب الدور والمهمة. (تلميح: هل يجب أن يعطي الذكاء الاصطناعي إجابة نهائية أم تفسيرات محتملة؟)
- أضف السياق: من يسأل، وأي قرار يدعمه الطلب.
- ضع جدول المدخلات بين علامتي
""". - أضف قيدين على الأقل. (تلميح: ماذا يفعل بالأسباب التي لا يستطيع رؤيتها في البيانات؟)
- حدِّد شكل المخرجات.
- أضف متطلب تحقق واحدًا.
ثم ضع بجانب كل جملة في طلبك رقم الجزء (1–7) من القسم 4.
8. تدريب مستقل
نشاط خيالي: لدى Greenleaf Plants عدد 12 تعليقًا مصطنعًا من العملاء. وتريد تجميعها في محاور قبل اجتماع عن المنتجات.
اكتب طلبًا منظّمًا:
- يطلب أربعة محاور على الأكثر، لكل منها عدد التعليقات واقتباس قصير داعم منقول حرفيًا من المدخلات؛
- يمنع اختراع تعليقات أو محاور غير موجودة في المدخلات؛
- يطلب جدول مخرجات ثابتًا وسطرًا أخيرًا يذكر التعليقات التي لا تنتمي لأي محور؛
- يتضمن متطلب تحقق واحدًا من اختيارك.
ثم اكتب فحصين ستجريهما على المخرجات. (مثال على نوع الفحص: عُدّ التعليقات في كل محور بنفسك.)
لا توجد إجابة نموذجية هنا.
9. اختبار الفهم — تمرين تحسين طلب
الجزء A — اختر أفضل إجابة.
A1. أي إضافة ستحسّن الطلب "لخّص جدول المبيعات هذا" أكثر من غيرها؟ - A) "من فضلك كن جيدًا جدًا." - B) "استخدم معرفتك بالإنترنت كله." - C) "لخّصه في 3 نقاط لصاحب متجر يقرر طلبية المخزون للشهر القادم، مستخدمًا الأرقام الموجودة في الجدول فقط." - D) إضافة الجدول نفسه مرتين
A2. لماذا نفصل بيانات المدخلات عن التعليمات بعلامات مثل """؟
- A) لأن ذلك يوضح أي نص هو المادة المطلوب العمل عليها وأي نص هو التعليمات.
- B) لأنه يشفّر البيانات فتصبح خاصة.
- C) لأنه يضمن أن تكون الإجابة صحيحة.
- D) لأن القانون يشترطه.
A3. متعلّم يلصق قاعدة بيانات المبيعات الكاملة للشركة "كسياق" في طلب عن المبيعات الأسبوعية لمنتج واحد. ما المشكلة الأساسية؟ - A) الطلب يصبح قصيرًا جدًا. - B) الذكاء الاصطناعي سيرفض الإجابة. - C) البيانات الأكثر تعطي دائمًا إجابات أفضل، فلا توجد مشكلة. - D) أغلبها ضوضاء لا صلة لها بالمهمة، وقد يشارك بيانات لا يجوز مشاركتها.
A4. طلبك المنظّم أعطى إجابة تبدو أفضل من طلبك الغامض. ماذا تفعل بعد ذلك؟ - A) أستخدم الإجابة مباشرة، لأن الطلب المنظّم يضمن الصحة. - B) أراجع الإجابة مقارنةً بالمدخلات، كما أفعل مع أي مخرجات للذكاء الاصطناعي. - C) أحذف إجابة الطلب الغامض وأنسى المقارنة. - D) أطلب من الذكاء الاصطناعي أن يقيّم إجابته من 10 وأقبل الدرجة العالية.
الجزء B — حسّن هذا الطلب.
"Look at our customer data and find the best customers and tell me everything about them." (انظر في بيانات عملائنا وابحث عن أفضل العملاء وأخبرني بكل شيء عنهم.)
- اذكر ثلاث مشكلات في هذا الطلب، منها مشكلة واحدة تتعلق بالخصوصية.
- أعِد كتابته كطلب منظّم باستخدام بيانات مصطنعة فقط، وبخمسة أجزاء على الأقل من الأجزاء السبعة في القسم 4.
10. الذكاء الاصطناعي في التطبيق
ابنِ طلبًا لمهمة جودة بيانات، وطوّره، وقارن المخرجات.
مدخلات مصطنعة (طلبات Cedar Lane الخيالية، نوفمبر):
| row | order_id | order_date | country | product | qty | unit_price |
|---|---|---|---|---|---|---|
| 1 | 2001 | 2026-11-03 | UK | Notebook | 2 | 12.00 |
| 2 | 2002 | 03/11/2026 | United Kingdom | Notebook | 1 | 12.00 |
| 3 | 2003 | 2026-11-04 | DE | Pen set | -1 | 8.00 |
| 4 | 2003 | 2026-11-04 | DE | Pen set | -1 | 8.00 |
| 5 | 2004 | 2026-11-05 | Notebook | 3 | 120.00 | |
| 6 | 2005 | 2026-11-31 | FR | Planner | 1 | 20.00 |
(أسعار القائمة في Cedar Lane: Notebook بسعر 12.00، وPen set بسعر 8.00، وPlanner بسعر 20.00.)
- شغّل النسخة 1 ("Check this data for problems.") مع الجدول. واحفظ المخرجات.
- شغّل النسخة 2 (الطلب المنظّم من القسم 5) مع الجدول نفسه. واحفظ المخرجات.
- طوّر مرة واحدة: غيّر جزءًا واحدًا من النسخة 2، مثلًا بإضافة صف مثال واحد من المخرجات أو أسعار القائمة كسياق. شغّله واحفظ المخرجات باسم النسخة 3.
- قارن المخرجات الثلاث في جدول: المشكلات التي وُجدت؛ والمشكلات التي فاتته؛ وأي شيء مخترع؛ وهل حاول حذف البيانات أو "إصلاحها"؛ ومدى سهولة التحقق.
لماذا قد يفيد هذا: مقارنة النسخ تُظهر لك مباشرة ما يضيفه كل جزء من المواصفات.
11. التحقق من مخرجات الذكاء الاصطناعي
- ابنِ إجابتك أولًا: قبل قراءة مخرجات الذكاء الاصطناعي، اكتب كل مشكلة تستطيع أنت أن تجدها في الصفوف الستة. هذه هي قائمة الفحص الخاصة بك.
- فحص صف بصف: لكل مشكلة يذكرها الذكاء الاصطناعي، اعثر على الصف والقيمة بالضبط. إن لم تجدهما، فضع عليها علامة مخترعة.
- المشكلات الفائتة: قارن بقائمة الفحص الخاصة بك. أي المشكلات فاتت كل نسخة؟
- المسائل التقديرية: بعض المشكلات لا يمكن الحسم فيها من البيانات وحدها (مثلًا: هل الكمية السالبة مرتجع أم خطأ؟). والمخرجات الجيدة تقول "needs human check"؛ ولا تحسم الأمر بصمت.
- لا إصلاحات صامتة: ارفض أي مخرجات تحذف صفوفًا أو تملأ قيمًا مفقودة دون أن يُطلب منها ذلك ودون أن تذكره.
- الخصوصية: هذا الجدول مصطنع. ومع البيانات الحقيقية، اتبع L12: لا بيانات شخصية أو سرية في أدوات غير معتمدة.
12. منظور الأعمال
اطلب من الذكاء الاصطناعي خطتي تحليل بديلتين ضمن قيود محددة، وقيّم الخطتين. الذكاء الاصطناعي يستطيع كتابة مسودات الخيارات بسرعة؛ وقيمة العمل تأتي من الاختيار الجيد بينها.
استخدم هذا الطلب (بيانات مصطنعة من L08 في U02):
"Act as an analytics planner. A small online store's revenue fell from 18,000 USD in November to 13,200 USD in December. Sessions went from 25,000 to 22,000 and orders from 750 to 550. Propose two different analysis plans to find out why.
Constraints: the analyst has 2 hours; available data is an order export (no customer personal data) and a website analytics summary; no paid tools; results are needed for the owner's meeting on Friday.
For each plan, give: the steps, the data used for each step, the expected output and one risk. Do not state causes as facts. Label any explanation as a hypothesis."
وبالعربية:
"تصرّف كمخطط تحليلات. انخفضت إيرادات متجر إلكتروني صغير من 18,000 دولار في نوفمبر إلى 13,200 دولار في ديسمبر. وانخفضت الجلسات من 25,000 إلى 22,000، والطلبات من 750 إلى 550. اقترح خطتي تحليل مختلفتين لمعرفة السبب.
القيود: لدى المحلل ساعتان؛ البيانات المتاحة ملف طلبات مُصدَّر (بلا بيانات شخصية للعملاء) وملخص تحليلات الموقع؛ لا أدوات مدفوعة؛ النتائج مطلوبة لاجتماع صاحب المتجر يوم الجمعة.
لكل خطة، اذكر: الخطوات، والبيانات المستخدمة في كل خطوة، والمخرجات المتوقعة، وخطرًا واحدًا. لا تذكر الأسباب على أنها حقائق. وصِف أي تفسير بأنه فرضية."
قيّم الخطتين بهذه المعايير (من 0 إلى 2 لكل معيار):
- تجيب عن سؤال العمل.
- تناسب القيود (الوقت، والبيانات، والأدوات).
- تستخدم فقط البيانات المتاحة فعلًا.
- خطواتها قابلة للتحقق.
- تصف الفرضيات بأنها فرضيات.
13. مهمة عمل — مذكرة الطلب والخطة
نشاط خيالي: Cedar Lane.
- شغّل طلب القسم 12. وإن لم يكن لديك وصول إلى الذكاء الاصطناعي، فسيعطيك المدرّس خطتين لتقيّمهما.
- املأ جدول التقييم للخطتين.
- اكتب مذكرة من 120 إلى 180 كلمة لصاحب المتجر تغطي أربع نقاط:
- أي خطة توصي بها ولماذا؛
- تغيير واحد ستجريه عليها؛
- شيء واحد في أي من الخطتين رفضته (مثلًا استخدمت بيانات ليست لديك، أو ذكرت سببًا على أنه حقيقة)؛
- كيف تحققت من ذلك.
- أرفق طلبك النهائي، واذكر تعديلًا واحدًا أجريته عليه، ولماذا.
14. تحدٍّ قصير
نشاط خيالي: لدى Greenleaf Plants كتالوج منتجات مصطنع بالأعمدة product_id, name, category, price, stock. وتشك في أن بعض الأسعار مفقودة، وأن بعض الفئات مكتوبة بطرق مختلفة، وأن بعض قيم المخزون سالبة.
- اكتب طلبًا منظّمًا لمراجعة جودة البيانات يتضمن صف مثال واحدًا من المخرجات (مثال few-shot).
- أضف قيدًا يمنع الذكاء الاصطناعي من تغيير أي بيانات.
- اكتب جملة واحدة تشرح لماذا قد يساعد تضمين صف مثال، وخطرًا واحدًا للمثال (مثلًا أن ينسخه الذكاء الاصطناعي حرفيًا أكثر من اللازم).
سلّم إجابتك قبل أي ملاحظات. لا يوجد حل هنا.
15. المصادر
- مطلوب (حوالي 15 دقيقة): OpenAI Help Center، Best practices for prompt engineering with the OpenAI API. اقرأ التوصيات المرقّمة عن موضع التعليمات، والتحديد، وشكل المخرجات، وzero-shot مقابل few-shot، وقول ما يجب فعله بدلًا مما لا يجب فعله. https://help.openai.com/en/articles/6654000-best-practices-for-prompt-engineering-with-chatgpt (فُتحت وروجعت في 12 أكتوبر 2026. الصفحة مكتوبة أساسًا لمستخدمي API، وعنوانها الدقيق يختلف عن الرابط. بعض التوصيات تخص نماذج أو خصائص منتجات بعينها وقد تتغير؛ وهذا الدرس يستخدم العادات العامة فقط.)
- مقترح: جدول تصنيف الادعاءات من L09. استخدمه للتحقق من أي مخرجات تحصل عليها في هذا الدرس.
- للتعمّق (اختياري): ChatGPT Prompt Engineering for Developers (DeepLearning.AI مع OpenAI). راجع القسم 16. الدورة مصممة للمطورين وتستخدم دفاتر برمجية (code notebooks)، لذلك هي اختيارية في هذه المرحلة.
16. شخصية تتابعها / قدوة
Andrew Ng (حددته D.World للوحدة U03؛ وظهر أيضًا في L09).
- حقائق متحقَّق منها (12 أكتوبر 2026): صفحة الدورة تذكره، مع Isa Fulford ("Member of Technical Staff, OpenAI")، مدرّسًا للدورة القصيرة ChatGPT Prompt Engineering for Developers. وصفته المذكورة هناك "Founder, DeepLearning.AI; Co-founder, Coursera". https://www.deeplearning.ai/short-courses/chatgpt-prompt-engineering-for-developers/
- لماذا يهم هذا هنا: الدورة تتعامل مع كتابة الطلبات كمهارة تتدرّب عليها وتحسّنها، وهذا يطابق حلقة هذا الدرس: اكتب ← شغّل ← تحقق ← عدّل.
- جرّب هذا: اقرأ وصف الدورة وسجّل مبدأً واحدًا لكتابة الطلبات تذكره. ثم ابحث عن الفكرة نفسها في إرشادات OpenAI، أو لاحظ أنها غير موجودة هناك.
17. المصطلحات
| المصطلح | معناه في هذا الدرس |
|---|---|
| مواصفات الطلب (Prompt specification) | طلب يحدد الدور والمهمة، والسياق، والمدخلات، والقيود، وشكل المخرجات، و(اختياريًا) الأمثلة ومتطلبات التحقق |
| السياق (Context) | الخلفية التي يحتاجها الذكاء الاصطناعي: الغرض، والتعريفات، والقواعد |
| القيد (Constraint) | حدّ لما يجوز للذكاء الاصطناعي أن يفعله أو يستخدمه |
| الفاصل (Delimiter) | علامات مثل """ أو ### تفصل التعليمات عن المدخلات |
| شكل المخرجات (Output format) | الشكل المطلوب للإجابة (جدول، نقاط، عدد كلمات) |
| طلب بلا أمثلة (Zero-shot prompt) | طلب لا يتضمن أمثلة محلولة |
| طلب بأمثلة (Few-shot prompt) | طلب يتضمن مثالًا واحدًا أو أكثر للمخرجات المطلوبة |
| التكرار (Iteration) | تعديل الطلب ومقارنة المخرجات |
| مشكلة جودة البيانات (Data-quality issue) | مشكلة قد تجعل البيانات خاطئة أو مضللة: التكرار، أو القيم المفقودة، أو الصيغ غير الصالحة أو غير المتّسقة، أو القيم المريبة |
18. تأمّل
قارن مخرجات النسخة 1 والنسخة 2. أي جزء من المواصفات أحدث الفرق الأكبر؟ وهل كان هناك جزء لم يُحدث فرقًا ظاهرًا؟ ماذا يخبرك ذلك؟
19. الخطوة التالية
الطلب الواضح يفيد أكثر عندما يمكن اختبار مخرجات الذكاء الاصطناعي. في L11 — الذكاء الاصطناعي في البرمجة وSQL والتحليل، ستطلب من الذكاء الاصطناعي أن يشرح أجزاء صغيرة من الكود وSQL وأن يكتب مسوداتها. ثم ستتحقق منها بتتبعها يدويًا على جدول صغير، وستكتشف خطأً من الذكاء الاصطناعي يبدو معقولًا.
20. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| تمرين تحسين الطلب، الجزء A (A1–A4) | فهم ما يجعل الطلب فعالًا وآمنًا | 3 إجابات صحيحة أو أكثر من 4 |
| تمرين تحسين الطلب، الجزء B | إعادة كتابة طلب ضعيف كمواصفات، مع مراعاة الخصوصية | معايير L10-KCB |
| مقارنة الذكاء الاصطناعي في التطبيق (V1/V2/V3) | تطوير الطلب ومقارنة المخرجات بقائمة الفحص الخاصة بك | معايير L10-AI |
| التدريب الموجَّه والمستقل، ومذكرة العمل، والتحدي القصير | كتابة طلبات منظّمة؛ وتقييم خطط بديلة | معايير L10-GP وL10-IP وL10-WT وL10-MC |
المراجع
- OpenAI Help Center. Best practices for prompt engineering with the OpenAI API. https://help.openai.com/en/articles/6654000-best-practices-for-prompt-engineering-with-chatgpt (فُتحت وروجعت في 12 أكتوبر 2026؛ الصفحة تُظهر "Updated 2 months ago"). يدعم: وضع التعليمات في البداية مع الفواصل
###أو"""؛ والتحديد والوصف؛ وتوضيح شكل المخرجات بالأمثلة؛ والبدء بـ zero-shot ثم few-shot؛ وتقليل الأوصاف غير الدقيقة؛ وقول ما يجب فعله بدلًا مما لا يجب فعله. - DeepLearning.AI. صفحة دورة ChatGPT Prompt Engineering for Developers. https://www.deeplearning.ai/short-courses/chatgpt-prompt-engineering-for-developers/ (فُتحت وروجعت في 12 أكتوبر 2026). يدعم: أسماء المدرّسين وصفاتهم المذكورة.
- مواصفات الطلب ذات الأجزاء السبعة ومعايير تقييم الخطط أدوات تعليمية من D.World، وليست معيارًا خارجيًا.
- D.World Curriculum Map v1.0 (صف L10) وCurriculum Bible v1.0. وثائق داخلية.
L11 · AI for Coding, SQL & AnalysisL11 · الذكاء الاصطناعي في البرمجة وSQL والتحليل Freeمجاني
L11 — AI for Coding, SQL & Analysis
Learner file. Answers and model solutions are in a separate instructor-only file. Version: U03 v1.0 · Content date: 12 October 2026. Time estimates are provisional until learner-tested.
1. Lesson Identity
| Field | Value |
|---|---|
| Title | AI for Coding, SQL & Analysis |
| Stage | Stage 1 — Foundations |
| Unit | U03 — AI for Data Work |
| Lesson ID | L11 |
| Skills | AI-assisted coding; verification |
| Difficulty | Beginner |
| Estimated time | About 2 hours (provisional) |
| Prerequisites | L09–L10. U02 L07 (AOV = revenue ÷ orders). No coding experience required. Python is taught in U04 and problem solving and testing in U05; here you only read and trace very short examples. |
Time breakdown (provisional): concept and worked example, 35 min · guided practice, 15 min · independent practice, 15 min · knowledge check, 15 min · AI in Practice and Verification, 20 min · workplace task, 15 min · mini challenge, 5 min.
About running code: you do not need to install anything or create any account for this lesson. Every task can be done by tracing by hand on a tiny table. If your instructor has given you a safe environment for running Python or SQL, you may run the examples there too. Tracing by hand is slower, but it checks the same logic. Note its limitation: it does not catch every problem that running code would, such as typing errors.
2. Learning Objective
By the end of this lesson, you will be able to use AI to explain, draft, refactor and debug simple code or SQL, and validate the result by working out the expected answer, tracing the code on a small table, and writing simple test cases.
D.World map objective (verbatim): Use AI to explain, draft, refactor, and debug simple code/SQL while validating results.
3. Why It Matters
AI assistants are often used to draft code and database queries (SQL). AI-drafted code can look tidy, include comments, and still answer a different question from the one you asked. Common examples are counting rows instead of orders, or including refunded sales.
These errors do not crash anything. They produce a believable number, which is why they are dangerous. In data work, such a number can end up in a report or a decision. Key principle: Generate → run → test → verify.
Python and SQL appear at the top of O*NET's list of software skills most often mentioned in US job postings for Data Scientists (Lightcast postings data, 2025; see Resources). This is a US signal, and requirements vary by employer. It is mentioned to explain why AI-assisted coding matters, not as a promise about jobs.
4. Concept
Four ways AI can help with code and SQL
| Use | Example request | What you must still do |
|---|---|---|
| Explain | "Explain this query line by line for a beginner." | Check the explanation against what the code actually does |
| Draft | "Write SQL to calculate average order value for paid orders." | Work out the expected answer yourself and compare |
| Refactor | "Make this function easier to read without changing what it does." | Test that the behaviour really is unchanged |
| Debug | "This gives 20.67 but I expected 31. Why?" | Confirm the fix with a test, and fix the cause, not just the symptom |
Generate → run → test → verify
- Generate: get a candidate from AI, using a structured prompt (L10) with the exact definition you need, e.g., "AOV = paid revenue ÷ number of distinct paid orders".
- Run (or trace): execute it on a small table where you already know the answer, or trace it by hand.
- Test: write test cases. Each test is an input plus the output you expect: - a normal case; - a boundary case (e.g., exactly 30.00 when the rule is "30 or more"); - an exclusion case (e.g., a refunded order that must not count); - an empty or unusual case (e.g., no paid orders).
- Verify: check that the result matches the business definition, not just that it runs. Check assumptions about filters, counting and rounding.
Readability helps verification
PEP 8, Python's official style guide, notes that "code is read much more often than it is written". It recommends:
- function and variable names in lowercase, with words separated by underscores (e.g., average_order_value);
- 4 spaces per indentation level.
Clear names make it easier to see whether code does what it claims.
The most common silent errors in simple data code
- Counting rows (lines) when you meant orders or customers (use distinct IDs).
- Missing a filter (e.g., including refunded orders).
- A wrong boundary (
>instead of>=). - Whole-number division: in some databases, dividing two whole numbers drops the decimals. This was tested in SQLite for this lesson; behaviour varies by database.
5. Worked Example
Synthetic table order_lines (fictional Cedar Lane, one week). Each row is a line in an order, and an order can have several lines.
| order_id | customer_id | product | qty | unit_price | status |
|---|---|---|---|---|---|
| 1001 | C01 | Notebook | 2 | 12 | paid |
| 1001 | C01 | Pen set | 1 | 8 | paid |
| 1002 | C02 | Notebook | 1 | 12 | paid |
| 1003 | C03 | Planner | 1 | 20 | refunded |
| 1004 | C01 | Notebook | 1 | 12 | paid |
| 1005 | C04 | Notebook | 4 | 12 | paid |
| 1005 | C04 | Planner | 1 | 20 | paid |
Task: average order value (AOV) for paid orders.
Step 1 — Work out the expected answer by hand (before asking AI):
| Paid line | qty × unit_price |
|---|---|
| 1001 Notebook | 2 × 12 = 24 |
| 1001 Pen set | 1 × 8 = 8 |
| 1002 Notebook | 1 × 12 = 12 |
| 1004 Notebook | 1 × 12 = 12 |
| 1005 Notebook | 4 × 12 = 48 |
| 1005 Planner | 1 × 20 = 20 |
| Paid revenue | 124 |
Distinct paid orders: 1001, 1002, 1004, 1005 = 4. Expected AOV = 124 ÷ 4 = 31.00 USD.
Step 2 — An illustrative AI-style proposal (written by D.World to show a typical error):
-- Average order value for paid orders
SELECT SUM(qty * unit_price) * 1.0 / COUNT(*) AS aov
FROM order_lines
WHERE status = 'paid';
Step 3 — Trace it:
- WHERE status = 'paid' keeps 6 lines. ✔ (The refunded order is excluded.)
- SUM(qty * unit_price) = 124. ✔
- COUNT(*) counts rows, giving 6 lines, not 4 orders. ✘
- Result: 124 ÷ 6 = 20.67, which does not match the expected 31.00.
The comment says "average order value", but the code calculates average line value.
Step 4 — Correct and re-test:
SELECT SUM(qty * unit_price) * 1.0 / COUNT(DISTINCT order_id) AS aov
FROM order_lines
WHERE status = 'paid';
Trace: 124 ÷ 4 = 31.00 ✔. Both queries were run in SQLite on this exact table for this lesson and gave 20.67 and 31.0.
About * 1.0: without it, SQLite returned 20 instead of 20.67 for the first query, because it divided two whole numbers. That is a second silent error to watch for.
6. Visual Explanation
order_lines (7 rows) orders (5) paid orders (4)
1001 | Notebook ┐ 1001 ─────────────► 1001 (32)
1001 | Pen set ┘ ──────────────────► 1002 ─────────────► 1002 (12)
1002 | Notebook ──────────────────► 1003 (refunded) ✘
1003 | Planner (refunded) 1004 ─────────────► 1004 (12)
1004 | Notebook ──────────────────► 1005 ─────────────► 1005 (68)
1005 | Notebook ┐
1005 | Planner ┘ ──────────────────►
COUNT(*) on paid rows = 6 ✘ COUNT(DISTINCT order_id) on paid rows = 4 ✔
Alt text: Three columns. On the left, seven order lines from the table. Arrows group lines into five orders in the middle column: 1001, 1002, 1003, 1004 and 1005. Order 1003 is marked refunded and crossed out. The right column shows the four paid orders with their totals: 1001 at 32, 1002 at 12, 1004 at 12 and 1005 at 68. At the bottom: counting rows among paid lines gives 6, marked wrong; counting distinct order IDs among paid lines gives 4, marked correct.
7. Guided Practice
Use the Section 5 table. An AI assistant proposed this query to list paid orders that qualify for free shipping (rule: order total of 30 USD or more):
SELECT order_id, SUM(qty * unit_price) AS order_total
FROM order_lines
WHERE status = 'paid'
GROUP BY order_id
HAVING SUM(qty * unit_price) >= 30;
- Expected answer first: using the visual in Section 6, which orders should qualify?
- Trace: for each paid order, write its total and whether
>= 30is true. (Hint:GROUP BY order_idadds up the lines of each order.) - Compare your trace with your expected answer.
- Write one boundary test: a small made-up order whose total is exactly 30. What should the query return for it?
- Ask an AI assistant to explain this query line by line. Mark any sentence in its explanation that does not match what the code does.
8. Independent Practice
Question: "How many different customers bought a Notebook (paid orders only)?"
Illustrative AI-style proposal:
SELECT COUNT(*) AS notebook_customers
FROM order_lines
WHERE product = 'Notebook' AND status = 'paid';
- Work out the correct answer by hand from the Section 5 table.
- Trace the query. What number does it return, and why?
- Write a corrected query.
- Design a tiny test table (3–4 rows) where the wrong query and the correct query give different answers, and state both answers.
- In one sentence, explain the business consequence if the owner used the wrong number to plan a "thank-you" discount for Notebook customers.
No model answer is shown here.
9. Knowledge Check — Hands-on Coding Check (by tracing)
Part A — Choose the best answer.
A1. An AI-generated query runs without errors. What does that prove? - A) That the result is correct - B) Only that it is valid code; the result still needs checking against an expected answer - C) That the business definition was followed - D) That no rows were excluded
A2. What is the best first step before asking AI to write a query for a metric? - A) Ask the AI to choose the definition. - B) Run the query on the full database straight away. - C) Ask for the shortest possible query. - D) Write the exact definition and, if possible, work out the expected answer on a small sample.
A3. You ask AI to "refactor" a function to make it easier to read. How do you check that it did not change the behaviour? - A) Run (or trace) the same test cases on the old and new versions and compare the results. - B) Read the AI's statement "behaviour unchanged". - C) Check that the new version is shorter. - D) Check that it follows PEP 8 naming.
A4. Which test case is most likely to catch a > vs >= mistake in the rule "free shipping for orders of 30 USD or more"?
- A) An order of 12 USD
- B) An order of 68 USD
- C) An order of exactly 30 USD
- D) An empty table
Part B — Trace this AI-proposed Python function. It is meant to return the number of Planner units sold in paid orders.
def planner_units(lines):
total = 0
for line in lines:
if line["product"] == "Planner":
total = total + line["qty"]
return total
Using the Section 5 table (as a list of lines):
- B1. What does the function return? Show your trace, line by line.
- B2. What should it return?
- B3. Change one line to fix it, and explain the change.
- B4. Write two test cases (input lines + expected output) that would catch this error.
10. AI in Practice
Generate a small code or query proposal, trace it, inspect the output, create tests, and correct a plausible AI error.
- Prompt (synthetic data only):
"Act as a patient data tutor for a beginner. Using the table below, write one SQL query that returns total paid revenue per product, where revenue = qty × unit_price. Explain each line in plain English. Then list 3 test cases I could use to check it, including one that checks refunded orders are excluded. """ (paste the Section 5 table) """
- Expected answer first: calculate paid revenue per product by hand.
- Trace or run the AI's query and compare it with your expected answer.
- Inspect the tests it proposed. Is each one specific (input + expected output)? Add any missing test, especially an empty case (no paid lines).
- Error drill (deliberate correction): the illustrative AI-style "refactor" below was presented as "same behaviour, cleaner code". Find the change in behaviour with a test, then correct it.
# Original
def free_shipping(order_total):
return order_total >= 30
# AI "refactor" (claimed: same behaviour)
def free_shipping(order_total):
return order_total > 30
11. AI Verification
- Expected answer before AI answer: always calculate by hand on a small sample first.
- Trace each clause:
- Which rows does
WHEREkeep? - What doesCOUNTcount: rows or distinct IDs? - What does eachSUMadd up? - Run the four test types: normal, boundary, exclusion and empty.
- Compare the explanation with the code: an explanation that says "orders" when the code counts rows is a red flag.
- Check claims of "unchanged behaviour" with the same tests on the old and new versions.
- Fix the cause: after a correction, re-run all tests, not only the one that failed.
- Privacy and security: - use only synthetic tables in prompts; - never paste real customer data, database passwords, connection strings or API keys into an AI tool; - follow your organization's policy.
12. Business Lens
Compare AI-generated and manually reasoned approaches to the same data task. Neither is automatically better:
| AI-generated approach | Manually reasoned approach | |
|---|---|---|
| Speed | Usually faster to draft | Slower, especially at first |
| Hidden assumptions | Can include filters or counts you did not ask for, or miss ones you needed | Your assumptions are explicit because you made them |
| Explainability | Explanation may not match the code | You can explain every step |
| Scale | Code can run on large data once verified | Hand calculation does not scale |
| Best use together | AI drafts; you verify on a small known sample; then run at scale | Gives the expected answer that tests the AI draft |
In practice, the strongest workflow combines them. Manual reasoning on a small sample becomes the test for the AI-generated code.
13. Workplace Task — Two Approaches, One Answer
Fictional business: Cedar Lane. The owner asks: "What share of this week's paid revenue came from Notebooks?"
- Manual approach: calculate the answer by hand from the Section 5 table, showing your working.
- AI approach: the illustrative AI-style query below was proposed. Trace it.
sql
SELECT SUM(CASE WHEN product = 'Notebook' THEN qty * unit_price ELSE 0 END) * 1.0
/ SUM(qty * unit_price) AS notebook_share
FROM order_lines;
- Do the two approaches agree? If not, identify the exact cause.
- Write a 100–150-word note to the owner covering four points: - the verified answer; - what was wrong with the AI draft, if anything; - how you checked it; - which approach you would use next week, when the table has 5,000 rows, and how you would keep it trustworthy.
14. Mini Challenge
Fictional business: Riverside Bikes tracks repair jobs (synthetic):
| job_id | status | hours |
|---|---|---|
| J1 | done | 2 |
| J2 | done | 3 |
| J3 | cancelled | 0 |
| J4 | done | 1 |
| J5 | done | 2 |
The manager wants the average hours per completed repair to plan staffing. An AI assistant proposed:
SELECT AVG(hours) AS avg_repair_hours FROM repairs;
- Work out the expected answer by hand.
- Trace the AI's query, then find and correct the error.
- Write one test that would catch it.
- In one sentence, explain the staffing risk if the wrong number were used.
Submit before feedback. No solution is provided here.
15. Resources
- Required (about 10 min): PEP 8 – Style Guide for Python Code (Python Software Foundation; status "Active"). Read the introduction "A Foo-lish Consistency…", "Indentation" and "Function and Variable Names". https://peps.python.org/pep-0008/ (Opened and checked 12 Oct 2026.)
- Recommended (about 5 min): ONET OnLine, In Demand: 15-2051.00 – Data Scientists, a list of software skills mentioned in US job postings, drawn from Lightcast data for 2025. Note the data source and dates at the bottom of the page. https://www.onetonline.org/link/demand/15-2051.00 (Opened and checked 12 Oct 2026. It is a US signal, and requirements vary by employer.)*
- D.World AI workflow: the Curriculum Bible's AI Integration Standard. For code: "run it, inspect assumptions, add tests and compare with expected behavior". For SQL: "execute on known data and verify joins, filters and totals". This lesson's Generate → run → test → verify follows it.
- Deeper (optional): none required. Python fundamentals (U04) and testing and debugging (U05) are taught later.
16. Person to Follow / Role Model
Practitioner perspective (no named person). The D.World map lists "Practical AI/data practitioner", a type of role rather than a specific person, so no individual is named here.
Try this: if you know someone who writes code, SQL or spreadsheet formulas at work, ask: 1. "When you use AI to draft code, how do you check it before you trust it?" 2. "Can you remember a time when code ran without errors but gave the wrong answer?"
Write down their checking habits and compare them with Section 11. If you cannot ask anyone, write your own checklist of five checks you will use in U04.
17. Glossary
| Term | Meaning in this lesson |
|---|---|
| SQL | A language for asking questions of data stored in tables (databases) |
| Query | One SQL request, such as SELECT … FROM … WHERE … |
| Refactor | Rewrite code to be clearer without changing what it does |
| Debug | Find and fix the cause of wrong behaviour |
| Trace | Follow code step by step on a known input, writing down intermediate values |
| Test case | A specific input plus the output you expect |
| Boundary case | A test exactly at the edge of a rule (e.g., exactly 30.00) |
| Expected answer | The answer worked out independently, before checking the code's output |
COUNT(*) vs COUNT(DISTINCT id) |
Counts rows vs counts different IDs |
| Silent error | An error that produces a believable result instead of a crash |
| PEP 8 | Python's official style guide for readable code |
18. Reflection
Which mistake in this lesson would you have missed without working out the expected answer first? What does that tell you about the order in which you should do things?
19. Next Step
You have now checked AI-drafted code. In L12 — Hallucinations, Privacy & Responsible AI Use, you will learn three more things: - how to recognise invented facts and overconfidence in AI answers; - how to decide what data must never be shared with an AI tool; - when not to use AI at all.
20. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Hands-on coding check, Part A (A1–A4) | Understands why running code is not the same as verifying it | 3 or more of 4 correct |
| Hands-on coding check, Part B (B1–B4) | Traces code, finds and fixes a missing filter, writes tests | Rubric L11-KCB; B1 and B2 must be correct |
| AI in Practice (tests and error drill) | Generates, traces, tests and corrects an AI proposal | Rubric L11-AI |
| Guided and independent practice, workplace note, mini challenge | Verifies AI SQL against expected answers; compares approaches | Rubrics L11-GP, L11-IP, L11-WT, L11-MC |
References
- van Rossum, G., Warsaw, B., & Coghlan, A. PEP 8 – Style Guide for Python Code (created 5 July 2001; status Active). https://peps.python.org/pep-0008/ (opened and checked 12 Oct 2026). Supports: "code is read much more often than it is written"; lowercase-with-underscores function and variable names; 4 spaces per indentation level.
- ONET OnLine. In Demand: 15-2051.00 – Data Scientists.* https://www.onetonline.org/link/demand/15-2051.00 (opened and checked 12 Oct 2026; site updated 6 Oct 2026). Supports: Python and SQL listed first among software skills in US job postings; source "Lightcast job postings data for the US nationwide between January 1, 2025 and December 31, 2025".
- D.World Curriculum Bible v1.0, AI Integration Standard (Code and SQL rows). Internal.
- SQL and Python examples were executed for this lesson on the synthetic table using SQLite and Python on 12 Oct 2026; results are recorded in the QA report.
- D.World Curriculum Map v1.0 (L11 row). Internal.
L11 — الذكاء الاصطناعي في البرمجة وSQL والتحليل
ملف المتعلّم. الإجابات والحلول النموذجية في ملف منفصل خاص بالمدرّس فقط. الإصدار: U03 v1.0 · تاريخ المحتوى: 12 أكتوبر 2026. تقديرات الوقت مبدئية إلى أن تُجرَّب مع المتعلّمين.
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | الذكاء الاصطناعي في البرمجة وSQL والتحليل |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U03 — الذكاء الاصطناعي في العمل مع البيانات |
| رقم الدرس | L11 |
| المهارات | البرمجة بمساعدة الذكاء الاصطناعي؛ التحقق |
| المستوى | مبتدئ |
| الوقت المتوقع | حوالي ساعتين (مبدئي) |
| المتطلبات السابقة | L09–L10. وL07 في U02 (AOV = الإيرادات ÷ الطلبات). لا تحتاج أي خبرة في البرمجة. ستتعلم Python في U04، وحل المشكلات والاختبار في U05؛ أما هنا فأنت فقط تقرأ وتتتبّع أمثلة قصيرة جدًا. |
تفصيل الوقت (مبدئي): المفهوم والمثال المحلول 35 دقيقة · التدريب الموجَّه 15 دقيقة · التدريب المستقل 15 دقيقة · اختبار الفهم 15 دقيقة · الذكاء الاصطناعي في التطبيق والتحقق 20 دقيقة · مهمة العمل 15 دقيقة · التحدي القصير 5 دقائق.
عن تشغيل الكود: لا تحتاج إلى تثبيت أي شيء أو إنشاء أي حساب في هذا الدرس. كل مهمة يمكن إنجازها بالتتبع اليدوي على جدول صغير. وإذا أعطاك المدرّس بيئة آمنة لتشغيل Python أو SQL، فيمكنك تشغيل الأمثلة هناك أيضًا. التتبع اليدوي أبطأ، لكنه يتحقق من المنطق نفسه. ولاحظ حدوده: فهو لا يكتشف كل مشكلة يكتشفها تشغيل الكود، مثل أخطاء الكتابة.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تستخدم الذكاء الاصطناعي لشرح كود أو SQL بسيط، وكتابة مسودته، وإعادة هيكلته (refactor)، وتصحيح أخطائه (debug)، وأن تتحقق من النتيجة بحساب الإجابة المتوقعة، وتتبع الكود على جدول صغير، وكتابة حالات اختبار بسيطة.
هدف خريطة D.World (بنصه): Use AI to explain, draft, refactor, and debug simple code/SQL while validating results.
3. لماذا يهمّك هذا؟
مساعدات الذكاء الاصطناعي تُستخدم كثيرًا لكتابة مسودات الكود واستعلامات قواعد البيانات (SQL). والكود الذي يكتبه الذكاء الاصطناعي قد يبدو مرتبًا، وفيه تعليقات، ومع ذلك يجيب عن سؤال مختلف عن الذي سألته. ومن الأمثلة الشائعة: عدّ الصفوف بدلًا من الطلبات، أو احتساب المبيعات المستردة.
هذه الأخطاء لا توقف أي شيء عن العمل. بل تنتج رقمًا قابلًا للتصديق، ولهذا هي خطيرة. ففي العمل مع البيانات، قد ينتهي رقم كهذا في تقرير أو قرار. المبدأ الأساسي: ولِّد ← شغّل ← اختبر ← تحقّق.
تظهر Python وSQL في أعلى قائمة O*NET لمهارات البرمجيات الأكثر ذكرًا في إعلانات وظائف علماء البيانات في الولايات المتحدة (بيانات إعلانات Lightcast لعام 2025؛ راجع المصادر). هذا مؤشر أمريكي، والمتطلبات تختلف من جهة توظيف لأخرى. ونذكره هنا لنشرح لماذا تهم البرمجة بمساعدة الذكاء الاصطناعي، لا كوعد بشأن الوظائف.
4. المفهوم
أربع طرق يساعد بها الذكاء الاصطناعي في الكود وSQL
| الاستخدام | مثال على الطلب | ما يجب أن تفعله رغم ذلك |
|---|---|---|
| الشرح (Explain) | "Explain this query line by line for a beginner." (اشرح هذا الاستعلام سطرًا بسطر لمبتدئ.) | قارن الشرح بما يفعله الكود فعلًا |
| كتابة المسودة (Draft) | "Write SQL to calculate average order value for paid orders." (اكتب SQL لحساب متوسط قيمة الطلب للطلبات المدفوعة.) | احسب الإجابة المتوقعة بنفسك وقارن |
| إعادة الهيكلة (Refactor) | "Make this function easier to read without changing what it does." (اجعل هذه الدالة أسهل في القراءة دون تغيير ما تفعله.) | اختبر أن السلوك لم يتغير فعلًا |
| تصحيح الأخطاء (Debug) | "This gives 20.67 but I expected 31. Why?" (هذا يعطي 20.67 لكنني توقعت 31. لماذا؟) | أكّد الإصلاح باختبار، وأصلح السبب لا العَرَض فقط |
ولِّد ← شغّل ← اختبر ← تحقّق
- ولِّد: احصل على مسودة من الذكاء الاصطناعي، باستخدام طلب منظّم (L10) يتضمن التعريف الدقيق الذي تحتاجه، مثل "AOV = الإيرادات المدفوعة ÷ عدد الطلبات المدفوعة المختلفة".
- شغّل (أو تتبّع): نفّذه على جدول صغير تعرف إجابته مسبقًا، أو تتبّعه يدويًا.
- اختبر: اكتب حالات اختبار (test cases). كل اختبار هو مدخلات مع المخرجات التي تتوقعها:
- حالة عادية؛
- حالة حدّية (مثلًا 30.00 بالضبط عندما تكون القاعدة "30 أو أكثر")؛
- حالة استبعاد (مثلًا طلب مسترد يجب ألا يُحسب)؛
- حالة فارغة أو غير معتادة (مثلًا لا توجد طلبات مدفوعة).
- تحقّق: تأكد أن النتيجة تطابق تعريف العمل، لا أن الكود يعمل فقط. وراجع الافتراضات المتعلقة بالتصفية والعدّ والتقريب.
سهولة القراءة تساعد على التحقق
يذكر PEP 8، وهو دليل الأسلوب الرسمي في Python، أن "code is read much more often than it is written" (الكود يُقرأ أكثر بكثير مما يُكتب). ويوصي بما يلي:
- أسماء الدوال والمتغيرات بحروف صغيرة، مع فصل الكلمات بشرطة سفلية (مثل
average_order_value)؛ - 4 مسافات لكل مستوى إزاحة.
الأسماء الواضحة تجعل من الأسهل أن ترى هل يفعل الكود ما يدّعيه.
أشهر الأخطاء الصامتة في كود البيانات البسيط
- عدّ الصفوف (البنود) بينما تقصد الطلبات أو العملاء (استخدم المعرّفات المختلفة distinct).
- نسيان شرط تصفية (مثلًا احتساب الطلبات المستردة).
- حدّ خاطئ (
>بدلًا من>=). - القسمة بين أعداد صحيحة: في بعض قواعد البيانات، قسمة عددين صحيحين تحذف الكسور العشرية. جُرّب هذا في SQLite لهذا الدرس؛ والسلوك يختلف من قاعدة بيانات لأخرى.
5. مثال محلول
جدول مصطنع order_lines (Cedar Lane الخيالية، أسبوع واحد). كل صف هو بند في طلب، والطلب الواحد قد يضم عدة بنود.
| order_id | customer_id | product | qty | unit_price | status |
|---|---|---|---|---|---|
| 1001 | C01 | Notebook | 2 | 12 | paid |
| 1001 | C01 | Pen set | 1 | 8 | paid |
| 1002 | C02 | Notebook | 1 | 12 | paid |
| 1003 | C03 | Planner | 1 | 20 | refunded |
| 1004 | C01 | Notebook | 1 | 12 | paid |
| 1005 | C04 | Notebook | 4 | 12 | paid |
| 1005 | C04 | Planner | 1 | 20 | paid |
المهمة: متوسط قيمة الطلب (AOV) للطلبات المدفوعة (paid).
الخطوة 1 — احسب الإجابة المتوقعة يدويًا (قبل سؤال الذكاء الاصطناعي):
| البند المدفوع | qty × unit_price |
|---|---|
| 1001 Notebook | 2 × 12 = 24 |
| 1001 Pen set | 1 × 8 = 8 |
| 1002 Notebook | 1 × 12 = 12 |
| 1004 Notebook | 1 × 12 = 12 |
| 1005 Notebook | 4 × 12 = 48 |
| 1005 Planner | 1 × 20 = 20 |
| الإيرادات المدفوعة | 124 |
الطلبات المدفوعة المختلفة: 1001، 1002، 1004، 1005 = 4. AOV المتوقع = 124 ÷ 4 = 31.00 دولار.
الخطوة 2 — اقتراح توضيحي بأسلوب الذكاء الاصطناعي (كتبته D.World لتُظهر خطأً معتادًا):
-- Average order value for paid orders
SELECT SUM(qty * unit_price) * 1.0 / COUNT(*) AS aov
FROM order_lines
WHERE status = 'paid';
الخطوة 3 — تتبّعه:
WHERE status = 'paid'يُبقي 6 بنود. ✔ (الطلب المسترد مستبعد.)SUM(qty * unit_price)= 124. ✔COUNT(*)يعدّ الصفوف، فيعطي 6 بنود، وليس 4 طلبات. ✘- النتيجة: 124 ÷ 6 = 20.67، وهي لا تطابق القيمة المتوقعة 31.00.
التعليق يقول "average order value" (متوسط قيمة الطلب)، لكن الكود يحسب متوسط قيمة البند.
الخطوة 4 — صحّح وأعِد الاختبار:
SELECT SUM(qty * unit_price) * 1.0 / COUNT(DISTINCT order_id) AS aov
FROM order_lines
WHERE status = 'paid';
التتبع: 124 ÷ 4 = 31.00 ✔. شُغّل الاستعلامان في SQLite على هذا الجدول نفسه لهذا الدرس، وأعطيا 20.67 و31.0.
عن * 1.0: بدونها، أعاد SQLite القيمة 20 بدلًا من 20.67 في الاستعلام الأول، لأنه قسم عددين صحيحين. وهذا خطأ صامت ثانٍ يجب الانتباه له.
6. شرح بصري
order_lines (7 rows) orders (5) paid orders (4)
1001 | Notebook ┐ 1001 ─────────────► 1001 (32)
1001 | Pen set ┘ ──────────────────► 1002 ─────────────► 1002 (12)
1002 | Notebook ──────────────────► 1003 (refunded) ✘
1003 | Planner (refunded) 1004 ─────────────► 1004 (12)
1004 | Notebook ──────────────────► 1005 ─────────────► 1005 (68)
1005 | Notebook ┐
1005 | Planner ┘ ──────────────────►
COUNT(*) on paid rows = 6 ✘ COUNT(DISTINCT order_id) on paid rows = 4 ✔
وصف الرسم: ثلاثة أعمدة. على اليسار سبعة بنود طلبات من الجدول. وتجمع الأسهم البنود في خمسة طلبات في العمود الأوسط: 1001، و1002، و1003، و1004، و1005. والطلب 1003 مكتوب عليه refunded (مسترد) ومشطوب. ويعرض العمود الأيمن الطلبات المدفوعة الأربعة بإجمالياتها: 1001 بقيمة 32، و1002 بقيمة 12، و1004 بقيمة 12، و1005 بقيمة 68. وفي الأسفل: عدّ الصفوف بين البنود المدفوعة يعطي 6، مع علامة خطأ؛ وعدّ معرّفات الطلبات المختلفة بين البنود المدفوعة يعطي 4، مع علامة صح.
7. تدريب موجَّه
استخدم جدول القسم 5. اقترح مساعد ذكاء اصطناعي هذا الاستعلام لعرض الطلبات المدفوعة المؤهلة للشحن المجاني (القاعدة: إجمالي الطلب 30 دولارًا أو أكثر):
SELECT order_id, SUM(qty * unit_price) AS order_total
FROM order_lines
WHERE status = 'paid'
GROUP BY order_id
HAVING SUM(qty * unit_price) >= 30;
- الإجابة المتوقعة أولًا: باستخدام الرسم في القسم 6، أي الطلبات يجب أن تكون مؤهلة؟
- تتبّع: لكل طلب مدفوع، اكتب إجماليه وهل الشرط
>= 30صحيح. (تلميح:GROUP BY order_idيجمع بنود كل طلب.) - قارن تتبعك بإجابتك المتوقعة.
- اكتب اختبارًا حدّيًا واحدًا: طلبًا صغيرًا مختلقًا إجماليه 30 بالضبط. ماذا يجب أن يُرجع الاستعلام له؟
- اطلب من مساعد ذكاء اصطناعي أن يشرح هذا الاستعلام سطرًا بسطر. وضع علامة على أي جملة في شرحه لا تطابق ما يفعله الكود.
8. تدريب مستقل
السؤال: "كم عدد العملاء المختلفين الذين اشتروا Notebook (في الطلبات المدفوعة فقط)؟"
اقتراح توضيحي بأسلوب الذكاء الاصطناعي:
SELECT COUNT(*) AS notebook_customers
FROM order_lines
WHERE product = 'Notebook' AND status = 'paid';
- احسب الإجابة الصحيحة يدويًا من جدول القسم 5.
- تتبّع الاستعلام. ما الرقم الذي يُرجعه، ولماذا؟
- اكتب استعلامًا مصحّحًا.
- صمّم جدول اختبار صغيرًا (3–4 صفوف) يعطي فيه الاستعلام الخاطئ والاستعلام الصحيح إجابتين مختلفتين، واذكر الإجابتين.
- في جملة واحدة، اشرح العاقبة على العمل لو استخدم صاحب المتجر الرقم الخاطئ للتخطيط لخصم "شكرًا" لعملاء Notebook.
لا توجد إجابة نموذجية هنا.
9. اختبار الفهم — فحص عملي للكود (بالتتبع)
الجزء A — اختر أفضل إجابة.
A1. استعلام كتبه الذكاء الاصطناعي يعمل دون أخطاء. ماذا يثبت ذلك؟ - A) أن النتيجة صحيحة - B) فقط أنه كود صالح؛ والنتيجة ما زالت بحاجة إلى مقارنة بإجابة متوقعة - C) أن تعريف العمل قد اتُّبع - D) أنه لم يُستبعد أي صف
A2. ما أفضل خطوة أولى قبل أن تطلب من الذكاء الاصطناعي كتابة استعلام لمقياس ما؟ - A) أطلب من الذكاء الاصطناعي أن يختار التعريف. - B) أشغّل الاستعلام على قاعدة البيانات كاملة فورًا. - C) أطلب أقصر استعلام ممكن. - D) أكتب التعريف الدقيق، وإن أمكن أحسب الإجابة المتوقعة على عيّنة صغيرة.
A3. طلبت من الذكاء الاصطناعي "إعادة هيكلة" دالة لتصبح أسهل في القراءة. كيف تتأكد أنه لم يغيّر سلوكها؟ - A) أشغّل (أو أتتبّع) حالات الاختبار نفسها على النسختين القديمة والجديدة وأقارن النتائج. - B) أقرأ عبارة الذكاء الاصطناعي "السلوك لم يتغير". - C) أتأكد أن النسخة الجديدة أقصر. - D) أتأكد أنها تتبع تسمية PEP 8.
A4. أي حالة اختبار هي الأرجح لاكتشاف خطأ > مقابل >= في القاعدة "شحن مجاني للطلبات من 30 دولارًا فأكثر"؟
- A) طلب بقيمة 12 دولارًا
- B) طلب بقيمة 68 دولارًا
- C) طلب بقيمة 30 دولارًا بالضبط
- D) جدول فارغ
الجزء B — تتبّع دالة Python هذه التي اقترحها الذكاء الاصطناعي. المفترض أن تُرجع عدد وحدات Planner المباعة في الطلبات المدفوعة.
def planner_units(lines):
total = 0
for line in lines:
if line["product"] == "Planner":
total = total + line["qty"]
return total
باستخدام جدول القسم 5 (كقائمة بنود):
- B1. ماذا تُرجع الدالة؟ اعرض تتبعك سطرًا بسطر.
- B2. ماذا يجب أن تُرجع؟
- B3. غيّر سطرًا واحدًا لإصلاحها، واشرح التغيير.
- B4. اكتب حالتي اختبار (بنود المدخلات + المخرجات المتوقعة) تكتشفان هذا الخطأ.
10. الذكاء الاصطناعي في التطبيق
ولِّد اقتراحًا صغيرًا لكود أو استعلام، وتتبّعه، وافحص مخرجاته، واكتب اختبارات، وصحّح خطأً معقول المظهر من الذكاء الاصطناعي.
- الطلب (بيانات مصطنعة فقط):
"Act as a patient data tutor for a beginner. Using the table below, write one SQL query that returns total paid revenue per product, where revenue = qty × unit_price. Explain each line in plain English. Then list 3 test cases I could use to check it, including one that checks refunded orders are excluded. """ (paste the Section 5 table) """
وبالعربية: "تصرّف كمعلّم بيانات صبور لمبتدئ. باستخدام الجدول التالي، اكتب استعلام SQL واحدًا يُرجع إجمالي الإيرادات المدفوعة لكل منتج، حيث الإيرادات = qty × unit_price. اشرح كل سطر بلغة بسيطة. ثم اذكر 3 حالات اختبار يمكنني استخدامها للتحقق منه، منها حالة تتأكد من استبعاد الطلبات المستردة. (الصق جدول القسم 5 بين علامتي """)"
- الإجابة المتوقعة أولًا: احسب الإيرادات المدفوعة لكل منتج يدويًا.
- تتبّع أو شغّل استعلام الذكاء الاصطناعي وقارنه بإجابتك المتوقعة.
- افحص الاختبارات التي اقترحها. هل كل اختبار محدد (مدخلات + مخرجات متوقعة)؟ أضف أي اختبار ناقص، خاصة حالة فارغة (لا بنود مدفوعة).
- تدريب على الخطأ (تصحيح متعمّد): "إعادة الهيكلة" التوضيحية التالية بأسلوب الذكاء الاصطناعي قُدِّمت على أنها "same behaviour, cleaner code" (السلوك نفسه، وكود أنظف). اكتشف التغيّر في السلوك باختبار، ثم صحّحه.
# Original
def free_shipping(order_total):
return order_total >= 30
# AI "refactor" (claimed: same behaviour)
def free_shipping(order_total):
return order_total > 30
11. التحقق من مخرجات الذكاء الاصطناعي
- الإجابة المتوقعة قبل إجابة الذكاء الاصطناعي: احسب دائمًا يدويًا على عيّنة صغيرة أولًا.
- تتبّع كل جزء:
- أي الصفوف يُبقيها
WHERE؟ - ماذا يعدّ
COUNT: الصفوف أم المعرّفات المختلفة؟ - ماذا يجمع كل
SUM؟
- أي الصفوف يُبقيها
- شغّل أنواع الاختبار الأربعة: العادية، والحدّية، والاستبعاد، والفارغة.
- قارن الشرح بالكود: الشرح الذي يقول "طلبات" بينما الكود يعدّ صفوفًا علامة تحذير.
- تحقّق من ادعاءات "السلوك لم يتغير" بالاختبارات نفسها على النسختين القديمة والجديدة.
- أصلح السبب: بعد أي تصحيح، أعِد تشغيل كل الاختبارات، لا الاختبار الذي فشل فقط.
- الخصوصية والأمان:
- استخدم جداول مصطنعة فقط في الطلبات؛
- لا تلصق أبدًا بيانات عملاء حقيقية، أو كلمات مرور قواعد البيانات، أو سلاسل الاتصال (connection strings)، أو مفاتيح API في أداة ذكاء اصطناعي؛
- اتبع سياسة مؤسستك.
12. منظور الأعمال
قارن بين الطريقة التي يولّدها الذكاء الاصطناعي والطريقة القائمة على التفكير اليدوي لمهمة البيانات نفسها. لا توجد طريقة أفضل تلقائيًا:
| الطريقة التي يولّدها الذكاء الاصطناعي | الطريقة القائمة على التفكير اليدوي | |
|---|---|---|
| السرعة | عادةً أسرع في كتابة المسودة | أبطأ، خاصة في البداية |
| الافتراضات الخفية | قد تتضمن شروط تصفية أو طرق عدّ لم تطلبها، أو تُغفل ما احتجته | افتراضاتك صريحة لأنك أنت من وضعها |
| قابلية الشرح | قد لا يطابق الشرح الكود | تستطيع شرح كل خطوة |
| الحجم | الكود يمكن تشغيله على بيانات كبيرة بعد التحقق منه | الحساب اليدوي لا يصلح للأحجام الكبيرة |
| أفضل استخدام لهما معًا | الذكاء الاصطناعي يكتب المسودة؛ وأنت تتحقق على عيّنة صغيرة معروفة؛ ثم تشغّل على الحجم الكامل | يعطي الإجابة المتوقعة التي تختبر مسودة الذكاء الاصطناعي |
عمليًا، أقوى سير عمل يجمع بين الطريقتين. فالتفكير اليدوي على عيّنة صغيرة يصبح هو الاختبار للكود الذي يولّده الذكاء الاصطناعي.
13. مهمة عمل — طريقتان، وإجابة واحدة
نشاط خيالي: Cedar Lane. يسأل صاحب المتجر: "ما نسبة الإيرادات المدفوعة هذا الأسبوع التي جاءت من Notebooks؟"
- الطريقة اليدوية: احسب الإجابة يدويًا من جدول القسم 5، مع عرض خطوات الحل.
- طريقة الذكاء الاصطناعي: اقتُرح الاستعلام التوضيحي التالي بأسلوب الذكاء الاصطناعي. تتبّعه.
SELECT SUM(CASE WHEN product = 'Notebook' THEN qty * unit_price ELSE 0 END) * 1.0
/ SUM(qty * unit_price) AS notebook_share
FROM order_lines;
- هل تتفق الطريقتان؟ إن لم تتفقا، فحدِّد السبب بالضبط.
- اكتب ملاحظة من 100 إلى 150 كلمة لصاحب المتجر تغطي أربع نقاط:
- الإجابة المتحقَّق منها؛
- ما الخطأ في مسودة الذكاء الاصطناعي، إن وُجد؛
- كيف تحققت من ذلك؛
- أي طريقة ستستخدم الأسبوع القادم، عندما يصبح الجدول 5,000 صف، وكيف ستحافظ على موثوقيتها.
14. تحدٍّ قصير
نشاط خيالي: تسجّل Riverside Bikes أعمال الإصلاح (بيانات مصطنعة):
| job_id | status | hours |
|---|---|---|
| J1 | done | 2 |
| J2 | done | 3 |
| J3 | cancelled | 0 |
| J4 | done | 1 |
| J5 | done | 2 |
يريد المدير متوسط الساعات لكل إصلاح مكتمل ليخطط لعدد العاملين. واقترح مساعد ذكاء اصطناعي:
SELECT AVG(hours) AS avg_repair_hours FROM repairs;
- احسب الإجابة المتوقعة يدويًا.
- تتبّع استعلام الذكاء الاصطناعي، ثم اكتشف الخطأ وصحّحه.
- اكتب اختبارًا واحدًا يكتشف هذا الخطأ.
- في جملة واحدة، اشرح الخطر على التخطيط لعدد العاملين لو استُخدم الرقم الخاطئ.
سلّم إجابتك قبل أي ملاحظات. لا يوجد حل هنا.
15. المصادر
- مطلوب (حوالي 10 دقائق): PEP 8 – Style Guide for Python Code (Python Software Foundation؛ الحالة "Active"). اقرأ المقدمة "A Foo-lish Consistency…"، وقسم "Indentation"، وقسم "Function and Variable Names". https://peps.python.org/pep-0008/ (فُتح وروجع في 12 أكتوبر 2026.)
- مقترح (حوالي 5 دقائق): O*NET OnLine، In Demand: 15-2051.00 – Data Scientists، وهي قائمة بمهارات البرمجيات المذكورة في إعلانات الوظائف الأمريكية، مأخوذة من بيانات Lightcast لعام 2025. لاحظ مصدر البيانات والتواريخ في أسفل الصفحة. https://www.onetonline.org/link/demand/15-2051.00 (فُتحت وروجعت في 12 أكتوبر 2026. هي مؤشر أمريكي، والمتطلبات تختلف من جهة توظيف لأخرى.)
- سير عمل الذكاء الاصطناعي في D.World: معيار دمج الذكاء الاصطناعي في Curriculum Bible. للكود: "run it, inspect assumptions, add tests and compare with expected behavior" (شغّله، وافحص الافتراضات، وأضف اختبارات، وقارن بالسلوك المتوقع). ولـ SQL: "execute on known data and verify joins, filters and totals" (نفّذه على بيانات معروفة، وتحقق من الربط والتصفية والإجماليات). وسير "ولِّد ← شغّل ← اختبر ← تحقّق" في هذا الدرس يتبعه.
- للتعمّق (اختياري): لا شيء مطلوب. أساسيات Python (U04) والاختبار وتصحيح الأخطاء (U05) تُدرَّس لاحقًا.
16. شخصية تتابعها / قدوة
منظور الممارس (دون تسمية شخص). تذكر خريطة D.World عبارة "Practical AI/data practitioner" (ممارس عملي للذكاء الاصطناعي والبيانات)، وهي نوع من الأدوار وليست شخصًا محددًا، لذلك لا نسمّي هنا أي فرد.
جرّب هذا: إن كنت تعرف شخصًا يكتب كودًا أو SQL أو معادلات جداول بيانات في عمله، فاسأله:
- "عندما تستخدم الذكاء الاصطناعي لكتابة مسودة كود، كيف تتحقق منها قبل أن تثق بها؟"
- "هل تتذكر مرة عمل فيها الكود دون أخطاء لكنه أعطى إجابة خاطئة؟"
سجّل عاداته في التحقق وقارنها بالقسم 11. وإن لم تستطع سؤال أحد، فاكتب قائمتك الخاصة من خمسة فحوصات ستستخدمها في U04.
17. المصطلحات
| المصطلح | معناه في هذا الدرس |
|---|---|
| SQL | لغة لطرح الأسئلة على البيانات المخزنة في جداول (قواعد بيانات) |
| الاستعلام (Query) | طلب SQL واحد، مثل SELECT … FROM … WHERE … |
| إعادة الهيكلة (Refactor) | إعادة كتابة الكود ليصبح أوضح دون تغيير ما يفعله |
| تصحيح الأخطاء (Debug) | إيجاد سبب السلوك الخاطئ وإصلاحه |
| التتبع (Trace) | متابعة الكود خطوة بخطوة على مدخلات معروفة، مع كتابة القيم الوسيطة |
| حالة الاختبار (Test case) | مدخلات محددة مع المخرجات التي تتوقعها |
| الحالة الحدّية (Boundary case) | اختبار على حافة القاعدة تمامًا (مثل 30.00 بالضبط) |
| الإجابة المتوقعة (Expected answer) | الإجابة المحسوبة بشكل مستقل، قبل مراجعة مخرجات الكود |
COUNT(*) مقابل COUNT(DISTINCT id) |
عدّ الصفوف مقابل عدّ المعرّفات المختلفة |
| الخطأ الصامت (Silent error) | خطأ ينتج نتيجة قابلة للتصديق بدلًا من أن يوقف البرنامج |
| PEP 8 | دليل الأسلوب الرسمي في Python لكتابة كود سهل القراءة |
18. تأمّل
أي خطأ في هذا الدرس كان سيفوتك لو لم تحسب الإجابة المتوقعة أولًا؟ وماذا يخبرك ذلك عن الترتيب الذي يجب أن تعمل به؟
19. الخطوة التالية
تحققت الآن من كود كتبه الذكاء الاصطناعي. في L12 — الهلوسة والخصوصية والاستخدام المسؤول للذكاء الاصطناعي، ستتعلم ثلاثة أشياء أخرى:
- كيف تتعرّف على الحقائق المخترعة والثقة الزائدة في إجابات الذكاء الاصطناعي؛
- كيف تقرر ما البيانات التي يجب ألا تُشارك أبدًا مع أداة ذكاء اصطناعي؛
- متى لا تستخدم الذكاء الاصطناعي إطلاقًا.
20. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| الفحص العملي للكود، الجزء A (A1–A4) | فهم أن تشغيل الكود ليس هو التحقق منه | 3 إجابات صحيحة أو أكثر من 4 |
| الفحص العملي للكود، الجزء B (B1–B4) | تتبع الكود، واكتشاف شرط تصفية ناقص وإصلاحه، وكتابة الاختبارات | معايير L11-KCB؛ ويجب أن تكون B1 وB2 صحيحتين |
| الذكاء الاصطناعي في التطبيق (الاختبارات وتدريب الخطأ) | توليد اقتراح من الذكاء الاصطناعي، وتتبعه، واختباره، وتصحيحه | معايير L11-AI |
| التدريب الموجَّه والمستقل، وملاحظة العمل، والتحدي القصير | التحقق من SQL الذي كتبه الذكاء الاصطناعي مقارنةً بالإجابات المتوقعة؛ ومقارنة الطرق | معايير L11-GP وL11-IP وL11-WT وL11-MC |
المراجع
- van Rossum, G., Warsaw, B., & Coghlan, A. PEP 8 – Style Guide for Python Code (أُنشئ في 5 يوليو 2001؛ الحالة Active). https://peps.python.org/pep-0008/ (فُتح وروجع في 12 أكتوبر 2026). يدعم: "code is read much more often than it is written"؛ وأسماء الدوال والمتغيرات بحروف صغيرة مع شرطة سفلية؛ و4 مسافات لكل مستوى إزاحة.
- O*NET OnLine. In Demand: 15-2051.00 – Data Scientists. https://www.onetonline.org/link/demand/15-2051.00 (فُتحت وروجعت في 12 أكتوبر 2026؛ حُدّث الموقع في 6 أكتوبر 2026). يدعم: ورود Python وSQL أولًا بين مهارات البرمجيات في إعلانات الوظائف الأمريكية؛ والمصدر "Lightcast job postings data for the US nationwide between January 1, 2025 and December 31, 2025".
- D.World Curriculum Bible v1.0، معيار دمج الذكاء الاصطناعي (صفا الكود وSQL). وثيقة داخلية.
- نُفّذت أمثلة SQL وPython لهذا الدرس على الجدول المصطنع باستخدام SQLite وPython في 12 أكتوبر 2026؛ والنتائج مسجلة في تقرير ضمان الجودة.
- D.World Curriculum Map v1.0 (صف L11). وثيقة داخلية.
L12 · Hallucinations, Privacy & Responsible AI UseL12 · الهلوسة والخصوصية والاستخدام المسؤول للذكاء الاصطناعي Freeمجاني
L12 — Hallucinations, Privacy & Responsible AI Use
Learner file. Answers and model solutions are in a separate instructor-only file. Version: U03 v1.0 · Content date: 12 October 2026. Time estimates are provisional until learner-tested. This lesson explains general principles; it is not legal advice. Privacy laws and organizational policies vary by country and employer.
1. Lesson Identity
| Field | Value |
|---|---|
| Title | Hallucinations, Privacy & Responsible AI Use |
| Stage | Stage 1 — Foundations |
| Unit | U03 — AI for Data Work |
| Lesson ID | L12 |
| Skills | Risk awareness; verification |
| Difficulty | Beginner |
| Estimated time | About 1 hour 45 minutes (provisional) |
| Prerequisites | L09–L11. U02 L08 (the November/December "sales are down" table). |
Time breakdown (provisional): concept and worked example, 30 min · guided practice, 15 min · independent practice, 10 min · knowledge check (scenario assessment), 15 min · AI in Practice and Verification, 15 min · workplace task, 15 min · mini challenge, 5 min.
2. Learning Objective
By the end of this lesson, you will be able to recognise three things: - hallucinations (invented or unsupported content) in AI output; - unsafe data sharing; - overconfidence, both the AI's tone and your own over-reliance.
You will also be able to decide, using stated rules, when AI should not be used and what data must not be shared.
D.World map objective (verbatim): Recognize hallucinations, unsafe data sharing, overconfidence, and when not to use AI.
3. Why It Matters
Two kinds of mistake cause most real AI problems in data work:
- Trusting what comes out: accepting an invented cause, number or source because it sounds sure.
- Sharing what should not go in: pasting customer details, confidential figures or passwords into a tool that is not approved for them.
Both are easy to make when you are busy. Both can harm customers, colleagues and the business, and neither can always be undone. Key principle: never treat confidence as evidence.
4. Concept
Hallucinations (confabulation)
NIST's Generative AI Profile calls this risk confabulation: "the production of confidently stated but erroneous or false content", known colloquially as "hallucinations" (L09). Common forms in data work:
| Form | Example |
|---|---|
| Invented fact or number | "Industry conversion averages 2.5%" (no source) |
| Invented source | A report title or link that does not exist |
| Invented cause | "Sales fell because of a competitor's discount" (no competitor data given) |
| Filled-in missing context | Assuming what a column means, a date format, or a time period |
| Confident wrong calculation | A neat number with a formula error (L11) |
Warning signs: - precise numbers or quotations with no source; - sources you cannot find; - causes the data does not show; - an answer to a question that the input could not answer; - details that change when you ask again.
Overconfidence: two sides
- The AI's tone: outputs are usually fluent and assured whether they are right or wrong. Tone is not evidence.
- The human's trust: NIST lists Human-AI Configuration as a generative-AI risk. It includes "automation bias" and "over-reliance". This is the human tendency to accept a system's output without enough checking. Your checking habit is the control.
Privacy and unsafe data sharing
What you type into an AI tool may be stored, reviewed or processed outside your control. What happens depends on the tool, its settings and your organization's agreement with the provider. NIST describes the Data Privacy risk as impacts from "leakage and unauthorized use, disclosure, or de-anonymization of" personal or sensitive information.
D.World privacy checklist. Answer it before pasting anything into an AI tool:
- Personal data? Does the text identify a person directly (name, email, phone, address, account number) or indirectly (a combination of details)?
- Confidential? Is it non-public company information (unreleased figures, contracts, plans)?
- Secrets? Does it contain passwords, API keys, database connection strings, verification codes or payment-card details? These are never shared with any AI tool.
- Approved tool? Is this tool approved by your organization for this type of data? Do you know its data settings?
- Necessary? Could you use synthetic, aggregated or properly anonymised data instead?
- Permitted use? Do you have the right to use this data for this purpose under policy and applicable law?
- Headline test: would you be comfortable if this exact text became visible outside your team?
If any answer is uncertain, do not paste the data. Ask, or use synthetic data.
Note: deleting names does not always make data anonymous. A combination of details, such as a postcode, a date of birth and a rare purchase, can still point to one person.
When not to use AI
Following the D.World Curriculum Bible, and the risks above, do not use AI (or use it only with strict conditions) when:
- it would create a privacy or security risk you cannot remove;
- the decision has a high impact on people (jobs, credit, health, legal matters), unless the use is permitted and the result is reviewed by qualified people. AI must never be the decision-maker;
- the task needs facts or system access the AI does not have, and you would be tempted to accept a guess;
- you cannot verify the output;
- it would hide misunderstanding or replace a skill you are expected to practise.
Trustworthy AI: the wider frame
NIST's AI Risk Management Framework (AI RMF 1.0) describes trustworthy AI systems as: - "valid and reliable"; - "safe"; - "secure and resilient"; - "accountable and transparent"; - "explainable and interpretable"; - "privacy-enhanced"; - "fair with harmful bias managed".
These organization-level ideas apply to your everyday habits. Verifying output supports valid and reliable. Protecting data supports privacy-enhanced. Keeping an AI-use note supports accountable and transparent.
5. Worked Example
Synthetic, fictional. A Cedar Lane team member drafts this prompt for a free public chatbot:
"Here is a complaint from our customer Maya Rahman (maya.rahman@example.com, order 2003, card ending 4242, lives at 14 Elm Road). She says her pen set arrived broken and she wants a refund. Write a reply and tell me if we must refund her."
Apply the checklist:
| Check | Finding |
|---|---|
| 1. Personal data | Yes: name, email, address, order number, partial card number |
| 2. Confidential | Customer records are confidential to the business |
| 3. Secrets | The partial card number is payment-related; remove it |
| 4. Approved tool | A free public chatbot is not approved for customer data in this scenario |
| 5. Necessary | No. The reply can be drafted without identifying details |
| 6. Permitted use | Doubtful without policy approval |
| 7. Headline test | Fails |
Safer version:
"Write a polite, short reply (under 120 words) to a customer whose pen set arrived broken. Apologise, explain that we will arrange a replacement or refund, and ask them to reply with a photo of the damage. Do not promise a specific timeframe."
And the decision? "Tell me if we must refund her" asks the AI to make a policy and legal judgment it cannot reliably make. That decision belongs to the business, following its refund policy and applicable consumer law.
6. Visual Explanation
BEFORE YOU PASTE AFTER YOU GET AN ANSWER
┌─────────────────────────────────┐ ┌──────────────────────────────────────┐
│ 1 Personal? 2 Confidential? │ │ Every claim: supported / calculation │
│ 3 Secrets? → NEVER │ │ / unsupported (L09) │
│ 4 Approved tool? 5 Necessary? │ │ Tone ≠ evidence; check sources exist │
│ 6 Permitted? 7 Headline test │ │ Causes = hypotheses until tested │
└───────────────┬─────────────────┘ └──────────────────┬───────────────────┘
▼ ▼
Uncertain? → don't paste; High-impact decision? → qualified
use synthetic / aggregated human review; AI is never the
decision-maker
Alt text: Two panels. The left panel, "Before you paste", lists the seven privacy checks: personal data, confidential information, secrets (marked never), approved tool, necessary, permitted use, and the headline test. Its arrow leads to: if uncertain, don't paste; use synthetic or aggregated data. The right panel, "After you get an answer", lists three checks: label every claim as supported, calculation or unsupported; tone is not evidence, so check that sources exist; causes are hypotheses until tested. Its arrow leads to: for high-impact decisions, qualified human review is required, and AI is never the decision-maker.
7. Guided Practice
Spot the hallucinations. Input given to an AI (synthetic, Cedar Lane): November 25,000 sessions, 750 orders, 18,000 USD revenue; December 22,000 sessions, 550 orders, 13,200 USD revenue.
Illustrative AI-style response (written by D.World):
"Revenue fell by 4,800 USD (about 27%). Conversion dropped from 3.0% to 2.5%. Average order value stayed at 24 USD. The drop was caused by a two-day website outage in mid-December. According to the 2025 Global E-commerce Benchmark Report, December dips of 25–30% are normal for stationery retailers. You should cut prices by 10% in January."
- Split the response into claims and label each (supported / calculation / unsupported).
- Recompute every calculation.
- For each unsupported claim, name its form from the Section 4 table.
- Which sentence is not a factual claim but a recommendation? Why should it not be accepted from this input alone?
8. Independent Practice
Fictional business: Pulse Studio, a fitness studio. A staff member wants to paste the following into a free public chatbot to "find members at risk of leaving":
A spreadsheet with members' full names, phone numbers, dates of birth, visit dates for the last 6 months, and notes on injuries mentioned to trainers.
- Apply all seven checklist questions.
- Identify which item is especially sensitive, and why.
- Propose a safer way to get some AI help with the task. (Hint: what could be done with synthetic data or aggregated counts, and who must approve real data use?)
- Name one part of this task where AI should not be the decision-maker.
No model answer is shown here.
9. Knowledge Check — Scenario Assessment
Part A — Choose the best answer.
A1. An AI answer cites "Smith & Lee (2023), Journal of Retail Analytics" for a claim. What should you do? - A) Accept it, because it has an author and a year. - B) Ask the AI if the source is real and accept its answer. - C) Try to find and open the source yourself; until you can, treat the claim as unsupported. - D) Copy the citation into your report with "(AI-provided)".
A2. Which item must never be pasted into any AI tool? - A) A database password - B) A synthetic practice table - C) The definition of "conversion rate" - D) Product descriptions already published on the public website
A3. An AI gives a fluent, confident answer with no caveats. What does the confidence tell you about correctness? - A) It shows the answer was checked. - B) Nothing on its own; the claims still need verification. - C) It shows the model used a reliable source. - D) It means the answer is probably wrong.
A4. Removing customers' names from a spreadsheet before pasting it into an unapproved AI tool… - A) always makes the data anonymous. - B) is unnecessary if the tool is popular. - C) is only needed for payment data. - D) may not be enough, because remaining details can still identify people.
Part B — For each scenario, choose: Use AI · Use AI with conditions (state them) · Do not use AI. Give a one-line reason.
| # | Scenario |
|---|---|
| 1 | Asking a public AI assistant to explain what "data minimisation" means |
| 2 | Pasting a CSV of customers' names, phone numbers and purchase histories into a free public chatbot to group them into segments |
| 3 | Summarising an internal sales report in the company-approved AI tool, with the report owner's permission, for an internal meeting |
| 4 | Asking AI to decide whether a loan applicant should be approved |
| 5 | Pasting the store's database password so AI can "fix the connection" |
| 6 | Asking AI to generate a synthetic practice table with the same columns as the order table |
| 7 | A learner asking AI to write the complete solution to a graded exercise designed to practise that skill |
10. AI in Practice
Part 1: a question with missing context. Ask an AI assistant (synthetic data only):
"A small online store had 25,000 sessions, 750 orders and 18,000 USD revenue in November, and 22,000 sessions, 550 orders and 13,200 USD revenue in December. Why did sales fall, and what should the owner do?"
The input contains no information about causes. Then: 1. List every claim in the response. 2. Mark each one: supported by the input, calculation to check or not supported by the input (invented or assumed). 3. Note whether the AI said that information was missing, or asked for it. That is good behaviour; mark it. 4. Rewrite the prompt so that the AI must separate facts from hypotheses and list the data needed to test each hypothesis. Run it again and compare.
Part 2: privacy checklist. Take the Section 5 unsafe prompt (it is synthetic) and, without running it, rewrite it so it passes all seven checks. Then run only the safe version.
11. AI Verification
- Input boundary: anything not in your input and not derivable from it is unsupported, however reasonable it sounds.
- Sources: open every source the AI names. If it does not exist or does not say what was claimed, record it as a hallucination.
- Numbers: recompute them (L09, L11).
- Causes and recommendations: treat causes as hypotheses and recommendations as suggestions until you have evidence. The owner decides, not the AI.
- Consistency: ask the same question again or rephrase it. If key details change, that is a warning sign.
- Privacy before, during and after: - run the checklist before pasting; - do not add real data in follow-up questions; - do not copy AI output containing personal data into shared documents without checking policy.
12. Business Lens
Decide which data can and cannot be shared with an AI tool, under stated rules.
Scenario rules (fictional Cedar Lane AI policy): - Tool A — Approved workspace: the company's paid AI workspace. Approved for internal business data (sales figures, internal reports). Not approved for customer personal data or payment data. - Tool B — Free public chatbot: approved only for public information or synthetic data. - Secrets (passwords, keys, verification codes, card numbers) may never be entered into any AI tool.
| # | Data item | Tool A? | Tool B? |
|---|---|---|---|
| A | Monthly revenue by product category (aggregated, internal) | ||
| B | Customer list with names, emails and addresses | ||
| C | API key for the online-store platform | ||
| D | Product descriptions already published on the website | ||
| E | A customer complaint email, after removing the name, email, order number and any other identifying detail, and checking that what remains cannot identify the person | ||
| F | A synthetic practice table created for training | ||
| G | Employee performance reviews |
Fill in Yes or No for each tool and give a reason. Where the rules do not clearly cover an item, write Ask first and say whom you would ask.
13. Workplace Task — AI-Use Decision Record
Fictional business: Cedar Lane (rules as in Section 12). The owner wants to use AI to help reply to 20 customer complaint emails each week.
Write a decision record (150–220 words) with these parts:
- Task: what the AI will and will not do. For example, will it draft replies? Will it decide refunds?
- Data: what may be shared, which tool, and how emails are prepared before use (what is removed).
- Human review: who checks each reply before sending, and what they check.
- Hallucination controls: for example, the AI must not promise timeframes or policies that are not in a provided policy text.
- When not to use AI: at least one type of complaint that must be handled without AI drafting, and why.
- AI-use note: how the team will record AI use.
14. Mini Challenge
Fictional business: Northgate Language School (adult learners). The school's rule says: "Only the school's approved AI tool may be used, and only for course materials and anonymised, aggregated statistics. Student records may not be entered into any AI tool."
A teacher wants to: 1. ask AI to draft a vocabulary quiz; 2. paste student names and test scores to get "personalised feedback"; 3. ask AI which students should repeat the level; 4. paste the average score per class to get ideas for revision topics.
For each, decide Allowed / Not allowed / Allowed with conditions under the rule. Explain your reason and, where something is not allowed, give a safer alternative.
Submit before feedback. No solution is provided here.
15. Resources
- Required (about 15 min): NIST, AI Risk Management Framework overview page. Read the summary, note that the framework is "intended for voluntary use", and note the page's statement that the AI RMF 1.0 is being revised. https://www.nist.gov/itl/ai-risk-management-framework (Opened and checked 12 Oct 2026.)
- Required (about 10 min): NIST AI 600-1, Generative AI Profile, Section 2. Read the short descriptions of Confabulation, Data Privacy and Human-AI Configuration. https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.600-1.pdf (Opened and checked 12 Oct 2026.)
- Deeper (optional): NIST AI 100-1, AI RMF 1.0 (January 2023), Section 3, on the characteristics of trustworthy AI. https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.100-1.pdf (Opened and checked 12 Oct 2026.)
- Your own context: if you study or work in an organization, find its AI-use or data policy and read the section on what may be entered into AI tools.
16. Person to Follow / Role Model
Community perspective (no named person). The D.World map lists the "NIST AI risk community", a community rather than an individual, so no person is named here.
Try this: read the NIST AI RMF page (Resources) and note: 1. one development or update listed there; 2. one trustworthy-AI characteristic from Section 4 that your own AI habits can support, and how.
17. Glossary
| Term | Meaning in this lesson |
|---|---|
| Hallucination / confabulation | Confidently stated but false or unsupported AI content |
| Overconfidence | Treating fluent, assured output as if it were verified |
| Automation bias / over-reliance | The human tendency to accept a system's output without enough checking |
| Personal data | Information that identifies a person directly or indirectly |
| Confidential data | Non-public information belonging to an organization |
| Secret | A password, key, code or card detail that grants access or payment |
| Anonymised data | Data altered so individuals can no longer be identified (harder than it looks) |
| Aggregated data | Totals or averages for groups rather than individual records |
| Synthetic data | Artificial data created for practice or testing, not about real people |
| Approved tool | An AI tool your organization has authorised for a stated type of data |
| AI-use note | A short record of what AI was used for, what was verified, and what remained human judgment |
18. Reflection
Think of a time you shared information online without thinking about where it would go. Which of the seven checklist questions would have made you pause? Which one will be hardest for you to remember under time pressure, and how will you remind yourself?
19. Next Step
U03 finishes with the U03 Exit Assessment. You will complete an AI-assisted data task and document every verification decision: what AI contributed, what you checked, what you corrected or rejected, your privacy judgment and what remains uncertain.
After that, U04 — Python Fundamentals begins. There you will write code yourself and use the generate → run → test → verify habit from L11.
20. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Scenario assessment, Part A (A1–A4) | Recognises hallucination signals, secrets, overconfidence and the limits of anonymisation | 3 or more of 4 correct |
| Scenario assessment, Part B (1–7) | Decides when not to use AI and what not to share | 6 or more of 7 with reasons; scenarios 2, 4 and 5 must be correct |
| AI in Practice (missing-context claims; privacy rewrite) | Identifies unsupported claims; produces a safe prompt | Rubric L12-AI |
| Guided and independent practice, workplace decision record, mini challenge | Applies the privacy checklist and AI-use rules | Rubrics L12-GP, L12-IP, L12-WT, L12-MC |
References
- NIST. Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile (NIST AI 600-1, 26 July 2024). https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.600-1.pdf (opened and checked 12 Oct 2026). Supports: definitions of Confabulation, Data Privacy and Human-AI Configuration (automation bias, over-reliance).
- NIST. AI Risk Management Framework (overview page). https://www.nist.gov/itl/ai-risk-management-framework (opened and checked 12 Oct 2026). Supports: release January 2023; voluntary use; the Generative AI Profile; statement that AI RMF 1.0 is being revised.
- NIST. Artificial Intelligence Risk Management Framework (AI RMF 1.0) (NIST AI 100-1, January 2023). https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.100-1.pdf (opened and checked 12 Oct 2026). Supports: the seven characteristics of trustworthy AI; core functions Govern, Map, Measure, Manage.
- D.World Curriculum Bible v1.0, "AI safety and professionalism" (never enter secrets; no sensitive data unless policy and tool permit; AI-use note; when not to use AI). Internal.
- The seven-question privacy checklist and the Cedar Lane AI policy are D.World teaching tools and a fictional scenario, not legal standards.
L12 — الهلوسة والخصوصية والاستخدام المسؤول للذكاء الاصطناعي
ملف المتعلّم. الإجابات والحلول النموذجية في ملف منفصل خاص بالمدرّس فقط. الإصدار: U03 v1.0 · تاريخ المحتوى: 12 أكتوبر 2026. تقديرات الوقت مبدئية إلى أن تُجرَّب مع المتعلّمين. هذا الدرس يشرح مبادئ عامة؛ وليس استشارة قانونية. قوانين الخصوصية وسياسات المؤسسات تختلف من بلد لآخر ومن جهة عمل لأخرى.
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | الهلوسة والخصوصية والاستخدام المسؤول للذكاء الاصطناعي |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U03 — الذكاء الاصطناعي في العمل مع البيانات |
| رقم الدرس | L12 |
| المهارات | الوعي بالمخاطر؛ التحقق |
| المستوى | مبتدئ |
| الوقت المتوقع | حوالي ساعة و45 دقيقة (مبدئي) |
| المتطلبات السابقة | L09–L11. وL08 في U02 (جدول نوفمبر/ديسمبر "المبيعات انخفضت"). |
تفصيل الوقت (مبدئي): المفهوم والمثال المحلول 30 دقيقة · التدريب الموجَّه 15 دقيقة · التدريب المستقل 10 دقائق · اختبار الفهم (تقييم مواقف) 15 دقيقة · الذكاء الاصطناعي في التطبيق والتحقق 15 دقيقة · مهمة العمل 15 دقيقة · التحدي القصير 5 دقائق.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تتعرّف على ثلاثة أشياء:
- الهلوسة (المحتوى المخترع أو غير المدعوم) في مخرجات الذكاء الاصطناعي؛
- المشاركة غير الآمنة للبيانات؛
- الثقة الزائدة، سواء في نبرة الذكاء الاصطناعي أو في اعتمادك الزائد عليه.
وستكون قادرًا أيضًا على أن تقرر، باستخدام قواعد واضحة، متى لا يجب استخدام الذكاء الاصطناعي، وما البيانات التي يجب ألا تُشارك.
هدف خريطة D.World (بنصه): Recognize hallucinations, unsafe data sharing, overconfidence, and when not to use AI.
3. لماذا يهمّك هذا؟
نوعان من الأخطاء يسببان أغلب مشكلات الذكاء الاصطناعي الحقيقية في العمل مع البيانات:
- الثقة فيما يخرج: قبول سبب أو رقم أو مصدر مخترع لأنه يبدو مؤكدًا.
- مشاركة ما لا يجب أن يدخل: لصق بيانات العملاء، أو أرقام سرية، أو كلمات مرور في أداة غير معتمدة لها.
الخطآن سهل الوقوع فيهما عندما تكون مشغولًا. وكلاهما قد يضر العملاء والزملاء والعمل، ولا يمكن دائمًا التراجع عن أي منهما. المبدأ الأساسي: لا تعامل الثقة أبدًا على أنها دليل.
4. المفهوم
الهلوسة (الاختلاق)
يسمي NIST Generative AI Profile هذا الخطر الاختلاق (confabulation): "the production of confidently stated but erroneous or false content" (إنتاج محتوى خاطئ أو زائف يُقال بثقة)، ويُعرف بالعامية باسم "hallucinations" (L09). وأشكاله الشائعة في العمل مع البيانات:
| الشكل | مثال |
|---|---|
| حقيقة أو رقم مخترع | "متوسط التحويل في القطاع 2.5%" (بلا مصدر) |
| مصدر مخترع | عنوان تقرير أو رابط غير موجود |
| سبب مخترع | "انخفضت المبيعات بسبب خصم أحد المنافسين" (دون أي بيانات عن المنافسين) |
| ملء سياق ناقص | افتراض معنى عمود، أو صيغة تاريخ، أو فترة زمنية |
| حساب خاطئ يُقال بثقة | رقم مرتب فيه خطأ في المعادلة (L11) |
علامات التحذير:
- أرقام أو اقتباسات دقيقة بلا مصدر؛
- مصادر لا تستطيع العثور عليها؛
- أسباب لا تُظهرها البيانات؛
- إجابة عن سؤال لم يكن في المدخلات ما يكفي للإجابة عنه؛
- تفاصيل تتغير عندما تسأل مرة أخرى.
الثقة الزائدة: وجهان
- نبرة الذكاء الاصطناعي: المخرجات عادةً سلسة وواثقة سواء كانت صحيحة أم خاطئة. النبرة ليست دليلًا.
- ثقة الإنسان: تذكر NIST خطر Human-AI Configuration (العلاقة بين الإنسان والذكاء الاصطناعي) ضمن مخاطر الذكاء الاصطناعي التوليدي. ويشمل "automation bias" (تحيّز الأتمتة) و"over-reliance" (الاعتماد الزائد). وهو ميل الإنسان إلى قبول مخرجات النظام دون فحص كافٍ. وعادتك في التحقق هي أداة الضبط.
الخصوصية والمشاركة غير الآمنة للبيانات
ما تكتبه في أداة ذكاء اصطناعي قد يُخزَّن، أو يُراجَع، أو يُعالَج خارج سيطرتك. وما يحدث فعلًا يعتمد على الأداة، وإعداداتها، واتفاق مؤسستك مع مقدّم الخدمة. وتصف NIST خطر Data Privacy (خصوصية البيانات) بأنه الآثار الناتجة عن "leakage and unauthorized use, disclosure, or de-anonymization of" (تسريب أو استخدام أو إفصاح غير مصرّح به، أو إلغاء إخفاء هوية) المعلومات الشخصية أو الحساسة.
قائمة D.World للخصوصية. أجب عنها قبل لصق أي شيء في أداة ذكاء اصطناعي:
- بيانات شخصية؟ هل يحدد النص شخصًا بشكل مباشر (الاسم، البريد الإلكتروني، الهاتف، العنوان، رقم الحساب) أو غير مباشر (مجموعة من التفاصيل)؟
- سرية؟ هل هي معلومات غير معلنة للشركة (أرقام لم تُنشر، عقود، خطط)؟
- أسرار؟ هل تحتوي على كلمات مرور، أو مفاتيح API، أو سلاسل اتصال بقواعد البيانات، أو رموز تحقق، أو بيانات بطاقات دفع؟ هذه لا تُشارك أبدًا مع أي أداة ذكاء اصطناعي.
- أداة معتمدة؟ هل هذه الأداة معتمدة من مؤسستك لهذا النوع من البيانات؟ وهل تعرف إعدادات البيانات فيها؟
- ضرورية؟ هل يمكنك استخدام بيانات مصطنعة، أو مجمّعة، أو مجهّلة بشكل سليم بدلًا منها؟
- استخدام مسموح؟ هل لديك الحق في استخدام هذه البيانات لهذا الغرض وفق السياسة والقانون المعمول به؟
- اختبار العنوان الصحفي: هل ستكون مرتاحًا لو أصبح هذا النص بعينه مرئيًا خارج فريقك؟
إذا كانت أي إجابة غير مؤكدة، فلا تلصق البيانات. اسأل، أو استخدم بيانات مصطنعة.
ملاحظة: حذف الأسماء لا يجعل البيانات مجهّلة دائمًا. فمجموعة من التفاصيل، مثل الرمز البريدي، وتاريخ الميلاد، وعملية شراء نادرة، قد تشير مع ذلك إلى شخص واحد.
متى لا تستخدم الذكاء الاصطناعي
وفقًا لـ D.World Curriculum Bible والمخاطر السابقة، لا تستخدم الذكاء الاصطناعي (أو استخدمه فقط بشروط صارمة) عندما:
- يخلق خطرًا على الخصوصية أو الأمان لا تستطيع إزالته؛
- يكون للقرار أثر كبير على الناس (الوظائف، الائتمان، الصحة، المسائل القانونية)، إلا إذا كان الاستخدام مسموحًا وراجع النتيجةَ أشخاصٌ مؤهلون. ولا يجوز أبدًا أن يكون الذكاء الاصطناعي هو صاحب القرار؛
- تحتاج المهمة إلى حقائق أو صلاحية وصول إلى أنظمة ليست لدى الذكاء الاصطناعي، وستكون معرّضًا لقبول تخمين؛
- لا تستطيع التحقق من المخرجات؛
- كان سيُخفي سوء فهم لديك، أو يحل محل مهارة يُتوقع منك أن تتدرّب عليها.
الذكاء الاصطناعي الجدير بالثقة: الإطار الأوسع
يصف إطار NIST لإدارة مخاطر الذكاء الاصطناعي (AI RMF 1.0) أنظمة الذكاء الاصطناعي الجديرة بالثقة بأنها:
- "valid and reliable" (صالحة وموثوقة)؛
- "safe" (آمنة)؛
- "secure and resilient" (محمية ومرنة)؛
- "accountable and transparent" (خاضعة للمساءلة وشفافة)؛
- "explainable and interpretable" (قابلة للشرح والتفسير)؛
- "privacy-enhanced" (معززة للخصوصية)؛
- "fair with harmful bias managed" (عادلة مع ضبط التحيّز الضار).
هذه الأفكار على مستوى المؤسسة تنطبق على عاداتك اليومية. التحقق من المخرجات يدعم الصلاحية والموثوقية. وحماية البيانات تدعم تعزيز الخصوصية. والاحتفاظ بملاحظة استخدام الذكاء الاصطناعي يدعم المساءلة والشفافية.
5. مثال محلول
مصطنع وخيالي. عضو في فريق Cedar Lane يكتب مسودة هذا الطلب لروبوت محادثة عام ومجاني:
"Here is a complaint from our customer Maya Rahman (maya.rahman@example.com, order 2003, card ending 4242, lives at 14 Elm Road). She says her pen set arrived broken and she wants a refund. Write a reply and tell me if we must refund her."
(المعنى: "هذه شكوى من عميلتنا Maya Rahman (البريد، ورقم الطلب 2003، وبطاقة تنتهي بـ 4242، وتسكن في 14 Elm Road). تقول إن طقم الأقلام وصلها مكسورًا وتريد استرداد المبلغ. اكتب ردًا وقل لي هل يجب أن نرد لها المبلغ.")
طبّق قائمة الفحص:
| الفحص | النتيجة |
|---|---|
| 1. بيانات شخصية | نعم: الاسم، والبريد الإلكتروني، والعنوان، ورقم الطلب، وجزء من رقم البطاقة |
| 2. سرية | سجلات العملاء سرية بالنسبة للنشاط |
| 3. أسرار | الجزء من رقم البطاقة مرتبط بالدفع؛ احذفه |
| 4. أداة معتمدة | روبوت المحادثة العام المجاني غير معتمد لبيانات العملاء في هذا السيناريو |
| 5. ضرورية | لا. يمكن كتابة مسودة الرد دون تفاصيل تحدد الهوية |
| 6. استخدام مسموح | مشكوك فيه دون موافقة وفق السياسة |
| 7. اختبار العنوان الصحفي | يفشل |
نسخة أكثر أمانًا:
"Write a polite, short reply (under 120 words) to a customer whose pen set arrived broken. Apologise, explain that we will arrange a replacement or refund, and ask them to reply with a photo of the damage. Do not promise a specific timeframe."
وبالعربية: "اكتب ردًا مهذبًا وقصيرًا (أقل من 120 كلمة) لعميل وصله طقم الأقلام مكسورًا. اعتذر، واشرح أننا سنرتب استبدالًا أو استردادًا للمبلغ، واطلب منه الرد بصورة للتلف. لا تَعِد بمدة زمنية محددة."
وماذا عن القرار؟ عبارة "قل لي هل يجب أن نرد لها المبلغ" تطلب من الذكاء الاصطناعي أن يصدر حكمًا في السياسة والقانون لا يستطيع إصداره بشكل موثوق. هذا القرار يخص النشاط التجاري، وفق سياسة الاسترداد لديه وقانون حماية المستهلك المعمول به.
6. شرح بصري
BEFORE YOU PASTE AFTER YOU GET AN ANSWER
┌─────────────────────────────────┐ ┌──────────────────────────────────────┐
│ 1 Personal? 2 Confidential? │ │ Every claim: supported / calculation │
│ 3 Secrets? → NEVER │ │ / unsupported (L09) │
│ 4 Approved tool? 5 Necessary? │ │ Tone ≠ evidence; check sources exist │
│ 6 Permitted? 7 Headline test │ │ Causes = hypotheses until tested │
└───────────────┬─────────────────┘ └──────────────────┬───────────────────┘
▼ ▼
Uncertain? → don't paste; High-impact decision? → qualified
use synthetic / aggregated human review; AI is never the
decision-maker
وصف الرسم: لوحتان. اللوحة اليسرى، "قبل أن تلصق" (Before you paste)، تعرض فحوصات الخصوصية السبعة: البيانات الشخصية، والمعلومات السرية، والأسرار (مكتوب بجانبها: أبدًا)، والأداة المعتمدة، والضرورة، والاستخدام المسموح، واختبار العنوان الصحفي. ويقود سهمها إلى: إذا لم تكن متأكدًا فلا تلصق؛ واستخدم بيانات مصطنعة أو مجمّعة. واللوحة اليمنى، "بعد أن تحصل على إجابة" (After you get an answer)، تعرض ثلاثة فحوصات: صنّف كل ادعاء إلى مدعوم أو حساب أو غير مدعوم؛ والنبرة ليست دليلًا، فتأكد من وجود المصادر؛ والأسباب فرضيات حتى تُختبر. ويقود سهمها إلى: القرارات عالية الأثر تتطلب مراجعة بشرية مؤهلة، والذكاء الاصطناعي ليس صاحب القرار أبدًا.
7. تدريب موجَّه
اكتشف الهلوسات. المدخلات المعطاة لذكاء اصطناعي (مصطنعة، Cedar Lane): نوفمبر 25,000 جلسة، و750 طلبًا، وإيرادات 18,000 دولار؛ ديسمبر 22,000 جلسة، و550 طلبًا، وإيرادات 13,200 دولار.
رد توضيحي بأسلوب الذكاء الاصطناعي (كتبته D.World):
"انخفضت الإيرادات بمقدار 4,800 دولار (حوالي 27%). وانخفض التحويل من 3.0% إلى 2.5%. وبقي متوسط قيمة الطلب 24 دولارًا. وسبب الانخفاض توقف الموقع يومين في منتصف ديسمبر. ووفقًا لتقرير 2025 Global E-commerce Benchmark Report، فإن انخفاضات ديسمبر بنسبة 25–30% طبيعية لمتاجر الأدوات المكتبية. يجب أن تخفض الأسعار 10% في يناير."
- قسّم الرد إلى ادعاءات وصنّف كل منها (مدعوم / حساب / غير مدعوم).
- أعِد حساب كل عملية حسابية.
- لكل ادعاء غير مدعوم، سمِّ شكله من جدول القسم 4.
- أي جملة ليست ادعاءً عن حقيقة بل توصية؟ ولماذا لا يجب قبولها من هذه المدخلات وحدها؟
8. تدريب مستقل
نشاط خيالي: Pulse Studio، استوديو لياقة. يريد أحد الموظفين لصق ما يلي في روبوت محادثة عام ومجاني "لاكتشاف الأعضاء المعرّضين للمغادرة":
جدول بيانات بالأسماء الكاملة للأعضاء، وأرقام هواتفهم، وتواريخ ميلادهم، وتواريخ زياراتهم خلال آخر 6 أشهر، وملاحظات عن إصابات ذكروها للمدربين.
- طبّق أسئلة قائمة الفحص السبعة كلها.
- حدِّد أي بند حساس بشكل خاص، ولماذا.
- اقترح طريقة أكثر أمانًا للحصول على بعض المساعدة من الذكاء الاصطناعي في هذه المهمة. (تلميح: ما الذي يمكن فعله ببيانات مصطنعة أو أعداد مجمّعة، ومن يجب أن يوافق على استخدام البيانات الحقيقية؟)
- سمِّ جزءًا واحدًا من هذه المهمة يجب ألا يكون فيه الذكاء الاصطناعي صاحب القرار.
لا توجد إجابة نموذجية هنا.
9. اختبار الفهم — تقييم مواقف
الجزء A — اختر أفضل إجابة.
A1. إجابة من الذكاء الاصطناعي تستشهد بـ "Smith & Lee (2023), Journal of Retail Analytics" لدعم ادعاء. ماذا تفعل؟ - A) أقبلها، لأن لها مؤلفًا وسنة. - B) أسأل الذكاء الاصطناعي هل المصدر حقيقي وأقبل إجابته. - C) أحاول العثور على المصدر وفتحه بنفسي؛ وحتى أتمكن من ذلك، أعامل الادعاء على أنه غير مدعوم. - D) أنسخ الاستشهاد في تقريري وأكتب بجانبه "(من الذكاء الاصطناعي)".
A2. أي بند يجب ألا يُلصق أبدًا في أي أداة ذكاء اصطناعي؟ - A) كلمة مرور قاعدة بيانات - B) جدول تدريبي مصطنع - C) تعريف "معدل التحويل" - D) أوصاف المنتجات المنشورة بالفعل على الموقع العام
A3. أعطاك الذكاء الاصطناعي إجابة سلسة وواثقة بلا أي تحفظات. ماذا تخبرك هذه الثقة عن صحة الإجابة؟ - A) تُظهر أن الإجابة رُوجعت. - B) لا شيء بمفردها؛ والادعاءات ما زالت بحاجة إلى تحقق. - C) تُظهر أن النموذج استخدم مصدرًا موثوقًا. - D) تعني أن الإجابة خاطئة على الأرجح.
A4. حذف أسماء العملاء من جدول بيانات قبل لصقه في أداة ذكاء اصطناعي غير معتمدة… - A) يجعل البيانات مجهّلة دائمًا. - B) غير ضروري إذا كانت الأداة مشهورة. - C) مطلوب فقط لبيانات الدفع. - D) قد لا يكفي، لأن التفاصيل المتبقية قد تحدد هوية الأشخاص.
الجزء B — لكل موقف، اختر: استخدم الذكاء الاصطناعي · استخدمه بشروط (اذكرها) · لا تستخدمه. واذكر سببًا في سطر واحد.
| # | الموقف |
|---|---|
| 1 | سؤال مساعد ذكاء اصطناعي عام عن معنى "تقليل البيانات إلى الحد الأدنى" (data minimisation) |
| 2 | لصق ملف CSV فيه أسماء العملاء وأرقام هواتفهم وسجل مشترياتهم في روبوت محادثة عام ومجاني لتقسيمهم إلى شرائح |
| 3 | تلخيص تقرير مبيعات داخلي في أداة الذكاء الاصطناعي المعتمدة من الشركة، بإذن صاحب التقرير، لاجتماع داخلي |
| 4 | طلب أن يقرر الذكاء الاصطناعي هل يجب الموافقة على طالب قرض |
| 5 | لصق كلمة مرور قاعدة بيانات المتجر حتى "يصلح" الذكاء الاصطناعي الاتصال |
| 6 | طلب أن يولّد الذكاء الاصطناعي جدولًا تدريبيًا مصطنعًا بأعمدة جدول الطلبات نفسها |
| 7 | متعلّم يطلب من الذكاء الاصطناعي كتابة الحل الكامل لتمرين مقيَّم صُمّم للتدرّب على هذه المهارة |
10. الذكاء الاصطناعي في التطبيق
الجزء 1: سؤال بسياق ناقص. اسأل مساعد ذكاء اصطناعي (بيانات مصطنعة فقط):
"A small online store had 25,000 sessions, 750 orders and 18,000 USD revenue in November, and 22,000 sessions, 550 orders and 13,200 USD revenue in December. Why did sales fall, and what should the owner do?"
وبالعربية: "كان لدى متجر إلكتروني صغير 25,000 جلسة و750 طلبًا وإيرادات 18,000 دولار في نوفمبر، و22,000 جلسة و550 طلبًا وإيرادات 13,200 دولار في ديسمبر. لماذا انخفضت المبيعات، وماذا يجب أن يفعل صاحب المتجر؟"
المدخلات لا تحتوي على أي معلومات عن الأسباب. بعد ذلك:
- اكتب كل ادعاء في الرد.
- ضع على كل منها علامة: مدعوم بالمدخلات، أو حساب يجب التحقق منه، أو غير مدعوم بالمدخلات (مخترع أو مفترض).
- لاحظ هل قال الذكاء الاصطناعي إن هناك معلومات ناقصة، أو طلبها. هذا سلوك جيد؛ ضع عليه علامة.
- أعِد كتابة الطلب بحيث يُلزَم الذكاء الاصطناعي بالفصل بين الحقائق والفرضيات، وبذكر البيانات اللازمة لاختبار كل فرضية. شغّله مرة أخرى وقارن.
الجزء 2: قائمة فحص الخصوصية. خذ الطلب غير الآمن من القسم 5 (وهو مصطنع)، ودون أن تشغّله، أعِد كتابته بحيث يجتاز الفحوصات السبعة كلها. ثم شغّل النسخة الآمنة فقط.
11. التحقق من مخرجات الذكاء الاصطناعي
- حدود المدخلات: أي شيء ليس في مدخلاتك ولا يمكن اشتقاقه منها غير مدعوم، مهما بدا معقولًا.
- المصادر: افتح كل مصدر يذكره الذكاء الاصطناعي. إن لم يكن موجودًا أو لم يقل ما نُسب إليه، فسجّله على أنه هلوسة.
- الأرقام: أعِد حسابها (L09، L11).
- الأسباب والتوصيات: تعامل مع الأسباب على أنها فرضيات ومع التوصيات على أنها اقتراحات حتى يتوفر لديك دليل. صاحب المتجر هو من يقرر، لا الذكاء الاصطناعي.
- الاتساق: اسأل السؤال نفسه مرة أخرى أو أعِد صياغته. إذا تغيّرت التفاصيل الأساسية، فهذه علامة تحذير.
- الخصوصية قبل وأثناء وبعد:
- طبّق قائمة الفحص قبل اللصق؛
- لا تُضف بيانات حقيقية في أسئلة المتابعة؛
- لا تنسخ مخرجات الذكاء الاصطناعي التي تحتوي على بيانات شخصية إلى مستندات مشتركة دون مراجعة السياسة.
12. منظور الأعمال
قرّر ما البيانات التي يمكن مشاركتها مع أداة ذكاء اصطناعي وما لا يمكن، وفق قواعد محددة.
قواعد السيناريو (سياسة خيالية للذكاء الاصطناعي في Cedar Lane):
- الأداة A — مساحة عمل معتمدة: مساحة عمل الذكاء الاصطناعي المدفوعة الخاصة بالشركة. معتمدة لبيانات العمل الداخلية (أرقام المبيعات، والتقارير الداخلية). وغير معتمدة للبيانات الشخصية للعملاء أو بيانات الدفع.
- الأداة B — روبوت محادثة عام ومجاني: معتمد فقط للمعلومات العامة أو البيانات المصطنعة.
- الأسرار (كلمات المرور، والمفاتيح، ورموز التحقق، وأرقام البطاقات) لا يجوز أبدًا إدخالها في أي أداة ذكاء اصطناعي.
| # | البند | الأداة A؟ | الأداة B؟ |
|---|---|---|---|
| A | الإيرادات الشهرية حسب فئة المنتج (مجمّعة، داخلية) | ||
| B | قائمة العملاء بأسمائهم وبريدهم الإلكتروني وعناوينهم | ||
| C | مفتاح API لمنصة المتجر الإلكتروني | ||
| D | أوصاف المنتجات المنشورة بالفعل على الموقع | ||
| E | رسالة شكوى من عميل، بعد حذف الاسم والبريد الإلكتروني ورقم الطلب وأي تفصيل آخر يحدد الهوية، والتأكد من أن ما تبقى لا يمكن أن يحدد الشخص | ||
| F | جدول تدريبي مصطنع أُنشئ للتدريب | ||
| G | تقييمات أداء الموظفين |
اكتب نعم أو لا لكل أداة واذكر السبب. وحيث لا تغطي القواعد بندًا بوضوح، اكتب اسأل أولًا وقل من ستسأل.
13. مهمة عمل — سجل قرار استخدام الذكاء الاصطناعي
نشاط خيالي: Cedar Lane (القواعد كما في القسم 12). يريد صاحب المتجر استخدام الذكاء الاصطناعي للمساعدة في الرد على 20 رسالة شكوى من العملاء كل أسبوع.
اكتب سجل قرار (150–220 كلمة) يتضمن هذه الأجزاء:
- المهمة: ما الذي سيفعله الذكاء الاصطناعي وما الذي لن يفعله. مثلًا، هل سيكتب مسودات الردود؟ هل سيقرر الاسترداد؟
- البيانات: ما الذي يجوز مشاركته، وبأي أداة، وكيف تُجهَّز الرسائل قبل الاستخدام (ما الذي يُحذف).
- المراجعة البشرية: من يراجع كل رد قبل إرساله، وماذا يراجع.
- ضوابط الهلوسة: مثلًا، يجب ألا يَعِد الذكاء الاصطناعي بمدد زمنية أو سياسات غير موجودة في نص سياسة مقدَّم له.
- متى لا نستخدم الذكاء الاصطناعي: نوع واحد على الأقل من الشكاوى يجب التعامل معه دون مسودة من الذكاء الاصطناعي، ولماذا.
- ملاحظة استخدام الذكاء الاصطناعي: كيف سيسجّل الفريق استخدامه للذكاء الاصطناعي.
14. تحدٍّ قصير
نشاط خيالي: Northgate Language School (مدرسة لغات للكبار). تقول قاعدة المدرسة: "لا يجوز استخدام إلا أداة الذكاء الاصطناعي المعتمدة من المدرسة، وفقط للمواد الدراسية والإحصاءات المجهّلة والمجمّعة. ولا يجوز إدخال سجلات الطلاب في أي أداة ذكاء اصطناعي."
يريد أحد المعلمين أن:
- يطلب من الذكاء الاصطناعي كتابة مسودة اختبار مفردات؛
- يلصق أسماء الطلاب ودرجاتهم في الاختبار للحصول على "ملاحظات شخصية"؛
- يسأل الذكاء الاصطناعي أي الطلاب يجب أن يعيدوا المستوى؛
- يلصق متوسط الدرجات لكل فصل للحصول على أفكار لموضوعات المراجعة.
لكل منها، قرّر مسموح / غير مسموح / مسموح بشروط وفق القاعدة. واشرح سببك، وحيث يكون الأمر غير مسموح، اقترح بديلًا أكثر أمانًا.
سلّم إجابتك قبل أي ملاحظات. لا يوجد حل هنا.
15. المصادر
- مطلوب (حوالي 15 دقيقة): NIST، صفحة التعريف بـ AI Risk Management Framework. اقرأ الملخص، ولاحظ أن الإطار "intended for voluntary use" (مخصص للاستخدام الاختياري)، ولاحظ ما تذكره الصفحة من أن AI RMF 1.0 قيد المراجعة. https://www.nist.gov/itl/ai-risk-management-framework (فُتحت وروجعت في 12 أكتوبر 2026.)
- مطلوب (حوالي 10 دقائق): NIST AI 600-1، Generative AI Profile، القسم 2. اقرأ الوصف القصير لـ Confabulation وData Privacy وHuman-AI Configuration. https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.600-1.pdf (فُتح وروجع في 12 أكتوبر 2026.)
- للتعمّق (اختياري): NIST AI 100-1، AI RMF 1.0 (يناير 2023)، القسم 3، عن خصائص الذكاء الاصطناعي الجدير بالثقة. https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.100-1.pdf (فُتح وروجع في 12 أكتوبر 2026.)
- سياقك أنت: إن كنت تدرس أو تعمل في مؤسسة، فابحث عن سياسة استخدام الذكاء الاصطناعي أو سياسة البيانات فيها، واقرأ الجزء الخاص بما يجوز إدخاله في أدوات الذكاء الاصطناعي.
16. شخصية تتابعها / قدوة
منظور المجتمع المهني (دون تسمية شخص). تذكر خريطة D.World عبارة "NIST AI risk community" (مجتمع مخاطر الذكاء الاصطناعي في NIST)، وهو مجتمع وليس فردًا، لذلك لا نسمّي هنا أي شخص.
جرّب هذا: اقرأ صفحة NIST AI RMF (المصادر) وسجّل:
- تطورًا أو تحديثًا واحدًا مذكورًا هناك؛
- خاصية واحدة من خصائص الذكاء الاصطناعي الجدير بالثقة في القسم 4 يمكن أن تدعمها عاداتك في استخدام الذكاء الاصطناعي، وكيف.
17. المصطلحات
| المصطلح | معناه في هذا الدرس |
|---|---|
| الهلوسة / الاختلاق (Hallucination / confabulation) | محتوى من الذكاء الاصطناعي خاطئ أو غير مدعوم يُقال بثقة |
| الثقة الزائدة (Overconfidence) | التعامل مع المخرجات السلسة الواثقة كأنها متحقَّق منها |
| تحيّز الأتمتة / الاعتماد الزائد (Automation bias / over-reliance) | ميل الإنسان إلى قبول مخرجات النظام دون فحص كافٍ |
| البيانات الشخصية (Personal data) | معلومات تحدد هوية شخص بشكل مباشر أو غير مباشر |
| البيانات السرية (Confidential data) | معلومات غير معلنة تخص مؤسسة |
| السر (Secret) | كلمة مرور أو مفتاح أو رمز أو بيانات بطاقة تمنح وصولًا أو قدرة على الدفع |
| البيانات المجهّلة (Anonymised data) | بيانات عُدّلت بحيث لا يمكن تحديد هوية الأفراد بعد ذلك (وهذا أصعب مما يبدو) |
| البيانات المجمّعة (Aggregated data) | إجماليات أو متوسطات لمجموعات بدلًا من سجلات أفراد |
| البيانات المصطنعة (Synthetic data) | بيانات اصطناعية أُنشئت للتدريب أو الاختبار، وليست عن أشخاص حقيقيين |
| الأداة المعتمدة (Approved tool) | أداة ذكاء اصطناعي أذنت بها مؤسستك لنوع محدد من البيانات |
| ملاحظة استخدام الذكاء الاصطناعي (AI-use note) | سجل قصير لما استُخدم فيه الذكاء الاصطناعي، وما تم التحقق منه، وما بقي حكمًا بشريًا |
18. تأمّل
فكّر في مرة شاركت فيها معلومات على الإنترنت دون أن تفكر إلى أين ستذهب. أي سؤال من أسئلة قائمة الفحص السبعة كان سيجعلك تتوقف؟ وأيها سيكون الأصعب عليك تذكّره تحت ضغط الوقت، وكيف ستذكّر نفسك به؟
19. الخطوة التالية
تنتهي U03 بـ تقييم نهاية الوحدة U03. ستنجز مهمة بيانات بمساعدة الذكاء الاصطناعي وتوثّق كل قرار تحقق: ما الذي أضافه الذكاء الاصطناعي، وما الذي راجعته، وما الذي صحّحته أو رفضته، وحكمك في الخصوصية، وما الذي ما زال غير مؤكد.
بعد ذلك تبدأ U04 — أساسيات Python. وهناك ستكتب الكود بنفسك وتستخدم عادة "ولِّد ← شغّل ← اختبر ← تحقّق" من L11.
20. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| تقييم المواقف، الجزء A (A1–A4) | التعرّف على علامات الهلوسة، والأسرار، والثقة الزائدة، وحدود التجهيل | 3 إجابات صحيحة أو أكثر من 4 |
| تقييم المواقف، الجزء B (1–7) | تقرير متى لا يُستخدم الذكاء الاصطناعي وما الذي لا يُشارك | 6 أو أكثر من 7 مع الأسباب؛ ويجب أن تكون المواقف 2 و4 و5 صحيحة |
| الذكاء الاصطناعي في التطبيق (ادعاءات السياق الناقص؛ إعادة الكتابة الآمنة) | التعرّف على الادعاءات غير المدعومة؛ وكتابة طلب آمن | معايير L12-AI |
| التدريب الموجَّه والمستقل، وسجل قرار العمل، والتحدي القصير | تطبيق قائمة فحص الخصوصية وقواعد استخدام الذكاء الاصطناعي | معايير L12-GP وL12-IP وL12-WT وL12-MC |
المراجع
- NIST. Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile (NIST AI 600-1، 26 يوليو 2024). https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.600-1.pdf (فُتح وروجع في 12 أكتوبر 2026). يدعم: تعريفات Confabulation وData Privacy وHuman-AI Configuration (تحيّز الأتمتة، والاعتماد الزائد).
- NIST. AI Risk Management Framework (صفحة التعريف). https://www.nist.gov/itl/ai-risk-management-framework (فُتحت وروجعت في 12 أكتوبر 2026). يدعم: الإصدار في يناير 2023؛ والاستخدام الاختياري؛ وGenerative AI Profile؛ وما تذكره من أن AI RMF 1.0 قيد المراجعة.
- NIST. Artificial Intelligence Risk Management Framework (AI RMF 1.0) (NIST AI 100-1، يناير 2023). https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.100-1.pdf (فُتح وروجع في 12 أكتوبر 2026). يدعم: الخصائص السبع للذكاء الاصطناعي الجدير بالثقة؛ والوظائف الأساسية Govern وMap وMeasure وManage.
- D.World Curriculum Bible v1.0، قسم "AI safety and professionalism" (لا تُدخل الأسرار أبدًا؛ لا بيانات حساسة إلا إذا سمحت السياسة والأداة؛ ملاحظة استخدام الذكاء الاصطناعي؛ متى لا تستخدم الذكاء الاصطناعي). وثيقة داخلية.
- قائمة فحص الخصوصية ذات الأسئلة السبعة وسياسة الذكاء الاصطناعي في Cedar Lane أدوات تعليمية وسيناريو خيالي من D.World، وليست معايير قانونية.
U03 Exit Assessment — AI for Data Workتقييم نهاية الوحدة U03 — الذكاء الاصطناعي في العمل مع البيانات Freeمجاني
U03 Exit Assessment — AI for Data Work
Learner-facing instructions and rubric. Model answers and marking notes are in the instructor-only file (05). Version: U03 v1.0 · 12 October 2026.
Unit exit criterion (D.World map): Complete an AI-assisted task and document verification decisions.
Estimated time: 75 minutes (provisional) · Format: a written verification report, 500–800 words. Tables are allowed, and copied AI output does not count toward the word limit. · Allowed: your U03 notes, a calculator, and an AI assistant (Option A) or the provided AI-style response (Option B). No coding is required. You may trace queries by hand.
The case (fictional business, synthetic data)
Harbor Tea Co. is a fictional online tea shop. The owner asks:
"For November, which product category brought in the most paid revenue, and what was our average order value? I need both numbers for a stock decision on Monday."
November order lines (synthetic). Each row is one line of an order; an order can have several lines.
| line | order_id | category | qty | unit_price (USD) | status |
|---|---|---|---|---|---|
| 1 | 3001 | Green tea | 2 | 9 | paid |
| 2 | 3001 | Teaware | 1 | 25 | paid |
| 3 | 3002 | Black tea | 3 | 7 | paid |
| 4 | 3003 | Green tea | 1 | 9 | refunded |
| 5 | 3004 | Herbal | 4 | 6 | paid |
| 6 | 3005 | Teaware | 1 | 25 | paid |
| 7 | 3005 | Green tea | 2 | 9 | paid |
| 8 | 3006 | Black tea | 2 | 7 | paid |
| 9 | 3006 | Black tea | 2 | 7 | paid |
| 10 | 3007 | Herbal | -1 | 6 | paid |
Definitions (from U02): - Paid revenue = qty × unit_price, summed over paid lines. - AOV = paid revenue ÷ number of distinct paid orders.
Owner's note: the export sometimes duplicates lines, and returns are sometimes recorded as negative quantities. There is no further information about lines 9 and 10.
Choose your option
- Option A: use an AI assistant. Use any AI tool you are permitted to use. Enter only the synthetic table above. Write your own prompt(s).
- Option B: no AI access, or you prefer not to use AI. Verify this illustrative AI-style response, written by D.World, as if an assistant had produced it:
"November paid revenue by category: Teaware 50 USD, Black tea 49 USD, Green tea 45 USD, Herbal 18 USD. Teaware was the top category. Total revenue was 162 USD across 10 orders, so the average order value was 16.20 USD. The data looks clean, with no quality issues. Teaware sales grew 30% compared with October, so the owner should double the Teaware stock order."
Both options are marked with the same rubric.
What to submit
Part 1: Task and input. State the business question, the definitions you used, and the data you used.
Part 2: Privacy judgment. Apply the L12 checklist to the data you entered (or would enter) into an AI tool. State what you would not have entered if this were real company data, and why.
Part 3: AI contribution. - Option A: include your first prompt, at least one revised prompt and the reason for the revision, plus a short summary of the AI's output. Paste key parts. - Option B: list the response's claims, one per line.
Part 4: Verification checks. Document at least two independent checks. Examples: - a hand calculation; - tracing a query on the table; - checking each claim against the input (supported / calculation / unsupported); - a test case with a known answer; - checking a data-quality issue.
For each check, state what you checked, how, and the result.
Part 5: Corrections and rejections. List every AI claim or output you corrected or rejected, with the reason. If you found nothing to correct, explain what you checked that makes you confident.
Part 6: Final answer (your own). Give the top category and the AOV. State how you treated lines 4, 9 and 10, and why.
Part 7: Uncertainty and AI-use note. - Uncertainty: say what remains uncertain, and how it could change the answer or the stock decision. - AI-use note: 2–3 lines on what AI was used for, what you verified, and what remained your judgment. For Option B, write what the provided response was used for.
Rubric (each criterion 0–2)
| # | Criterion | 2 — Meets | 1 — Partly | 0 — Not yet |
|---|---|---|---|---|
| C1 | Task, input and privacy (Parts 1–2) | Question and definitions stated; checklist applied with a specific judgment about what must not be shared if real | Task stated, but privacy judgment generic or incomplete | No privacy judgment, or real/personal data entered |
| C2 | AI contribution documented (Part 3) | Option A: prompts shown with a reasoned revision. Option B: claims fully listed | Prompts or claims partly shown; revision without reason | AI contribution not described |
| C3 | Verification checks (Part 4) | At least two independent, specific checks with method and result | One check, or checks vague ("I checked it") | No real check |
| C4 | Corrections and rejections (Part 5) | All material AI errors found (or a justified "none found"), each with a reason; unsupported claims rejected | Some errors found; reasons thin | Errors accepted; unsupported claims repeated as fact |
| C5 | Final answer and data quality (Part 6) | Correct top category and AOV for the stated treatment; lines 4, 9 and 10 handled explicitly and justified | Minor error, or a data issue handled but not justified | Wrong answer from an unverified AI figure, or data issues ignored |
| C6 | Uncertainty and AI-use note (Part 7) | Specific uncertainty linked to the decision; complete AI-use note | Uncertainty generic, or note incomplete | Missing |
Gate conditions (all must be met to pass)
- G1: No personal, confidential or secret data was entered into an AI tool. Only the synthetic table was used.
- G2: At least two independent verification checks are documented with results.
- G3: The final AOV is your verified figure and is consistent with the treatment you state. No unsupported AI claim (e.g., a growth figure or a cause) appears in your final answer as fact.
Result
- PASS: a total of 9 or more out of 12, no criterion scored 0, and all gates met.
- REVISE: anything else. Feedback names the criteria to improve; one resubmission is allowed.
Why this threshold? It requires solid overall performance (75%) while allowing small weaknesses. The gates protect what this unit is about: safe data use, real verification, and owning the final answer. The threshold is a design judgment, not statistically validated, and should be reviewed after learner pilot data.
This assessment checks understanding of U03 concepts. It is not a certification and makes no claim about job readiness.
تقييم نهاية الوحدة U03 — الذكاء الاصطناعي في العمل مع البيانات
تعليمات ومعايير تقييم موجّهة للمتعلّم. الإجابات النموذجية وملاحظات التصحيح موجودة في ملف المدرّس فقط (05). الإصدار: U03 v1.0 · 12 أكتوبر 2026.
معيار إنهاء الوحدة (خريطة D.World): أنجز مهمة بمساعدة الذكاء الاصطناعي ووثّق قرارات التحقق.
الوقت المتوقع: 75 دقيقة (مبدئي) · الشكل: تقرير تحقق مكتوب من 500 إلى 800 كلمة. يُسمح بالجداول، ومخرجات الذكاء الاصطناعي المنسوخة لا تُحسب ضمن عدد الكلمات. · المسموح: ملاحظاتك من U03، وآلة حاسبة، ومساعد ذكاء اصطناعي (الخيار A) أو الرد المعطى بأسلوب الذكاء الاصطناعي (الخيار B). لا تحتاج إلى البرمجة. ويمكنك تتبع الاستعلامات يدويًا.
الحالة (نشاط خيالي، بيانات مصطنعة)
Harbor Tea Co. متجر شاي خيالي على الإنترنت. يسأل صاحب المتجر:
"في نوفمبر، أي فئة منتجات جلبت أكبر إيرادات مدفوعة، وكم كان متوسط قيمة الطلب؟ أحتاج الرقمين لقرار المخزون يوم الإثنين."
بنود طلبات نوفمبر (مصطنعة). كل صف هو بند واحد في طلب؛ والطلب الواحد قد يضم عدة بنود.
| line | order_id | category | qty | unit_price (USD) | status |
|---|---|---|---|---|---|
| 1 | 3001 | Green tea | 2 | 9 | paid |
| 2 | 3001 | Teaware | 1 | 25 | paid |
| 3 | 3002 | Black tea | 3 | 7 | paid |
| 4 | 3003 | Green tea | 1 | 9 | refunded |
| 5 | 3004 | Herbal | 4 | 6 | paid |
| 6 | 3005 | Teaware | 1 | 25 | paid |
| 7 | 3005 | Green tea | 2 | 9 | paid |
| 8 | 3006 | Black tea | 2 | 7 | paid |
| 9 | 3006 | Black tea | 2 | 7 | paid |
| 10 | 3007 | Herbal | -1 | 6 | paid |
التعريفات (من U02):
- الإيرادات المدفوعة = qty × unit_price، مجموعة على البنود المدفوعة (paid).
- AOV = الإيرادات المدفوعة ÷ عدد الطلبات المدفوعة المختلفة.
ملاحظة صاحب المتجر: ملف التصدير يكرر البنود أحيانًا، والمرتجعات تُسجَّل أحيانًا بكميات سالبة. ولا توجد معلومات إضافية عن البندين 9 و10.
اختر الخيار المناسب لك
- الخيار A: استخدم مساعد ذكاء اصطناعي. استخدم أي أداة ذكاء اصطناعي مسموح لك باستخدامها. وأدخل فقط الجدول المصطنع السابق. واكتب طلباتك بنفسك.
- الخيار B: لا يتوفر لك وصول إلى الذكاء الاصطناعي، أو تفضّل عدم استخدامه. تحقّق من هذا الرد التوضيحي بأسلوب الذكاء الاصطناعي، الذي كتبته D.World، كأن مساعدًا هو من أنتجه:
"الإيرادات المدفوعة في نوفمبر حسب الفئة: Teaware بقيمة 50 دولارًا، وBlack tea بقيمة 49 دولارًا، وGreen tea بقيمة 45 دولارًا، وHerbal بقيمة 18 دولارًا. وكانت Teaware هي الفئة الأولى. وبلغ إجمالي الإيرادات 162 دولارًا على 10 طلبات، فيكون متوسط قيمة الطلب 16.20 دولار. والبيانات تبدو نظيفة، بلا مشكلات في الجودة. وزادت مبيعات Teaware بنسبة 30% مقارنةً بأكتوبر، لذلك يجب أن يضاعف صاحب المتجر طلبية مخزون Teaware."
الخياران يُقيَّمان بالمعايير نفسها.
ما الذي تسلّمه
الجزء 1: المهمة والمدخلات. اذكر سؤال العمل، والتعريفات التي استخدمتها، والبيانات التي استخدمتها.
الجزء 2: حكمك في الخصوصية. طبّق قائمة الفحص من L12 على البيانات التي أدخلتها (أو كنت ستدخلها) في أداة ذكاء اصطناعي. واذكر ما الذي لم تكن لتدخله لو كانت هذه بيانات حقيقية لشركة، ولماذا.
الجزء 3: ما أضافه الذكاء الاصطناعي.
- الخيار A: أرفق طلبك الأول، وطلبًا معدّلًا واحدًا على الأقل مع سبب التعديل، إضافة إلى ملخص قصير لمخرجات الذكاء الاصطناعي. والصق الأجزاء الأساسية.
- الخيار B: اكتب ادعاءات الرد، كل ادعاء في سطر.
الجزء 4: فحوصات التحقق. وثّق فحصين مستقلين على الأقل. أمثلة:
- حساب يدوي؛
- تتبع استعلام على الجدول؛
- مراجعة كل ادعاء مقارنةً بالمدخلات (مدعوم / حساب / غير مدعوم)؛
- حالة اختبار بإجابة معروفة؛
- فحص مشكلة في جودة البيانات.
لكل فحص، اذكر ما الذي فحصته، وكيف، والنتيجة.
الجزء 5: التصحيحات والرفض. اذكر كل ادعاء أو مخرج من الذكاء الاصطناعي صحّحته أو رفضته، مع السبب. وإن لم تجد شيئًا يحتاج إلى تصحيح، فاشرح ما الذي فحصته وجعلك واثقًا.
الجزء 6: الإجابة النهائية (إجابتك أنت). اذكر الفئة الأولى وAOV. واذكر كيف تعاملت مع البنود 4 و9 و10، ولماذا.
الجزء 7: عدم التأكد وملاحظة استخدام الذكاء الاصطناعي.
- عدم التأكد: قل ما الذي ما زال غير مؤكد، وكيف قد يغيّر الإجابة أو قرار المخزون.
- ملاحظة استخدام الذكاء الاصطناعي: سطران أو ثلاثة عن الغرض من استخدامه، وما الذي تحققت منه، وما الذي بقي حكمك أنت. وفي الخيار B، اكتب فيمَ استخدمت الرد المعطى.
معايير التقييم (كل معيار من 0 إلى 2)
| # | المعيار | 2 — يحقق المطلوب | 1 — يحققه جزئيًا | 0 — لم يحققه بعد |
|---|---|---|---|---|
| C1 | المهمة والمدخلات والخصوصية (الجزءان 1–2) | السؤال والتعريفات مذكورة؛ وقائمة الفحص مطبّقة مع حكم محدد عما يجب ألا يُشارك لو كانت البيانات حقيقية | المهمة مذكورة، لكن حكم الخصوصية عام أو ناقص | لا يوجد حكم في الخصوصية، أو أُدخلت بيانات حقيقية أو شخصية |
| C2 | توثيق ما أضافه الذكاء الاصطناعي (الجزء 3) | الخيار A: الطلبات معروضة مع تعديل مبرَّر. الخيار B: الادعاءات مذكورة بالكامل | الطلبات أو الادعاءات معروضة جزئيًا؛ أو تعديل بلا سبب | لم يُوصف ما أضافه الذكاء الاصطناعي |
| C3 | فحوصات التحقق (الجزء 4) | فحصان مستقلان ومحددان على الأقل، مع الطريقة والنتيجة | فحص واحد، أو فحوصات غامضة ("راجعته") | لا يوجد فحص حقيقي |
| C4 | التصحيحات والرفض (الجزء 5) | اكتُشفت كل أخطاء الذكاء الاصطناعي المهمة (أو "لم أجد شيئًا" مع تبرير)، لكل منها سبب؛ ورُفضت الادعاءات غير المدعومة | اكتُشف بعض الأخطاء؛ والأسباب ضعيفة | قُبلت الأخطاء؛ وكُررت الادعاءات غير المدعومة على أنها حقائق |
| C5 | الإجابة النهائية وجودة البيانات (الجزء 6) | الفئة الأولى وAOV صحيحان وفق طريقة المعالجة المذكورة؛ والبنود 4 و9 و10 عولجت بشكل صريح ومبرَّر | خطأ بسيط، أو عولجت مشكلة في البيانات دون تبرير | إجابة خاطئة مأخوذة من رقم للذكاء الاصطناعي لم يُتحقق منه، أو تجاهل مشكلات البيانات |
| C6 | عدم التأكد وملاحظة استخدام الذكاء الاصطناعي (الجزء 7) | عدم تأكد محدد ومرتبط بالقرار؛ وملاحظة استخدام كاملة | عدم التأكد عام، أو الملاحظة ناقصة | غير موجود |
شروط أساسية (يجب تحقيقها كلها للنجاح)
- G1: لم تُدخل أي بيانات شخصية أو سرية أو أسرار في أداة ذكاء اصطناعي. واستُخدم الجدول المصطنع فقط.
- G2: وُثّق فحصان مستقلان على الأقل للتحقق مع نتائجهما.
- G3: قيمة AOV النهائية هي رقمك أنت المتحقَّق منه، ومتسقة مع طريقة المعالجة التي ذكرتها. ولا يظهر أي ادعاء غير مدعوم من الذكاء الاصطناعي (مثل رقم نمو أو سبب) في إجابتك النهائية على أنه حقيقة.
النتيجة
- PASS (ناجح): مجموع 9 أو أكثر من 12، ولا يوجد معيار حصل على 0، وكل الشروط الأساسية متحققة.
- REVISE (يحتاج تعديلًا): أي نتيجة أخرى. تحدد الملاحظات المعايير التي تحتاج إلى تحسين؛ ويُسمح بإعادة التسليم مرة واحدة.
لماذا هذا الحد؟ لأنه يتطلب أداءً قويًا في المجمل (75%) مع السماح بنقاط ضعف صغيرة. والشروط الأساسية تحمي جوهر هذه الوحدة: الاستخدام الآمن للبيانات، والتحقق الحقيقي، وتحمّل مسؤولية الإجابة النهائية. هذا الحد حكم تصميمي، وليس مُثبتًا إحصائيًا، ويجب مراجعته بعد توفر بيانات التجربة مع المتعلّمين.
هذا التقييم يقيس فهمك لمفاهيم U03. وهو ليس شهادة معتمدة، ولا يدّعي أي شيء عن جاهزيتك للعمل.
U04 · Python Fundamentalsأساسيات بايثون
Stage 1المرحلة 1Free: every lesson in this unit.
مجاني: كل دروس هذه الوحدة.
L13 · Python Environment, Variables & Data TypesL13 · بيئة Python والمتغيرات وأنواع البيانات Freeمجاني
L13 — Python Environment, Variables & Data Types
Learner file. Answers and model solutions are in a separate instructor-only file. Version: U04 v1.0 · Content date: 12 October 2026. Time estimates are provisional until learner-tested. Code examples were tested with Python 3.13 (see the U04 QA report).
1. Lesson Identity
| Field | Value |
|---|---|
| Title | Python Environment, Variables & Data Types |
| Stage | Stage 1 — Foundations |
| Unit | U04 — Python Fundamentals |
| Lesson ID | L13 |
| Skills | Python basics |
| Difficulty | Beginner (no programming experience assumed) |
| Estimated time | About 1 hour 45 minutes (provisional), including about 15 minutes of setup |
| Prerequisites | U01. Also helpful: U02 L06 (revenue, COGS, gross profit, gross margin) and U03 L11 (expected answer first; tracing). |
Time breakdown (provisional): setup, 15 min · concept and worked example, 30 min · guided practice, 15 min · independent practice, 10 min · knowledge check, 10 min · AI in Practice and Verification, 10 min · workplace task, 10 min · mini challenge, 5 min.
What you need: Python 3 installed on a computer (see Section 4), or a Python environment provided by your instructor. No packages, accounts or internet connection are needed once Python is installed. If you cannot run Python yet, you can still do the trace tasks (marked Trace OK), but U04 tasks marked Run need a working Python.
2. Learning Objective
By the end of this lesson, you will be able to run Python code and use variables with common data types (int, float, str, bool) to represent and calculate simple business values.
D.World map objective (verbatim): Run Python code and use variables with common data types.
3. Why It Matters
In U02 you calculated revenue, gross profit and margin by hand. That works for one product and one month. It does not work for hundreds of products every day.
Python lets you write a calculation once and run it again on new numbers. To trust that calculation, though, you must understand exactly what each line does. In particular, you need to know what type of value each variable holds, because the same symbol can behave differently with different types. Key principle: read code before changing it.
4. Concept
Where to run Python
You have two main options. Choose one; you do not need both.
- Install Python on your computer. Installers are available from python.org/downloads. Python's own documentation describes IDLE as "Python's Integrated Development and Learning Environment". It is an editor and shell that is often included with Python (on some systems it must be installed separately). Open IDLE, or a terminal, to start.
- Use an environment provided by your instructor. Follow their instructions.
Two ways to run code:
| Mode | What it looks like | Use it for |
|---|---|---|
| Interactive (the "shell") | A >>> prompt. Type one line, press Enter, see the result immediately |
Quick experiments |
Script (a .py file) |
Write several lines in a file, save it (e.g., revenue.py), then run the whole file |
Programs you want to keep and re-run |
In a terminal, the command to start Python is usually python3. On Windows it may be py, and the exact command can depend on how Python was installed. In IDLE, use File → New File to write a script and Run → Run Module to run it.
In interactive mode, typing a variable's name shows its value. In a script, you must use
print()to see anything. All examples in this lesson are written as scripts, so they useprint().
Your first lines
# This is a comment: Python ignores everything after the # sign.
print("Hello, Cedar Lane")
print(12 * 3)
Hello, Cedar Lane
36
Variables and assignment
A variable is a name that refers to a value. You create one with =:
price = 12.0
quantity = 3
revenue = price * quantity
print(revenue)
36.0
- In Python,
=means "assign": put the value on the right into the name on the left. It does not mean "is equal to". (Checking equality uses==, which comes in L14.) - The right-hand side is calculated first, then stored. So
quantity = quantity + 1means "take the current quantity, add 1, and store the result back". - Naming rules: letters, digits and
_; a name cannot start with a digit; names are case-sensitive (Priceandpriceare different). - Style (PEP 8): use lowercase words joined by underscores, such as
unit_costorgross_profit. Choose names that say what the value means, including the business meaning.
Four common data types
| Type | Meaning | Examples | Business use |
|---|---|---|---|
int |
Whole number | 3, 1000, -2 |
Quantities, counts of orders |
float |
Number with a decimal point | 12.0, 0.5, 58.3 |
Prices, revenue, percentages |
str (string) |
Text, inside quotes '...' or "..." |
"Notebook", "paid", "12" |
Product names, status labels |
bool (Boolean) |
Truth value: True or False |
True |
"Is this customer a member?" |
type(value) tells you the type:
print(type(1000))
print(type(12.0))
print(type("Notebook"))
print(type(True))
<class 'int'>
<class 'float'>
<class 'str'>
<class 'bool'>
Watch out:
- "12" (with quotes) is text, not a number.
- Division / always gives a float, even when the result is whole: 10 / 2 gives 5.0.
Converting between types
| Function | Does | Example | Result |
|---|---|---|---|
int(...) |
Convert to a whole number | int("3") |
3 |
float(...) |
Convert to a decimal number | float("12.5") |
12.5 |
str(...) |
Convert to text | str(36.0) |
'36.0' |
Values often arrive as text, for example from a web form or a file. You must convert them before doing arithmetic. Conversion can fail: int("3.5") raises a ValueError, because "3.5" is not a whole number.
Printing results clearly
An f-string puts values inside text. Write an f before the opening quote and place variable names in {}:
product = "Notebook"
revenue = 36.0
print(f"{product} revenue: {revenue} USD")
Notebook revenue: 36.0 USD
Decimal numbers are not always exact
Computers store most decimal numbers approximately:
print(0.1 + 0.2)
print(round(0.1 + 0.2, 2))
0.30000000000000004
0.3
This is normal; the Python Tutorial explains it in its chapter "Floating-Point Arithmetic: Issues and Limitations". For reports, round when you display a result, e.g., round(value, 1). Keep the unrounded value for further calculations.
5. Worked Example
Synthetic data, fictional Cedar Lane (same September figures as U02 L06). Notebooks sell for 12 USD each, cost 5 USD each, and 1,000 were sold.
Step 1: expected answer first (by hand). - Revenue = 12 × 1,000 = 12,000. - COGS = 5 × 1,000 = 5,000. - Gross profit = 7,000. - Gross margin = 7,000 ÷ 12,000 = 58.3%.
Step 2: write the program. (Run)
# Cedar Lane, September (synthetic data)
price = 12.0 # USD per notebook
unit_cost = 5.0 # USD per notebook
quantity = 1000 # notebooks sold
revenue = price * quantity
cogs = unit_cost * quantity
gross_profit = revenue - cogs
gross_margin_pct = gross_profit / revenue * 100
print(f"Revenue: {revenue} USD")
print(f"COGS: {cogs} USD")
print(f"Gross profit: {gross_profit} USD")
print(f"Gross margin: {round(gross_margin_pct, 1)} %")
print(type(quantity), type(revenue))
Revenue: 12000.0 USD
COGS: 5000.0 USD
Gross profit: 7000.0 USD
Gross margin: 58.3 %
<class 'int'> <class 'float'>
Step 3: read the output and compare.
- All four numbers match the hand calculation. ✔
- quantity is an int.
- revenue is a float, because float × int gives a float.
- The margin is rounded only when printed.
6. Visual Explanation
price ──────► 12.0 (float)
quantity ───► 1000 (int)
unit_cost ──► 5.0 (float)
revenue = price * quantity
12.0 * 1000 ──► 12000.0 (float) right side first, then stored
"12" + "3" ──► "123" (str + str joins text)
12 + 3 ──► 15 (int + int adds numbers)
"12" + 3 ──► TypeError (Python will not guess what you meant)
Alt text: Three variable names point to their values: price to 12.0 (a float), quantity to 1000 (an int), and unit_cost to 5.0 (a float). Below, the line revenue equals price times quantity is evaluated right side first: 12.0 times 1000 gives 12000.0, a float, which is then stored in revenue. Three comparisons follow: the text "12" plus the text "3" joins to "123"; the number 12 plus 3 gives 15; and the text "12" plus the number 3 gives a TypeError, because Python will not guess what you meant.
7. Guided Practice
(Run, or Trace OK.) October (synthetic, from U02): the price drops to 11 USD, 1,200 notebooks are sold, and the unit cost stays at 5 USD.
- By hand first: calculate revenue, COGS, gross profit and gross margin (%, 1 decimal).
- Copy the worked-example program into a new file. Before changing anything, read it and write next to each line what it does.
- Change only the values that differ in October. (Hint: which variables change? Which stay the same?)
- Run it. Compare every printed number with your hand calculation.
- Add one line that prints the type of
gross_margin_pct, and explain the result.
8. Independent Practice
(Run.) Synthetic data: Cedar Lane sold 350 pen sets at 8 USD each. Each pen set costs 3 USD.
- Write a program from scratch that stores these values in well-named variables and calculates revenue, COGS, gross profit and gross margin (%, 1 decimal).
- Print each result with a clear label and the unit (USD or %).
- Calculate the expected values by hand and record whether each output matches.
- Change
quantityto the text"350"(with quotes) and run again. Record the error's last line and explain it in one sentence. Then fix it without retyping the number, by converting the text.
No model answer is shown here.
9. Knowledge Check — Coding Task + Output Prediction
Part A — Predict the output. Write your prediction before running anything; then run to check (Trace OK, then Run).
A1.
quantity = 3
price = 12
print(quantity * price)
- A)
36 - B)
36.0 - C)
312 - D) An error
A2.
print(10 / 4)
- A)
2 - B)
2.0 - C)
2.5 - D) An error
A3.
first = "12"
second = "3"
print(first + second)
- A)
15 - B)
123 - C)
"15" - D) An error
A4.
price = "12"
print(price * 2)
- A)
24 - B)
24.0 - C) An error
- D)
1212
A5.
stock = 40
stock = stock - 15
stock = stock + 5
print(stock)
- A)
30 - B)
40 - C)
25 - D) An error, because
stockis assigned more than once
A6.
is_member = True
print(type(is_member))
- A)
<class 'str'> - B)
<class 'bool'> - C)
<class 'int'> - D)
True
Part B — Coding task (Run). Cedar Lane sells planners at 20 USD, with a unit cost of 8 USD. In one month it sold 45 planners. Write a program that:
1. stores the four inputs in variables with PEP 8-style names;
2. calculates revenue, gross profit and gross margin (%, 1 decimal);
3. prints them in one f-string line, e.g. Planner: revenue ... USD, gross profit ... USD, margin ... %;
4. includes one comment that states your hand-calculated expected margin.
10. AI in Practice
Ask AI to explain a type error, then reproduce and fix it locally.
- Reproduce it first (Run). Type and run this program yourself:
python
# Quantity arrives as text from an order form (synthetic)
quantity = "3"
price = 20.0
revenue = price * quantity
print(revenue)
Copy the last line of the error message.
- Ask an AI assistant (synthetic code only):
"I am a Python beginner. This code gives the error below. Explain in plain English what the error means, which line causes it, and suggest a minimal fix. Do not rewrite the whole program. """ (paste the code and the error's last line) """
- Verify the explanation using Section 11. Then apply the fix yourself and run it. What output do you expect?
- Test an edge case: change
quantityto"3.5"and run your fixed program. What happens? Is this good or bad behaviour for an order form? Write two sentences.
Why this can help: AI is good at translating error messages into plain language. Reproducing the error yourself first means you can check whether the explanation matches what you saw.
11. AI Verification
- Same error? Does the AI's explanation refer to the same error type and line you saw? If it describes a different error, it is guessing.
- Read before running: read the suggested fix line by line and predict its output before you run it.
- Run and compare with your expected answer (by hand: 3 × 20 = 60).
- Minimal change: reject fixes that rewrite unrelated lines or add packages you did not ask for.
- Edge case: test at least one unusual input (e.g.,
"3.5","three") and note what happens. - Privacy: paste only synthetic code and data. Never paste real customer data, passwords or keys into an AI tool.
12. Business Lens
Use variables to represent price, quantity, revenue and margin. Good variables make a business calculation readable and reusable:
- Meaningful names (
unit_cost, notx) let a manager or colleague check the logic. - Inputs at the top (price, unit cost, quantity), calculations below. Changing next month's figures means editing only the inputs.
- Correct types: quantities as
int, money and percentages asfloat, labels asstr. - Units in comments or labels (USD, %) prevent mix-ups.
- No hidden numbers: write
gross_profit / revenue * 100, not0.583, so the result updates when the inputs change.
13. Workplace Task — Bulk-Order Quote Check
Fictional business: Cedar Lane. A school (a fictional customer) asks for a quote for 150 notebooks at the usual price of 12 USD; the unit cost is 5 USD. Your manager asks: "Before I send the quote, what revenue and margin would we make?"
- Calculate revenue, COGS, gross profit and gross margin by hand.
- Write a short program with clearly named variables that prints a four-line summary for your manager.
- Add a comment at the top:
# Checked by hand: <your expected values>. - Write two sentences to your manager: the result, and one thing they should confirm before quoting (e.g., whether a discount applies; discounts come in L14).
14. Mini Challenge
Fictional business: Hilltop Honey (from U03) sold 400 jars at 10 USD, with a unit cost of 4 USD. A colleague's script prints a gross margin of 40.0 %:
jars = 400
price = 10.0
unit_cost = 4.0
revenue = price * jars
cogs = unit_cost * jars
gross_margin_pct = cogs / revenue * 100
print(round(gross_margin_pct, 1))
- Read the code before changing it. Which line is wrong, and why? (Python gives no error.)
- Fix it with the smallest change, then run it and check the result against a hand calculation.
- In one sentence, explain why "the code runs" did not mean "the code is right".
Submit before feedback. No solution is provided here.
15. Resources
- Required (about 20 min): The Python Tutorial, chapter 3, "An Informal Introduction to Python" (sections on numbers, text and the
=sign), and skim chapter 2, "Using the Python Interpreter". https://docs.python.org/3/tutorial/ (Opened and checked 12 Oct 2026; the page showed the Python 3.15.0 documentation.) Note: the Tutorial itself says it is designed for programmers new to Python, not for complete beginners. Read only the sections listed, and use this lesson as your main explanation. - Recommended: IDLE — Python editor and shell (documentation page). https://docs.python.org/3/library/idle.html (Opened and checked 12 Oct 2026.)
- Deeper (optional): The Python Tutorial, chapter 15, "Floating-Point Arithmetic: Issues and Limitations", for why
0.1 + 0.2is not exactly0.3.
16. Person to Follow / Role Model
Wes McKinney (mapped by D.World for U04).
- Verified facts (12 Oct 2026): on his website he states that he wrote Python for Data Analysis. The book's 3rd edition is available there as an "Open Access" HTML version, and its page says it "has been updated for pandas 2.0.0 and Python 3.10". https://wesmckinney.com/book/
- Why D.World recommends him: the map links him to Python and analytical computing, connecting practical data analysis with Python.
- Honest note: his book goes far beyond this lesson and uses libraries (such as pandas) that U04 does not require. Treat it as a preview of where Python fundamentals lead.
- Try this: open the book's online page and find where it mentions Python and pandas versions. Note one thing you recognise from this lesson, such as a variable, a type or
print.
His current roles change over time; check his own site for details.
17. Glossary
| Term | Meaning in this lesson |
|---|---|
| Interpreter | The program that reads and runs Python code |
| Interactive mode / shell | Running Python one line at a time at the >>> prompt |
| Script | A saved .py file containing a program |
| Variable | A name that refers to a value |
Assignment (=) |
Storing the value on the right in the name on the left |
| Data type | The kind of value: int, float, str, bool |
int / float |
Whole number / number with a decimal point |
str (string) |
Text inside quotes |
bool (Boolean) |
True or False |
| Type conversion | Changing a value's type with int(), float() or str() |
| f-string | Text with {} placeholders filled by values, written f"..." |
| Comment | Text after # that Python ignores |
TypeError / ValueError |
Errors raised when an operation gets the wrong type / a value that cannot be converted |
18. Reflection
Before running the worked example, did you predict what each line would print? Where was your prediction wrong, and what did that teach you about how Python treats types?
19. Next Step
Variables store values; the next step is making decisions with them. In L14 — Operators & Conditions, you will compare values (==, >=), combine conditions (and, or, not) and use if/elif/else to encode business rules such as discounts and stock alerts.
20. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Output prediction, Part A (A1–A6) | Reads code and predicts behaviour by type | 5 or more of 6 correct |
| Coding task, Part B (planner) | Writes a correct, readable calculation with variables and types | Rubric L13-KCB |
| AI in Practice (type error) | Reproduces, verifies and fixes an error; tests an edge case | Rubric L13-AI |
| Guided and independent practice, workplace task, mini challenge | Calculates business values in Python and checks against hand calculations | Rubrics L13-GP, L13-IP, L13-WT, L13-MC |
References
- Python Software Foundation. The Python Tutorial (chapters 2, 3 and 15). https://docs.python.org/3/tutorial/ (opened and checked 12 Oct 2026; documentation header showed 3.15.0). Supports: "Division (
/) always returns a float"; "The equal sign (=) is used to assign a value to a variable"; strings in single or double quotes; using an undefined variable gives an error; the Tutorial's "programmers … not beginners" note. - Python Software Foundation. IDLE — Python editor and shell. https://docs.python.org/3/library/idle.html (opened and checked 12 Oct 2026). Supports: IDLE described as "Python's Integrated Development and Learning Environment"; optional module.
- van Rossum, G., Warsaw, B., & Coghlan, A. PEP 8 – Style Guide for Python Code. https://peps.python.org/pep-0008/ (opened and checked 12 Oct 2026). Supports: lowercase-with-underscores names.
- McKinney, W. Python for Data Analysis, 3rd ed. (Open Access HTML). https://wesmckinney.com/book/ and https://wesmckinney.com/ (opened and checked 12 Oct 2026).
- D.World Curriculum Map v1.0 (L13 row) and Curriculum Bible v1.0. Internal.
L13 — بيئة Python والمتغيرات وأنواع البيانات
ملف المتعلّم. الإجابات والحلول النموذجية في ملف منفصل خاص بالمدرّس فقط. الإصدار: U04 v1.0 · تاريخ المحتوى: 12 أكتوبر 2026. تقديرات الوقت مبدئية إلى أن تُجرَّب مع المتعلّمين. أمثلة الكود مُختبَرة على Python 3.13 (راجع تقرير الجودة QA الخاص بـ U04).
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | بيئة Python والمتغيرات وأنواع البيانات |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U04 — أساسيات Python |
| رقم الدرس | L13 |
| المهارات | أساسيات Python |
| المستوى | مبتدئ (لا يُفترض أي خبرة سابقة في البرمجة) |
| الوقت المتوقع | حوالي ساعة و45 دقيقة (مبدئي)، منها حوالي 15 دقيقة للتجهيز |
| المتطلبات السابقة | U01. ومن المفيد أيضًا: L06 في U02 (الإيرادات، وتكلفة البضاعة المباعة COGS، ومجمل الربح، وهامش الربح الإجمالي) وL11 في U03 (الإجابة المتوقعة أولًا؛ والتتبّع). |
تفصيل الوقت (مبدئي): التجهيز 15 دقيقة · المفهوم والمثال المحلول 30 دقيقة · التدريب الموجَّه 15 دقيقة · التدريب المستقل 10 دقائق · اختبار الفهم 10 دقائق · الذكاء الاصطناعي في التطبيق والتحقق 10 دقائق · مهمة العمل 10 دقائق · التحدي القصير 5 دقائق.
ما تحتاجه: Python 3 مثبّتًا على جهاز كمبيوتر (راجع القسم 4)، أو بيئة Python يوفّرها لك المدرّس. لا تحتاج إلى أي حزم أو حسابات أو اتصال بالإنترنت بعد تثبيت Python. إذا لم تستطع تشغيل Python بعد، فما زال بإمكانك حل مهام التتبّع (المعلَّمة بـ Trace OK)، لكن مهام U04 المعلَّمة بـ Run تحتاج إلى Python يعمل.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تشغّل كود Python، وأن تستخدم المتغيرات مع أنواع البيانات الشائعة (int وfloat وstr وbool) لتمثيل قيم أعمال بسيطة وحسابها.
هدف خريطة D.World (بنصّه): Run Python code and use variables with common data types.
3. لماذا يهمّك هذا؟
في U02 حسبت الإيرادات ومجمل الربح والهامش يدويًا. هذا ينفع لمنتج واحد وشهر واحد، لكنه لا ينفع لمئات المنتجات كل يوم.
Python يتيح لك أن تكتب الحساب مرة واحدة ثم تشغّله من جديد على أرقام جديدة. لكن لكي تثق في هذا الحساب، يجب أن تفهم بدقة ما يفعله كل سطر. وبالأخص، يجب أن تعرف نوع القيمة التي يحملها كل متغير، لأن الرمز نفسه قد يتصرف بشكل مختلف مع الأنواع المختلفة. المبدأ الأساسي: اقرأ الكود قبل أن تغيّره.
4. المفهوم
أين تشغّل Python؟
أمامك خياران رئيسيان. اختر واحدًا منهما؛ لا تحتاج إلى الاثنين.
- ثبّت Python على جهازك. ملفات التثبيت متاحة على python.org/downloads. توثيق Python نفسه يصف IDLE بأنه "Python's Integrated Development and Learning Environment" (بيئة Python المتكاملة للتطوير والتعلّم). وهو محرّر وواجهة تفاعلية (shell) يأتي غالبًا مع Python (وفي بعض الأنظمة يجب تثبيته منفصلًا). افتح IDLE، أو نافذة الطرفية (terminal)، لتبدأ.
- استخدم بيئة يوفّرها لك المدرّس. اتبع تعليماته.
طريقتان لتشغيل الكود:
| الوضع | كيف يبدو | متى تستخدمه |
|---|---|---|
| التفاعلي (Interactive، أو الـ "shell") | علامة >>>. اكتب سطرًا واحدًا، واضغط Enter، وسترى النتيجة فورًا |
التجارب السريعة |
السكربت (Script، ملف .py) |
اكتب عدة أسطر في ملف، واحفظه (مثلًا revenue.py)، ثم شغّل الملف كله |
البرامج التي تريد الاحتفاظ بها وإعادة تشغيلها |
في الطرفية، يكون أمر تشغيل Python عادةً python3. وفي Windows قد يكون py، والأمر الدقيق قد يعتمد على طريقة تثبيت Python. وفي IDLE، استخدم File → New File لكتابة سكربت، وRun → Run Module لتشغيله.
في الوضع التفاعلي، كتابة اسم المتغير تعرض قيمته. أما في السكربت، فيجب أن تستخدم
print()لترى أي شيء. كل الأمثلة في هذا الدرس مكتوبة كسكربتات، ولذلك تستخدمprint().
أول أسطرك
# This is a comment: Python ignores everything after the # sign.
print("Hello, Cedar Lane")
print(12 * 3)
Hello, Cedar Lane
36
السطر الأول تعليق (comment): Python يتجاهل كل ما يأتي بعد العلامة #.
المتغيرات والإسناد
المتغير (variable) اسم يشير إلى قيمة. تنشئه باستخدام =:
price = 12.0
quantity = 3
revenue = price * quantity
print(revenue)
36.0
- في Python،
=تعني "أسنِد" (assign): ضع القيمة التي على اليمين في الاسم الذي على اليسار. وهي لا تعني "يساوي". (فحص التساوي يستخدم==، وستتعلمه في L14.) - الطرف الأيمن يُحسب أولًا، ثم يُخزَّن. لذلك
quantity = quantity + 1تعني: "خذ الكمية الحالية، وأضف إليها 1، وخزّن النتيجة في المتغير نفسه". - قواعد التسمية: حروف وأرقام و
_؛ ولا يجوز أن يبدأ الاسم برقم؛ والأسماء حساسة لحالة الأحرف (Priceوpriceاسمان مختلفان). - الأسلوب (PEP 8): استخدم كلمات بأحرف صغيرة تفصل بينها شرطة سفلية، مثل
unit_costأوgross_profit. واختر أسماء تقول ماذا تعني القيمة، بما في ذلك معناها في الأعمال.
أربعة أنواع بيانات شائعة
| النوع | المعنى | أمثلة | الاستخدام في الأعمال |
|---|---|---|---|
int |
عدد صحيح | 3، 1000، -2 |
الكميات، وعدد الطلبات |
float |
عدد بعلامة عشرية | 12.0، 0.5، 58.3 |
الأسعار، والإيرادات، والنسب المئوية |
str (نص، string) |
نص بين علامتي تنصيص '...' أو "..." |
"Notebook"، "paid"، "12" |
أسماء المنتجات، وتسميات الحالة |
bool (قيمة منطقية، Boolean) |
قيمة صواب أو خطأ: True أو False |
True |
"هل هذا العميل عضو؟" |
الدالة type(value) تخبرك بالنوع:
print(type(1000))
print(type(12.0))
print(type("Notebook"))
print(type(True))
<class 'int'>
<class 'float'>
<class 'str'>
<class 'bool'>
انتبه:
"12"(بعلامتي التنصيص) نص، وليس رقمًا.- القسمة
/تعطي دائمًاfloat، حتى لو كانت النتيجة عددًا صحيحًا:10 / 2تعطي5.0.
التحويل بين الأنواع
| الدالة | ماذا تفعل | مثال | النتيجة |
|---|---|---|---|
int(...) |
تحوّل إلى عدد صحيح | int("3") |
3 |
float(...) |
تحوّل إلى عدد عشري | float("12.5") |
12.5 |
str(...) |
تحوّل إلى نص | str(36.0) |
'36.0' |
كثيرًا ما تصل القيم في صورة نص، مثلًا من نموذج على موقع أو من ملف. ويجب أن تحوّلها قبل إجراء أي عملية حسابية. وقد يفشل التحويل: int("3.5") يُطلق خطأ ValueError، لأن "3.5" ليس عددًا صحيحًا.
طباعة النتائج بوضوح
الـ f-string يضع القيم داخل النص. اكتب الحرف f قبل علامة التنصيص الأولى، وضع أسماء المتغيرات بين {}:
product = "Notebook"
revenue = 36.0
print(f"{product} revenue: {revenue} USD")
Notebook revenue: 36.0 USD
الأعداد العشرية ليست دقيقة دائمًا
أجهزة الكمبيوتر تخزّن معظم الأعداد العشرية بشكل تقريبي:
print(0.1 + 0.2)
print(round(0.1 + 0.2, 2))
0.30000000000000004
0.3
هذا أمر طبيعي، ويشرحه دليل Python التعليمي (The Python Tutorial) في فصل "Floating-Point Arithmetic: Issues and Limitations". في التقارير، قرّب الرقم عند عرضه، مثلًا round(value, 1). واحتفظ بالقيمة غير المقرَّبة لأي حسابات لاحقة.
5. مثال محلول
بيانات مصطنعة، لمتجر Cedar Lane الخيالي (أرقام سبتمبر نفسها من L06 في U02). الكشكول يُباع بـ 12 دولارًا، وتكلفته 5 دولارات، وبيعت منه 1,000 قطعة.
الخطوة 1: الإجابة المتوقعة أولًا (يدويًا).
- الإيرادات = 12 × 1,000 = 12,000.
- تكلفة البضاعة المباعة (COGS) = 5 × 1,000 = 5,000.
- مجمل الربح = 7,000.
- هامش الربح الإجمالي = 7,000 ÷ 12,000 = 58.3%.
الخطوة 2: اكتب البرنامج. (Run)
# Cedar Lane, September (synthetic data)
price = 12.0 # USD per notebook
unit_cost = 5.0 # USD per notebook
quantity = 1000 # notebooks sold
revenue = price * quantity
cogs = unit_cost * quantity
gross_profit = revenue - cogs
gross_margin_pct = gross_profit / revenue * 100
print(f"Revenue: {revenue} USD")
print(f"COGS: {cogs} USD")
print(f"Gross profit: {gross_profit} USD")
print(f"Gross margin: {round(gross_margin_pct, 1)} %")
print(type(quantity), type(revenue))
Revenue: 12000.0 USD
COGS: 5000.0 USD
Gross profit: 7000.0 USD
Gross margin: 58.3 %
<class 'int'> <class 'float'>
الخطوة 3: اقرأ المخرجات وقارن.
- الأرقام الأربعة كلها تطابق الحساب اليدوي. ✔
quantityمن النوعint.revenueمن النوعfloat، لأنfloat × intتعطيfloat.- الهامش يُقرَّب عند الطباعة فقط.
6. شرح بصري
price ──────► 12.0 (float)
quantity ───► 1000 (int)
unit_cost ──► 5.0 (float)
revenue = price * quantity
12.0 * 1000 ──► 12000.0 (float) right side first, then stored
"12" + "3" ──► "123" (str + str joins text)
12 + 3 ──► 15 (int + int adds numbers)
"12" + 3 ──► TypeError (Python will not guess what you meant)
وصف الرسم: ثلاثة أسماء متغيرات تشير إلى قيمها: price إلى 12.0 (من النوع float)، وquantity إلى 1000 (من النوع int)، وunit_cost إلى 5.0 (من النوع float). وتحتها يُحسب سطر revenue = price * quantity بدءًا من الطرف الأيمن: 12.0 ضرب 1000 يعطي 12000.0 من النوع float، ثم تُخزَّن في revenue. وبعدها ثلاث مقارنات: النص "12" زائد النص "3" يُدمجان فيصبحان "123"؛ والعدد 12 زائد 3 يعطي 15؛ أما النص "12" زائد العدد 3 فيعطي خطأ TypeError، لأن Python لن يخمّن ما تقصده.
7. تدريب موجَّه
(Run، أو Trace OK.) أكتوبر (بيانات مصطنعة، من U02): ينخفض السعر إلى 11 دولارًا، وتُباع 1,200 قطعة كشكول، وتبقى تكلفة القطعة 5 دولارات.
- يدويًا أولًا: احسب الإيرادات، وتكلفة البضاعة المباعة، ومجمل الربح، وهامش الربح الإجمالي (%، برقم عشري واحد).
- انسخ برنامج المثال المحلول في ملف جديد. وقبل أن تغيّر أي شيء، اقرأه واكتب بجانب كل سطر ماذا يفعل.
- غيّر فقط القيم المختلفة في أكتوبر. (تلميح: أي المتغيرات تتغير؟ وأيها يبقى كما هو؟)
- شغّل البرنامج. وقارن كل رقم مطبوع بحسابك اليدوي.
- أضف سطرًا واحدًا يطبع نوع
gross_margin_pct، واشرح النتيجة.
8. تدريب مستقل
(Run.) بيانات مصطنعة: باع Cedar Lane 350 طقم أقلام بسعر 8 دولارات للطقم. وتكلفة الطقم الواحد 3 دولارات.
- اكتب برنامجًا من الصفر يخزّن هذه القيم في متغيرات بأسماء جيدة، ويحسب الإيرادات، وتكلفة البضاعة المباعة، ومجمل الربح، وهامش الربح الإجمالي (%، برقم عشري واحد).
- اطبع كل نتيجة مع تسمية واضحة والوحدة (USD أو %).
- احسب القيم المتوقعة يدويًا، وسجّل هل تطابق كل نتيجة مطبوعة توقّعك أم لا.
- غيّر
quantityإلى النص"350"(بعلامتي التنصيص) وشغّل البرنامج مرة أخرى. سجّل آخر سطر في رسالة الخطأ، واشرحه في جملة واحدة. ثم أصلحه دون أن تعيد كتابة الرقم، وذلك بتحويل النص.
لا تُعرض هنا إجابة نموذجية.
9. اختبار الفهم — مهمة برمجة + توقّع المخرجات
الجزء A — توقّع المخرجات. اكتب توقّعك قبل أن تشغّل أي شيء، ثم شغّل الكود لتتأكد (Trace OK، ثم Run).
A1.
quantity = 3
price = 12
print(quantity * price)
- A)
36 - B)
36.0 - C)
312 - D) خطأ
A2.
print(10 / 4)
- A)
2 - B)
2.0 - C)
2.5 - D) خطأ
A3.
first = "12"
second = "3"
print(first + second)
- A)
15 - B)
123 - C)
"15" - D) خطأ
A4.
price = "12"
print(price * 2)
- A)
24 - B)
24.0 - C) خطأ
- D)
1212
A5.
stock = 40
stock = stock - 15
stock = stock + 5
print(stock)
- A)
30 - B)
40 - C)
25 - D) خطأ، لأن
stockأُسنِدت إليه قيمة أكثر من مرة
A6.
is_member = True
print(type(is_member))
- A)
<class 'str'> - B)
<class 'bool'> - C)
<class 'int'> - D)
True
الجزء B — مهمة برمجة (Run). يبيع Cedar Lane الأجندات (planners) بسعر 20 دولارًا، وتكلفة الواحدة 8 دولارات. وفي شهر واحد باع 45 أجندة. اكتب برنامجًا:
- يخزّن المدخلات الأربعة في متغيرات بأسماء على نمط PEP 8؛
- يحسب الإيرادات، ومجمل الربح، وهامش الربح الإجمالي (%، برقم عشري واحد)؛
- يطبعها في سطر واحد باستخدام f-string، مثل
Planner: revenue ... USD, gross profit ... USD, margin ... %؛ - يحتوي على تعليق واحد يذكر الهامش المتوقع الذي حسبته يدويًا.
10. الذكاء الاصطناعي في التطبيق
اطلب من الذكاء الاصطناعي أن يشرح خطأ نوع (type error)، ثم أعِد إنتاج الخطأ وأصلحه بنفسك على جهازك.
- أعِد إنتاج الخطأ أولًا (Run). اكتب هذا البرنامج وشغّله بنفسك:
# Quantity arrives as text from an order form (synthetic)
quantity = "3"
price = 20.0
revenue = price * quantity
print(revenue)
(التعليق يقول: الكمية تصل كنص من نموذج طلب، والبيانات مصطنعة.) انسخ آخر سطر في رسالة الخطأ.
- اسأل مساعد ذكاء اصطناعي (كود مصطنع فقط):
"I am a Python beginner. This code gives the error below. Explain in plain English what the error means, which line causes it, and suggest a minimal fix. Do not rewrite the whole program. """ (paste the code and the error's last line) """
وبالعربية: "أنا مبتدئ في Python. هذا الكود يعطي الخطأ الموجود بالأسفل. اشرح بلغة بسيطة ماذا يعني الخطأ، وأي سطر يسببه، واقترح أصغر إصلاح ممكن. لا تُعِد كتابة البرنامج كله. """ (الصق الكود وآخر سطر في رسالة الخطأ) """"
- تحقّق من الشرح باستخدام القسم 11. ثم طبّق الإصلاح بنفسك وشغّل البرنامج. ما المخرجات التي تتوقعها؟
- اختبر حالة طرفية (edge case): غيّر
quantityإلى"3.5"وشغّل برنامجك بعد الإصلاح. ماذا يحدث؟ وهل هذا سلوك جيد أم سيئ في نموذج طلب؟ اكتب جملتين.
لماذا قد يفيدك هذا: الذكاء الاصطناعي جيد في ترجمة رسائل الخطأ إلى لغة بسيطة. وإعادة إنتاج الخطأ بنفسك أولًا تعني أنك تستطيع أن تتحقق هل الشرح يطابق ما رأيته أنت.
11. التحقق من مخرجات الذكاء الاصطناعي
- هل هو الخطأ نفسه؟ هل يشير شرح الذكاء الاصطناعي إلى نوع الخطأ نفسه والسطر نفسه اللذين رأيتهما؟ إذا وصف خطأً مختلفًا، فهو يخمّن.
- اقرأ قبل أن تشغّل: اقرأ الإصلاح المقترح سطرًا سطرًا، وتوقّع مخرجاته قبل أن تشغّله.
- شغّل وقارن بالإجابة المتوقعة (يدويًا: 3 × 20 = 60).
- أصغر تغيير: ارفض الإصلاحات التي تعيد كتابة أسطر لا علاقة لها بالمشكلة، أو تضيف حزمًا لم تطلبها.
- الحالة الطرفية: اختبر مدخلًا غير معتاد واحدًا على الأقل (مثل
"3.5"أو"three") ولاحظ ماذا يحدث. - الخصوصية: الصق كودًا وبيانات مصطنعة فقط. لا تلصق أبدًا بيانات عملاء حقيقية أو كلمات مرور أو مفاتيح في أداة ذكاء اصطناعي.
12. منظور الأعمال
استخدم المتغيرات لتمثيل السعر والكمية والإيرادات والهامش. المتغيرات الجيدة تجعل حساب الأعمال مقروءًا وقابلًا لإعادة الاستخدام:
- الأسماء ذات المعنى (
unit_cost، وليسx) تتيح للمدير أو الزميل أن يراجع المنطق. - المدخلات في الأعلى (السعر، وتكلفة القطعة، والكمية)، والحسابات تحتها. وتغيير أرقام الشهر القادم يعني تعديل المدخلات فقط.
- الأنواع الصحيحة: الكميات
int، والمبالغ المالية والنسب المئويةfloat، والتسمياتstr. - الوحدات في التعليقات أو التسميات (USD، %) تمنع الخلط.
- لا أرقام مخفية: اكتب
gross_profit / revenue * 100، وليس0.583، حتى تتحدّث النتيجة عندما تتغير المدخلات.
13. مهمة عمل — مراجعة عرض سعر لطلب كبير
نشاط تجاري خيالي: Cedar Lane. طلبت مدرسة (عميل خيالي) عرض سعر لـ 150 كشكولًا بالسعر المعتاد 12 دولارًا؛ وتكلفة القطعة 5 دولارات. ويسألك مديرك: "قبل أن أرسل عرض السعر، كم ستكون الإيرادات والهامش؟"
- احسب الإيرادات، وتكلفة البضاعة المباعة، ومجمل الربح، وهامش الربح الإجمالي يدويًا.
- اكتب برنامجًا قصيرًا بمتغيرات ذات أسماء واضحة يطبع ملخصًا من أربعة أسطر لمديرك.
- أضف تعليقًا في أعلى البرنامج:
# Checked by hand: <your expected values>(أي: "روجع يدويًا: القيم التي توقعتها"). - اكتب جملتين لمديرك: النتيجة، وشيئًا واحدًا يجب أن يتأكد منه قبل إرسال العرض (مثلًا: هل يُطبَّق خصم؛ والخصومات ستأتي في L14).
14. تحدٍّ قصير
نشاط تجاري خيالي: Hilltop Honey (من U03) باع 400 برطمان بسعر 10 دولارات، وتكلفة البرطمان 4 دولارات. سكربت كتبه زميلك يطبع هامش ربح إجمالي قدره 40.0 %:
jars = 400
price = 10.0
unit_cost = 4.0
revenue = price * jars
cogs = unit_cost * jars
gross_margin_pct = cogs / revenue * 100
print(round(gross_margin_pct, 1))
- اقرأ الكود قبل أن تغيّره. أي سطر خطأ، ولماذا؟ (Python لا يعطي أي رسالة خطأ.)
- أصلحه بأصغر تغيير ممكن، ثم شغّله وقارن النتيجة بحساب يدوي.
- اشرح في جملة واحدة لماذا "الكود يعمل" لم تكن تعني "الكود صحيح".
سلّم إجابتك قبل الحصول على التعليقات. لا يوجد حل هنا.
15. المصادر
- مطلوب (حوالي 20 دقيقة): The Python Tutorial، الفصل 3، "An Informal Introduction to Python" (الأجزاء الخاصة بالأرقام والنصوص وعلامة
=)، وتصفّح سريع للفصل 2، "Using the Python Interpreter". https://docs.python.org/3/tutorial/ (فُتح وروجع في 12 أكتوبر 2026؛ وكانت الصفحة تعرض توثيق Python 3.15.0.) ملاحظة: الدليل نفسه يقول إنه مصمَّم للمبرمجين الجدد على Python، وليس للمبتدئين تمامًا في البرمجة. اقرأ الأجزاء المذكورة فقط، واعتمد على هذا الدرس كشرح أساسي. - موصى به: IDLE — Python editor and shell (صفحة التوثيق). https://docs.python.org/3/library/idle.html (فُتحت وروجعت في 12 أكتوبر 2026.)
- للتعمّق (اختياري): The Python Tutorial، الفصل 15، "Floating-Point Arithmetic: Issues and Limitations"، لتعرف لماذا
0.1 + 0.2لا تساوي0.3بالضبط.
16. شخصية تتابعها / قدوة
Wes McKinney (اختارته D.World لوحدة U04).
- حقائق موثّقة (12 أكتوبر 2026): يذكر على موقعه أنه كتب Python for Data Analysis. والطبعة الثالثة من الكتاب متاحة هناك كنسخة HTML مفتوحة الوصول ("Open Access")، وتقول صفحته إنه "has been updated for pandas 2.0.0 and Python 3.10" (حُدِّث ليتوافق مع pandas 2.0.0 وPython 3.10). https://wesmckinney.com/book/
- لماذا ترشّحه D.World: الخريطة تربطه بـ Python والحوسبة التحليلية، فهو يصل بين تحليل البيانات العملي وPython.
- ملاحظة صريحة: كتابه يتجاوز هذا الدرس بكثير، ويستخدم مكتبات (مثل pandas) لا تحتاجها U04. تعامل معه كلمحة عمّا تقودك إليه أساسيات Python.
- جرّب هذا: افتح صفحة الكتاب على الإنترنت وابحث عن المكان الذي يذكر فيه إصدارات Python وpandas. ودوّن شيئًا واحدًا تعرفه من هذا الدرس، مثل متغير أو نوع بيانات أو
print.
مناصبه الحالية تتغير مع الوقت؛ راجع موقعه الشخصي للتفاصيل.
17. المصطلحات
| المصطلح | معناه في هذا الدرس |
|---|---|
| المفسِّر (Interpreter) | البرنامج الذي يقرأ كود Python ويشغّله |
| الوضع التفاعلي / الـ shell (Interactive mode) | تشغيل Python سطرًا بسطر عند علامة >>> |
| السكربت (Script) | ملف .py محفوظ يحتوي على برنامج |
| المتغير (Variable) | اسم يشير إلى قيمة |
الإسناد (Assignment، =) |
تخزين القيمة التي على اليمين في الاسم الذي على اليسار |
| نوع البيانات (Data type) | نوع القيمة: int أو float أو str أو bool |
int / float |
عدد صحيح / عدد بعلامة عشرية |
str (نص، string) |
نص بين علامتي تنصيص |
bool (قيمة منطقية، Boolean) |
True أو False |
| تحويل النوع (Type conversion) | تغيير نوع القيمة باستخدام int() أو float() أو str() |
| f-string | نص فيه أماكن {} تُملأ بالقيم، ويُكتب f"..." |
| التعليق (Comment) | نص بعد # يتجاهله Python |
TypeError / ValueError |
أخطاء تظهر عندما تتلقى عملية نوعًا خاطئًا / قيمة لا يمكن تحويلها |
18. تأمّل
قبل أن تشغّل المثال المحلول، هل توقّعت ما سيطبعه كل سطر؟ أين كان توقّعك خاطئًا، وماذا علّمك ذلك عن طريقة تعامل Python مع الأنواع؟
19. الخطوة التالية
المتغيرات تخزّن القيم؛ والخطوة التالية هي اتخاذ القرارات بها. في L14 — العوامل والشروط، ستقارن القيم (==، >=)، وتجمع الشروط (and، or، not)، وتستخدم if/elif/else لتحويل قواعد الأعمال إلى كود، مثل الخصومات وتنبيهات المخزون.
20. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| توقّع المخرجات، الجزء A (A1–A6) | قراءة الكود وتوقّع سلوكه حسب الأنواع | 5 إجابات صحيحة أو أكثر من 6 |
| مهمة البرمجة، الجزء B (الأجندات) | كتابة حساب صحيح ومقروء باستخدام المتغيرات والأنواع | معايير L13-KCB |
| الذكاء الاصطناعي في التطبيق (خطأ النوع) | إعادة إنتاج الخطأ والتحقق منه وإصلاحه؛ واختبار حالة طرفية | معايير L13-AI |
| التدريب الموجَّه والمستقل، ومهمة العمل، والتحدي القصير | حساب قيم الأعمال في Python ومقارنتها بالحسابات اليدوية | معايير L13-GP وL13-IP وL13-WT وL13-MC |
المراجع
- Python Software Foundation. The Python Tutorial (الفصول 2 و3 و15). https://docs.python.org/3/tutorial/ (فُتح وروجع في 12 أكتوبر 2026؛ وكان رأس التوثيق يعرض 3.15.0). يدعم: "Division (
/) always returns a float"؛ و"The equal sign (=) is used to assign a value to a variable"؛ والنصوص بين علامات تنصيص مفردة أو مزدوجة؛ واستخدام متغير غير معرَّف يعطي خطأ؛ وملاحظة الدليل بأنه موجّه للمبرمجين وليس للمبتدئين. - Python Software Foundation. IDLE — Python editor and shell. https://docs.python.org/3/library/idle.html (فُتحت وروجعت في 12 أكتوبر 2026). يدعم: وصف IDLE بأنه "Python's Integrated Development and Learning Environment"؛ وأنه وحدة اختيارية.
- van Rossum, G., Warsaw, B., & Coghlan, A. PEP 8 – Style Guide for Python Code. https://peps.python.org/pep-0008/ (فُتح وروجع في 12 أكتوبر 2026). يدعم: الأسماء بأحرف صغيرة تفصل بينها شرطة سفلية.
- McKinney, W. Python for Data Analysis، الطبعة الثالثة (نسخة HTML مفتوحة الوصول). https://wesmckinney.com/book/ وhttps://wesmckinney.com/ (فُتحا وروجعا في 12 أكتوبر 2026).
- D.World Curriculum Map v1.0 (صف L13) وCurriculum Bible v1.0. وثائق داخلية.
L14 · Operators & ConditionsL14 · العوامل والشروط Freeمجاني
L14 — Operators & Conditions
Learner file. Answers and model solutions are in a separate instructor-only file. Version: U04 v1.0 · Content date: 12 October 2026. Time estimates are provisional until learner-tested. Code examples were tested with Python 3.13 (see the U04 QA report).
1. Lesson Identity
| Field | Value |
|---|---|
| Title | Operators & Conditions |
| Stage | Stage 1 — Foundations |
| Unit | U04 — Python Fundamentals |
| Lesson ID | L14 |
| Skills | Control flow; logic |
| Difficulty | Beginner |
| Estimated time | About 1 hour 50 minutes (provisional) |
| Prerequisites | L13 (variables, int/float/str/bool, running a script). U03 L11 (boundary test cases). |
Time breakdown (provisional): concept and worked example, 35 min · guided practice, 15 min · independent practice, 15 min · knowledge check, 15 min · AI in Practice and Verification, 10 min · workplace task, 15 min · mini challenge, 5 min.
2. Learning Objective
By the end of this lesson, you will be able to use arithmetic, comparison and Boolean operators and if/elif/else to encode simple business decisions, and test them at their boundaries.
D.World map objective (verbatim): Use arithmetic, comparison, boolean logic, and if/elif/else to encode simple decisions.
3. Why It Matters
Businesses run on rules: - "Orders of 100 USD or more get 10% off." - "Reorder when stock falls to 20 or below." - "Members get free shipping from 20 USD."
When you turn a rule into code, every word matters. "100 or more" and "more than 100" give different answers for an order of exactly 100. Put the checks in the wrong order and some customers silently get the wrong discount. Neither mistake crashes the program. Key principle: conditions should reflect business rules explicitly.
4. Concept
Arithmetic operators
| Operator | Meaning | Example | Result |
|---|---|---|---|
+ - * |
Add, subtract, multiply | 12 * 3 |
36 |
/ |
Divide (always gives a float) |
7 / 2 |
3.5 |
// |
Floor division (whole-number part, for positive numbers) | 7 // 2 |
3 |
% |
Remainder | 7 % 2 |
1 |
** |
Power | 2 ** 3 |
8 |
Order: *, /, // and % are done before + and -, as in ordinary arithmetic. Use parentheses to make your intention clear: (price - discount) * quantity.
Comparison operators: they give True or False
| Operator | Meaning | Example | Result |
|---|---|---|---|
== |
Equal to | stock == 0 |
True if stock is 0 |
!= |
Not equal to | status != "paid" |
|
< > |
Less than / greater than | total > 100 |
|
<= >= |
Less than or equal / greater than or equal | total >= 100 |
= vs ==:
- = assigns a value (L13).
- == asks whether two values are equal.
Writing if quantity = 100: is a mistake. Python stops with a SyntaxError; in Python 3.13 the message even suggests '=='.
Boolean logic: and, or, not
| Expression | True when… |
|---|---|
a and b |
both are True |
a or b |
at least one is True |
not a |
a is False |
Example: is_member and total >= 20 is True only for members with at least 20 USD.
When you mix and with or, use parentheses to show which conditions belong together.
if / elif / else
stock = 12
reorder_level = 20
if stock <= reorder_level:
print("Reorder")
else:
print("Stock OK")
Reorder
- The line after
if,elifandelseends with a colon:. - The code that belongs to the branch is indented (PEP 8 and the Tutorial both recommend 4 spaces). Indentation is not decoration in Python: it defines which lines belong to the branch. A missing indent gives an
IndentationError. elifmeans "else if". Python checks conditions from top to bottom, runs the first branch whose condition isTrue, and skips the rest. Order matters.else(optional) runs when no condition above it wasTrue.
Boundaries and explicit rules
For every rule, ask: what happens exactly at the edge?
| Business wording | Code |
|---|---|
| "100 USD or more" | total >= 100 |
| "more than 100 USD" | total > 100 |
| "up to 20 units" | stock <= 20 |
If the wording is unclear, ask the person who owns the rule. Don't guess. Then write the rule in a comment above the code. The Zen of Python (PEP 20) puts it this way: "Explicit is better than implicit."
Testing a condition means checking values just below, at and just above each boundary, plus unusual values such as 0.
Money and ==: because decimal numbers are stored approximately (L13), avoid testing calculated money values with ==. For example, 0.1 * 3 == 0.3 is False. Compare with >= / <=, or round first.
5. Worked Example
Rule (fictional Cedar Lane bulk-discount policy): "Orders of 100 or more notebooks get 10% off. Orders of 50 to 99 get 5% off. Smaller orders pay full price."
Step 1: expected answers first. Make a test table before writing code:
| quantity | Expected rate | Why |
|---|---|---|
| 49 | 0.0 | Just below 50 |
| 50 | 0.05 | At the lower boundary |
| 99 | 0.05 | Just below 100 |
| 100 | 0.10 | At the upper boundary |
| 120 | 0.10 | Clearly in the top band |
Step 2: code (correct order: highest threshold first). (Run)
# Bulk discount rule: >= 100 units -> 10%; 50-99 units -> 5%; else 0%
quantity = 120
unit_price = 12.0
if quantity >= 100:
discount_rate = 0.10
elif quantity >= 50:
discount_rate = 0.05
else:
discount_rate = 0.0
subtotal = quantity * unit_price
total = subtotal - subtotal * discount_rate
print(f"Discount rate: {discount_rate}")
print(f"Total: {total} USD")
Discount rate: 0.1
Total: 1296.0 USD
Check by hand: 120 × 12 = 1,440; 10% of 1,440 = 144; 1,440 − 144 = 1,296 ✔.
Step 3: a plausible bug. Someone reorders the checks:
quantity = 120
if quantity >= 50:
discount_rate = 0.05
elif quantity >= 100:
discount_rate = 0.10
else:
discount_rate = 0.0
print(discount_rate)
0.05
120 is "≥ 50", so the first branch runs and the 10% branch is never reached. This version never gives anyone 10%. There is no error message; only the test at quantity = 120 (or 100) catches it.
6. Visual Explanation
quantity
│
┌──────▼───────┐ True
│ >= 100 ? ├──────────► rate = 0.10
└──────┬───────┘
│ False
┌──────▼───────┐ True
│ >= 50 ? ├──────────► rate = 0.05
└──────┬───────┘
│ False
▼
rate = 0.0
Boundaries to test: 49 | 50 ... 99 | 100 ...
Alt text: A decision flowchart. The quantity first goes to the check "greater than or equal to 100?". If true, the rate is 0.10. If false, it goes to the check "greater than or equal to 50?". If true, the rate is 0.05. If false, the rate is 0.0. Below the chart, the boundaries to test are marked at 49, at 50 through 99, and at 100 and above.
7. Guided Practice
(Run.) Stock-alert rule (fictional Cedar Lane): "If stock is 0, show OUT OF STOCK. If stock is 20 or below, show REORDER. Otherwise show OK."
- Expected answers first: complete this table by hand.
| stock | Expected message |
|---|---|
| 0 | |
| 1 | |
| 20 | |
| 21 | |
| 35 |
- Complete this template. Replace each
___; this is a template, not runnable as shown.
```text stock = 0 reorder_level = 20
if stock ___ 0: message = "OUT OF STOCK" elif stock ___ reorder_level: message = ___ else: message = "OK" print(message) ```
- Run it with each value in your table. Record actual vs expected.
- (Hint: order matters.) Swap the
ifandelifconditions and rerun withstock = 0. What changes, and why?
8. Independent Practice
(Run.) Shipping rule (fictional): "Shipping is free for orders of 30 USD or more. Members also get free shipping on orders of 20 USD or more. Otherwise shipping costs 4.99 USD."
- Write the rule as one condition using
and/or(with parentheses), and store the fee inshipping_fee. - Before running, fill in an expected-results table for these cases: - not a member, 29.99; - not a member, 30.00; - member, 20.00; - member, 19.99; - not a member, 20.00.
- Run all five cases and compare.
- Write one sentence explaining which test would catch a
>vs>=mistake.
No model answer is shown here.
9. Knowledge Check — Code-Writing Task + Output Prediction
Part A — Predict the output, then run to check.
A1.
print(7 // 2, 7 % 2)
- A)
3.5 1 - B)
3 1 - C)
3 0 - D)
4 1
A2.
print(2 + 3 * 4)
- A)
20 - B)
24 - C)
14 - D)
9
A3.
stock = 20
print(stock <= 20)
- A)
True - B)
False - C)
20 - D) An error
A4.
is_member = False
total = 25
print(is_member or total >= 20)
- A)
False - B)
25 - C) An error
- D)
True
A5.
total = 75
if total >= 50:
label = "Silver"
elif total >= 70:
label = "Gold"
else:
label = "Standard"
print(label)
- A)
Gold - B)
Silver - C)
Standard - D)
SilverandGoldon two lines
A6.
print(not (5 > 3 and 2 > 4))
- A)
False - B) An error
- C)
True - D)
None
Part B — Code-writing task (Run). Loyalty points rule (fictional): "Orders under 10 USD earn 0 points. Otherwise, members earn 2 points per whole USD spent and non-members earn 1 point per whole USD." Use int(total) to get the whole-USD part (e.g., int(25.50) gives 25).
- Write the rule with
if/elif/else, using variablesis_member(bool) andtotal(float). - Calculate the expected points by hand and test these cases: - member, 25.50; - non-member, 25.50; - member, 9.99; - non-member, 10.00.
- Add a comment above the code that states the rule in words.
10. AI in Practice
Ask AI to generate edge cases for a condition and test them.
- Write your own expected table first for the worked example's bulk-discount rule (at least the five cases in Section 5).
- Ask an AI assistant (synthetic rule only):
"Here is a business rule and Python code (below). List 8 test cases (quantity values) that check its edges and unusual inputs. For each, give the expected discount rate and explain why the case is useful. Do not change the code. """ (paste the rule in words and the Step 2 code) """
- Run every AI test case through the code yourself and record the actual output.
- Check the AI's expected values against the rule, not against the code. Mark each case: - useful and correct; - useful but wrong expected value; - not useful (e.g., duplicates another case).
- Add any important case the AI missed. (Think: zero, negative, very large, exactly on each boundary.)
Why this can help: AI is quick at brainstorming unusual inputs, and that helps you think beyond the obvious. But AI may state the wrong expected result, so the rule, not the AI, is the judge.
11. AI Verification
- Expected values come from the rule in words, written by you, before you look at the code's output.
- Run each case. Never accept "this test passes" without running it.
- Check boundaries: is every threshold tested just below, at and just above?
- Unusual inputs: what should happen for
0or a negative quantity? If the rule does not say, write the question you would ask the rule owner. Don't invent the policy. - Reject code changes you did not ask for, especially ones that change thresholds or the order of conditions.
- Privacy: use the synthetic rule only. Do not paste real customer lists or confidential pricing.
12. Business Lens
Encode discount eligibility or stock-alert rules. Conditions are where business policy becomes software:
- Write the rule in words first, as a comment, so a non-programmer can check it.
- Ask about ambiguity: "over", "from", "up to" and "between" all need a precise boundary.
- Order from most specific or highest threshold to least, and test that every branch can be reached.
- Keep thresholds in named variables, e.g.,
free_shipping_threshold = 30.0. A policy change then means editing one line. - Business risk: a wrong boundary can cost money (unintended discounts) or customers (missed free shipping), with no error message to warn you.
13. Workplace Task — Checkout Rule
Fictional Cedar Lane checkout policy: 1. Subtotal of 100 USD or more → 10% discount. 2. Otherwise, members with a subtotal of 50 USD or more → 5% discount. 3. Otherwise no discount. 4. Shipping is free if the amount after discount is 30 USD or more; otherwise it costs 4.99 USD. 5. Final amount = amount after discount + shipping.
Tasks:
1. Write the policy as a comment, then as code with variables subtotal (float) and is_member (bool). Print the discount rate, shipping fee and final amount.
2. By hand first, calculate the expected final amount for these cases, then run and compare:
| subtotal | is_member |
|---|---|
| 120.00 | False |
| 60.00 | True |
| 60.00 | False |
| 25.00 | True |
| 100.00 | False |
| 50.00 | True |
- Write a two-sentence note to the store owner listing one part of the policy wording you would ask them to confirm. For example, should the discount be applied before checking free shipping?
14. Mini Challenge
Fictional business: Riverside Bikes service-priority rule: "A bike with a brake problem is URGENT. Otherwise, a bike not serviced for more than 365 days is DUE. Otherwise it is OK."
- Write the code using
brake_issue(bool) anddays_since_service(int). - Create five test cases, including the boundary 365/366 and a bike with both a brake issue and more than 365 days since service. Write the expected result for each before running.
- Explain in one sentence why the brake check must come first.
Submit before feedback. No solution is provided here.
15. Resources
- Required (about 15 min): The Python Tutorial, chapter 4, "More Control Flow Tools", section 4.1 "
ifStatements". Also read section 4.10 "Intermezzo: Coding Style" on indentation and naming. https://docs.python.org/3/tutorial/controlflow.html (Opened and checked 12 Oct 2026.) - Recommended (about 5 min): The Python Tutorial, chapter 3, the numbers section, for
/,//and%. https://docs.python.org/3/tutorial/introduction.html (Opened and checked 12 Oct 2026.) - Deeper (optional): PEP 20 – The Zen of Python. https://peps.python.org/pep-0020/ (Opened and checked 12 Oct 2026.) Find the lines "Explicit is better than implicit." and "Readability counts."
16. Person to Follow / Role Model
Guido van Rossum and the Python community (mapped by D.World as "Guido van Rossum / Python community").
- Verified facts (12 Oct 2026): the official General Python FAQ gives Guido van Rossum's own account of creating Python. He was working at CWI, started during the 1989 Christmas holidays, and posted Python to USENET in February 1991. He is one of the three listed authors of PEP 8, Python's style guide.
- Community: the same FAQ describes the Python Software Foundation as "an independent non-profit organization that holds the copyright on Python versions 2.1 and newer". PEP 20, The Zen of Python, is by Tim Peters.
- Try this: read the "Why was Python created in the first place?" answer in the FAQ (https://docs.python.org/3/faq/general.html). Note one goal or idea that connects to this lesson's focus on readable, explicit rules.
17. Glossary
| Term | Meaning in this lesson |
|---|---|
| Operator | A symbol that performs an operation (+, ==, and) |
Floor division // |
Division that keeps only the whole-number part (for positive numbers) |
Remainder % |
What is left over after division |
| Comparison | An expression such as total >= 100 that gives True or False |
== vs = |
Equality check vs assignment |
| Boolean logic | Combining conditions with and, or, not |
| Condition | An expression checked by if/elif |
| Branch | The indented block that runs when its condition is True |
elif |
"else if": checked only if earlier conditions were False |
| Indentation | Leading spaces that define which lines belong to a branch (use 4) |
| Boundary / edge case | A value exactly at, just below or just above a threshold |
SyntaxError / IndentationError |
Errors raised when code breaks Python's grammar or indentation rules |
18. Reflection
Think of a rule you follow in daily life, such as a store's return policy or a travel discount. Try to write it as if/elif/else. Which words in the rule were ambiguous once you had to choose > or >=?
19. Next Step
So far, your code has handled one order at a time. In L15 — Lists, Dictionaries & Loops, you will store many transactions in a list and use loops to process them. You will calculate total revenue across a whole list, applying conditions like the ones you wrote here.
20. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Output prediction, Part A (A1–A6) | Reads operators, logic and branch order correctly | 5 or more of 6 correct; A5 must be correct (branch order) |
| Code-writing task, Part B (loyalty points) | Encodes a written rule with explicit boundaries and tests | Rubric L14-KCB |
| AI in Practice (edge cases) | Generates, runs and judges edge cases against the rule | Rubric L14-AI |
| Guided and independent practice, workplace task, mini challenge | Writes and boundary-tests business rules | Rubrics L14-GP, L14-IP, L14-WT, L14-MC |
References
- Python Software Foundation. The Python Tutorial, ch. 4 "More Control Flow Tools". https://docs.python.org/3/tutorial/controlflow.html (opened and checked 12 Oct 2026). Supports:
ifstatements; "The keyword 'elif' is short for 'else if'"; "Use 4-space indentation, and no tabs"; lowercase_with_underscores function names. - Python Software Foundation. The Python Tutorial, ch. 3. https://docs.python.org/3/tutorial/introduction.html (opened and checked 12 Oct 2026). Supports:
/returns a float;//floor division;%remainder. - Peters, T. PEP 20 – The Zen of Python. https://peps.python.org/pep-0020/ (opened and checked 12 Oct 2026). Supports: "Explicit is better than implicit."; "Readability counts."
- Python Software Foundation. General Python FAQ. https://docs.python.org/3/faq/general.html (opened and checked 12 Oct 2026). Supports: Guido van Rossum's account (CWI; 1989 Christmas holidays; USENET, February 1991); PSF description.
- van Rossum, G., Warsaw, B., & Coghlan, A. PEP 8. https://peps.python.org/pep-0008/ (opened and checked 12 Oct 2026). Supports: authorship; indentation; naming.
- D.World Curriculum Map v1.0 (L14 row) and Curriculum Bible v1.0. Internal.
L14 — العوامل والشروط
ملف المتعلّم. الإجابات والحلول النموذجية في ملف منفصل خاص بالمدرّس فقط. الإصدار: U04 v1.0 · تاريخ المحتوى: 12 أكتوبر 2026. تقديرات الوقت مبدئية إلى أن تُجرَّب مع المتعلّمين. أمثلة الكود مُختبَرة على Python 3.13 (راجع تقرير الجودة QA الخاص بـ U04).
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | العوامل والشروط |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U04 — أساسيات Python |
| رقم الدرس | L14 |
| المهارات | التحكم في سير البرنامج (control flow)؛ المنطق |
| المستوى | مبتدئ |
| الوقت المتوقع | حوالي ساعة و50 دقيقة (مبدئي) |
| المتطلبات السابقة | L13 (المتغيرات، وint/float/str/bool، وتشغيل سكربت). وL11 في U03 (حالات اختبار الحدود). |
تفصيل الوقت (مبدئي): المفهوم والمثال المحلول 35 دقيقة · التدريب الموجَّه 15 دقيقة · التدريب المستقل 15 دقيقة · اختبار الفهم 15 دقيقة · الذكاء الاصطناعي في التطبيق والتحقق 10 دقائق · مهمة العمل 15 دقيقة · التحدي القصير 5 دقائق.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تستخدم العوامل الحسابية وعوامل المقارنة والعوامل المنطقية، وif/elif/else، لكي تحوّل قرارات أعمال بسيطة إلى كود، وأن تختبرها عند حدودها.
هدف خريطة D.World (بنصّه): Use arithmetic, comparison, boolean logic, and if/elif/else to encode simple decisions.
3. لماذا يهمّك هذا؟
الأعمال تسير وفق قواعد:
- "الطلبات التي قيمتها 100 دولار أو أكثر تحصل على خصم 10%."
- "أعِد الطلب من المورّد عندما ينخفض المخزون إلى 20 أو أقل."
- "الأعضاء يحصلون على شحن مجاني بدءًا من 20 دولارًا."
عندما تحوّل قاعدة إلى كود، فكل كلمة مهمة. "100 أو أكثر" و"أكثر من 100" تعطيان إجابتين مختلفتين لطلب قيمته 100 بالضبط. وإذا وضعت الفحوصات بترتيب خاطئ، فسيحصل بعض العملاء على خصم خاطئ دون أن يلاحظ أحد. ولا أحد من الخطأين يوقف البرنامج. المبدأ الأساسي: يجب أن تعبّر الشروط عن قواعد الأعمال بشكل صريح.
4. المفهوم
العوامل الحسابية
| العامل | المعنى | مثال | النتيجة |
|---|---|---|---|
+ - * |
جمع، طرح، ضرب | 12 * 3 |
36 |
/ |
قسمة (تعطي دائمًا float) |
7 / 2 |
3.5 |
// |
القسمة الصحيحة (floor division: الجزء الصحيح من الناتج، للأعداد الموجبة) | 7 // 2 |
3 |
% |
باقي القسمة | 7 % 2 |
1 |
** |
الأُس (القوة) | 2 ** 3 |
8 |
الترتيب: * و/ و// و% تُنفَّذ قبل + و-، كما في الحساب العادي. استخدم الأقواس لتوضّح ما تقصده: (price - discount) * quantity.
عوامل المقارنة: تعطي True أو False
| العامل | المعنى | مثال | النتيجة |
|---|---|---|---|
== |
يساوي | stock == 0 |
True إذا كان المخزون 0 |
!= |
لا يساوي | status != "paid" |
|
< > |
أصغر من / أكبر من | total > 100 |
|
<= >= |
أصغر من أو يساوي / أكبر من أو يساوي | total >= 100 |
الفرق بين = و==:
=تُسنِد قيمة (L13).==تسأل هل القيمتان متساويتان.
كتابة if quantity = 100: خطأ. يتوقف Python ويُظهر SyntaxError؛ وفي Python 3.13 تقترح الرسالة نفسها استخدام '=='.
المنطق البولياني (Boolean logic): and وor وnot
| التعبير | يكون True عندما… |
|---|---|
a and b |
يكون الاثنان True |
a or b |
يكون واحد على الأقل True |
not a |
يكون a هو False |
مثال: is_member and total >= 20 تكون True فقط للأعضاء الذين وصلت قيمة طلبهم إلى 20 دولارًا على الأقل.
عندما تخلط and مع or، استخدم الأقواس لتُظهر أي الشروط ترتبط ببعضها.
if / elif / else
stock = 12
reorder_level = 20
if stock <= reorder_level:
print("Reorder")
else:
print("Stock OK")
Reorder
- السطر الذي يحتوي على
ifوelifوelseينتهي بنقطتين:. - الكود الذي ينتمي إلى الفرع يكون مُزاحًا إلى الداخل (indented)؛ ويوصي كلٌّ من PEP 8 والدليل التعليمي بـ 4 مسافات. الإزاحة في Python ليست للزينة: هي التي تحدّد أي الأسطر تنتمي إلى الفرع. ونسيان الإزاحة يعطي
IndentationError. elifتعني "else if" (وإلا فإذا). يفحص Python الشروط من أعلى إلى أسفل، وينفّذ أول فرع يكون شرطهTrue، ويتخطّى الباقي. الترتيب مهم.else(اختيارية) تُنفَّذ عندما لا يكون أي شرط فوقهاTrue.
الحدود والقواعد الصريحة
مع كل قاعدة، اسأل: ماذا يحدث بالضبط عند الحد؟
| صياغة الأعمال | الكود |
|---|---|
| "100 دولار أو أكثر" | total >= 100 |
| "أكثر من 100 دولار" | total > 100 |
| "حتى 20 وحدة" | stock <= 20 |
إذا كانت الصياغة غير واضحة، اسأل صاحب القاعدة. لا تخمّن. ثم اكتب القاعدة في تعليق فوق الكود. ويعبّر The Zen of Python (PEP 20) عن ذلك هكذا: "Explicit is better than implicit." (الصريح أفضل من الضمني).
اختبار الشرط يعني فحص قيم أقل من كل حد بقليل، وعنده بالضبط، وأعلى منه بقليل، بالإضافة إلى القيم غير المعتادة مثل 0.
المبالغ المالية و==: لأن الأعداد العشرية تُخزَّن بشكل تقريبي (L13)، تجنّب اختبار المبالغ المالية المحسوبة باستخدام ==. مثلًا، 0.1 * 3 == 0.3 تعطي False. قارن باستخدام >= / <=، أو قرّب الرقم أولًا.
5. مثال محلول
القاعدة (سياسة خصم الكميات في متجر Cedar Lane الخيالي): "الطلبات التي فيها 100 كشكول أو أكثر تحصل على خصم 10%. والطلبات من 50 إلى 99 تحصل على خصم 5%. والطلبات الأصغر تدفع السعر كاملًا."
الخطوة 1: الإجابات المتوقعة أولًا. اصنع جدول اختبار قبل أن تكتب الكود:
| quantity | نسبة الخصم المتوقعة | السبب |
|---|---|---|
| 49 | 0.0 | أقل من 50 بقليل |
| 50 | 0.05 | عند الحد الأدنى |
| 99 | 0.05 | أقل من 100 بقليل |
| 100 | 0.10 | عند الحد الأعلى |
| 120 | 0.10 | داخل الشريحة العليا بوضوح |
الخطوة 2: الكود (الترتيب الصحيح: الحد الأعلى أولًا). (Run)
# Bulk discount rule: >= 100 units -> 10%; 50-99 units -> 5%; else 0%
quantity = 120
unit_price = 12.0
if quantity >= 100:
discount_rate = 0.10
elif quantity >= 50:
discount_rate = 0.05
else:
discount_rate = 0.0
subtotal = quantity * unit_price
total = subtotal - subtotal * discount_rate
print(f"Discount rate: {discount_rate}")
print(f"Total: {total} USD")
Discount rate: 0.1
Total: 1296.0 USD
تحقّق يدويًا: 120 × 12 = 1,440؛ و10% من 1,440 = 144؛ و1,440 − 144 = 1,296 ✔.
الخطوة 3: خطأ وارد الحدوث. شخص ما يغيّر ترتيب الفحوصات:
quantity = 120
if quantity >= 50:
discount_rate = 0.05
elif quantity >= 100:
discount_rate = 0.10
else:
discount_rate = 0.0
print(discount_rate)
0.05
العدد 120 "≥ 50"، لذلك يُنفَّذ الفرع الأول، ولا يُوصَل أبدًا إلى فرع الـ 10%. هذه النسخة لن تعطي أحدًا خصم 10% أبدًا. ولا تظهر أي رسالة خطأ؛ فقط الاختبار عند quantity = 120 (أو 100) يكشف المشكلة.
6. شرح بصري
quantity
│
┌──────▼───────┐ True
│ >= 100 ? ├──────────► rate = 0.10
└──────┬───────┘
│ False
┌──────▼───────┐ True
│ >= 50 ? ├──────────► rate = 0.05
└──────┬───────┘
│ False
▼
rate = 0.0
Boundaries to test: 49 | 50 ... 99 | 100 ...
وصف الرسم: مخطط قرار. تذهب الكمية أولًا إلى الفحص "أكبر من أو يساوي 100؟". إذا كانت الإجابة نعم، تكون النسبة 0.10. وإذا كانت لا، تذهب إلى الفحص "أكبر من أو يساوي 50؟". إذا كانت نعم، تكون النسبة 0.05. وإذا كانت لا، تكون النسبة 0.0. وتحت المخطط عُلِّمت الحدود التي يجب اختبارها: عند 49، ومن 50 إلى 99، وعند 100 وما فوقها.
7. تدريب موجَّه
(Run.) قاعدة تنبيه المخزون (متجر Cedar Lane الخيالي): "إذا كان المخزون 0، اعرض OUT OF STOCK. وإذا كان المخزون 20 أو أقل، اعرض REORDER. وفي غير ذلك اعرض OK."
- الإجابات المتوقعة أولًا: أكمل هذا الجدول يدويًا.
| stock | الرسالة المتوقعة |
|---|---|
| 0 | |
| 1 | |
| 20 | |
| 21 | |
| 35 |
- أكمل هذا القالب. استبدل كل
___؛ هذا قالب، ولا يمكن تشغيله كما هو.
stock = 0
reorder_level = 20
if stock ___ 0:
message = "OUT OF STOCK"
elif stock ___ reorder_level:
message = ___
else:
message = "OK"
print(message)
- شغّله بكل قيمة في جدولك. وسجّل النتيجة الفعلية مقابل المتوقعة.
- (تلميح: الترتيب مهم.) بدّل شرطَي
ifوelif، وأعِد التشغيل بـstock = 0. ماذا تغيّر، ولماذا؟
8. تدريب مستقل
(Run.) قاعدة الشحن (خيالية): "الشحن مجاني للطلبات التي قيمتها 30 دولارًا أو أكثر. والأعضاء يحصلون أيضًا على شحن مجاني للطلبات التي قيمتها 20 دولارًا أو أكثر. وفي غير ذلك تكون تكلفة الشحن 4.99 دولار."
- اكتب القاعدة في شرط واحد باستخدام
and/or(مع الأقواس)، وخزّن رسوم الشحن فيshipping_fee. - قبل التشغيل، املأ جدول نتائج متوقعة لهذه الحالات:
- ليس عضوًا، 29.99؛
- ليس عضوًا، 30.00؛
- عضو، 20.00؛
- عضو، 19.99؛
- ليس عضوًا، 20.00.
- شغّل الحالات الخمس كلها وقارن.
- اكتب جملة واحدة تشرح أي اختبار سيكشف خطأ استخدام
>بدلًا من>=.
لا تُعرض هنا إجابة نموذجية.
9. اختبار الفهم — مهمة كتابة كود + توقّع المخرجات
الجزء A — توقّع المخرجات، ثم شغّل الكود لتتأكد.
A1.
print(7 // 2, 7 % 2)
- A)
3.5 1 - B)
3 1 - C)
3 0 - D)
4 1
A2.
print(2 + 3 * 4)
- A)
20 - B)
24 - C)
14 - D)
9
A3.
stock = 20
print(stock <= 20)
- A)
True - B)
False - C)
20 - D) خطأ
A4.
is_member = False
total = 25
print(is_member or total >= 20)
- A)
False - B)
25 - C) خطأ
- D)
True
A5.
total = 75
if total >= 50:
label = "Silver"
elif total >= 70:
label = "Gold"
else:
label = "Standard"
print(label)
- A)
Gold - B)
Silver - C)
Standard - D)
SilverوGoldفي سطرين
A6.
print(not (5 > 3 and 2 > 4))
- A)
False - B) خطأ
- C)
True - D)
None
الجزء B — مهمة كتابة كود (Run). قاعدة نقاط الولاء (خيالية): "الطلبات الأقل من 10 دولارات تكسب 0 نقاط. وفي غير ذلك، يكسب الأعضاء نقطتين عن كل دولار كامل يُنفَق، ويكسب غير الأعضاء نقطة واحدة عن كل دولار كامل." استخدم int(total) للحصول على عدد الدولارات الكاملة (مثلًا، int(25.50) تعطي 25).
- اكتب القاعدة باستخدام
if/elif/else، مع المتغيرينis_member(bool) وtotal(float). - احسب النقاط المتوقعة يدويًا واختبر هذه الحالات:
- عضو، 25.50؛
- ليس عضوًا، 25.50؛
- عضو، 9.99؛
- ليس عضوًا، 10.00.
- أضف تعليقًا فوق الكود يذكر القاعدة بالكلمات.
10. الذكاء الاصطناعي في التطبيق
اطلب من الذكاء الاصطناعي أن يولّد حالات طرفية (edge cases) لشرط ما، ثم اختبرها.
- اكتب جدولك المتوقع أولًا لقاعدة خصم الكميات في المثال المحلول (على الأقل الحالات الخمس في القسم 5).
- اسأل مساعد ذكاء اصطناعي (قاعدة مصطنعة فقط):
"Here is a business rule and Python code (below). List 8 test cases (quantity values) that check its edges and unusual inputs. For each, give the expected discount rate and explain why the case is useful. Do not change the code. """ (paste the rule in words and the Step 2 code) """
وبالعربية: "إليك قاعدة أعمال وكود Python (بالأسفل). اذكر 8 حالات اختبار (قيم للكمية) تفحص حدودها والمدخلات غير المعتادة. ولكل حالة، اذكر نسبة الخصم المتوقعة، واشرح لماذا هذه الحالة مفيدة. لا تغيّر الكود. """ (الصق القاعدة بالكلمات وكود الخطوة 2) """"
- شغّل كل حالة اختبار اقترحها الذكاء الاصطناعي على الكود بنفسك، وسجّل المخرجات الفعلية.
- قارن القيم المتوقعة التي ذكرها الذكاء الاصطناعي بالقاعدة، وليس بالكود. وضع على كل حالة علامة:
- مفيدة وصحيحة؛
- مفيدة لكن القيمة المتوقعة خاطئة؛
- غير مفيدة (مثلًا، تكرار لحالة أخرى).
- أضف أي حالة مهمة فاتت الذكاء الاصطناعي. (فكّر في: الصفر، والقيم السالبة، والقيم الكبيرة جدًا، والقيمة الواقعة على كل حد بالضبط.)
لماذا قد يفيدك هذا: الذكاء الاصطناعي سريع في اقتراح مدخلات غير معتادة، وهذا يساعدك على التفكير أبعد من الحالات الواضحة. لكنه قد يذكر نتيجة متوقعة خاطئة، ولذلك فالحَكَم هو القاعدة، وليس الذكاء الاصطناعي.
11. التحقق من مخرجات الذكاء الاصطناعي
- القيم المتوقعة تأتي من القاعدة المكتوبة بالكلمات، وتكتبها أنت، قبل أن تنظر إلى مخرجات الكود.
- شغّل كل حالة. لا تقبل أبدًا عبارة "هذا الاختبار ينجح" دون أن تشغّله.
- افحص الحدود: هل اختُبر كل حد عند قيمة أقل منه بقليل، وعنده، وأعلى منه بقليل؟
- المدخلات غير المعتادة: ماذا يجب أن يحدث عند
0أو كمية سالبة؟ إذا لم تذكر القاعدة ذلك، فاكتب السؤال الذي ستسأله لصاحب القاعدة. لا تخترع السياسة. - ارفض تغييرات الكود التي لم تطلبها، خاصة تلك التي تغيّر الحدود أو ترتيب الشروط.
- الخصوصية: استخدم القاعدة المصطنعة فقط. لا تلصق قوائم عملاء حقيقية أو أسعارًا سرية.
12. منظور الأعمال
حوّل قواعد استحقاق الخصم أو تنبيه المخزون إلى كود. الشروط هي المكان الذي تتحول فيه سياسة الأعمال إلى برنامج:
- اكتب القاعدة بالكلمات أولًا، في تعليق، حتى يستطيع شخص غير مبرمج أن يراجعها.
- اسأل عن الغموض: كلمات مثل "فوق" و"من" و"حتى" و"بين" كلها تحتاج إلى حد دقيق.
- رتّب من الأكثر تحديدًا أو الحد الأعلى إلى الأقل، واختبر أن كل فرع يمكن الوصول إليه.
- احتفظ بالحدود في متغيرات لها أسماء، مثل
free_shipping_threshold = 30.0. وعندها يعني تغيير السياسة تعديل سطر واحد. - مخاطر الأعمال: الحد الخاطئ قد يكلّف مالًا (خصومات غير مقصودة) أو عملاء (شحن مجاني لم يحصلوا عليه)، دون أي رسالة خطأ تنبّهك.
13. مهمة عمل — قاعدة الدفع عند الشراء
سياسة الدفع في متجر Cedar Lane الخيالي:
- المجموع الفرعي (subtotal) 100 دولار أو أكثر ← خصم 10%.
- وإلا، الأعضاء الذين يبلغ مجموعهم الفرعي 50 دولارًا أو أكثر ← خصم 5%.
- وإلا فلا خصم.
- الشحن مجاني إذا كان المبلغ بعد الخصم 30 دولارًا أو أكثر؛ وإلا فتكلفته 4.99 دولار.
- المبلغ النهائي = المبلغ بعد الخصم + الشحن.
المهام:
- اكتب السياسة في تعليق، ثم في كود باستخدام المتغيرين
subtotal(float) وis_member(bool). اطبع نسبة الخصم، ورسوم الشحن، والمبلغ النهائي. - يدويًا أولًا، احسب المبلغ النهائي المتوقع لهذه الحالات، ثم شغّل وقارن:
| subtotal | is_member |
|---|---|
| 120.00 | False |
| 60.00 | True |
| 60.00 | False |
| 25.00 | True |
| 100.00 | False |
| 50.00 | True |
- اكتب ملاحظة من جملتين لصاحب المتجر تذكر فيها جزءًا واحدًا من صياغة السياسة تريد أن يؤكده لك. مثلًا: هل يُطبَّق الخصم قبل فحص الشحن المجاني؟
14. تحدٍّ قصير
نشاط تجاري خيالي: قاعدة أولوية الصيانة في Riverside Bikes: "الدراجة التي بها مشكلة في الفرامل حالتها URGENT (عاجلة). وإلا، فالدراجة التي لم تُصَن منذ أكثر من 365 يومًا حالتها DUE (مستحقة). وفي غير ذلك حالتها OK."
- اكتب الكود باستخدام
brake_issue(bool) وdays_since_service(int). - أنشئ خمس حالات اختبار، منها الحد 365/366، ودراجة بها الأمران معًا: مشكلة في الفرامل وأكثر من 365 يومًا منذ آخر صيانة. واكتب النتيجة المتوقعة لكل حالة قبل التشغيل.
- اشرح في جملة واحدة لماذا يجب أن يأتي فحص الفرامل أولًا.
سلّم إجابتك قبل الحصول على التعليقات. لا يوجد حل هنا.
15. المصادر
- مطلوب (حوالي 15 دقيقة): The Python Tutorial، الفصل 4، "More Control Flow Tools"، القسم 4.1 "
ifStatements". واقرأ أيضًا القسم 4.10 "Intermezzo: Coding Style" عن الإزاحة والتسمية. https://docs.python.org/3/tutorial/controlflow.html (فُتح وروجع في 12 أكتوبر 2026.) - موصى به (حوالي 5 دقائق): The Python Tutorial، الفصل 3، الجزء الخاص بالأرقام، لفهم
/و//و%. https://docs.python.org/3/tutorial/introduction.html (فُتح وروجع في 12 أكتوبر 2026.) - للتعمّق (اختياري): PEP 20 – The Zen of Python. https://peps.python.org/pep-0020/ (فُتح وروجع في 12 أكتوبر 2026.) ابحث عن السطرين "Explicit is better than implicit." و"Readability counts." (قابلية القراءة مهمة).
16. شخصية تتابعها / قدوة
Guido van Rossum ومجتمع Python (اختارتهم D.World تحت اسم "Guido van Rossum / Python community").
- حقائق موثّقة (12 أكتوبر 2026): صفحة General Python FAQ الرسمية تعرض رواية Guido van Rossum نفسه عن إنشاء Python. كان يعمل في CWI، وبدأ خلال عطلة عيد الميلاد عام 1989، ونشر Python على USENET في فبراير 1991. وهو واحد من المؤلفين الثلاثة المذكورين لـ PEP 8، دليل أسلوب كتابة كود Python.
- المجتمع: الصفحة نفسها تصف Python Software Foundation بأنها "an independent non-profit organization that holds the copyright on Python versions 2.1 and newer" (منظمة مستقلة غير ربحية تملك حقوق النشر لإصدارات Python من 2.1 فما بعد). أما PEP 20، The Zen of Python، فكاتبه Tim Peters.
- جرّب هذا: اقرأ إجابة "Why was Python created in the first place?" في صفحة الأسئلة الشائعة (https://docs.python.org/3/faq/general.html). ودوّن هدفًا أو فكرة واحدة ترتبط بتركيز هذا الدرس على القواعد المقروءة والصريحة.
17. المصطلحات
| المصطلح | معناه في هذا الدرس |
|---|---|
| العامل (Operator) | رمز ينفّذ عملية (+، ==، and) |
القسمة الصحيحة (Floor division) // |
قسمة تحتفظ بالجزء الصحيح فقط (للأعداد الموجبة) |
باقي القسمة (Remainder) % |
ما يتبقى بعد القسمة |
| المقارنة (Comparison) | تعبير مثل total >= 100 يعطي True أو False |
== مقابل = |
فحص التساوي مقابل الإسناد |
| المنطق البولياني (Boolean logic) | دمج الشروط باستخدام and وor وnot |
| الشرط (Condition) | تعبير تفحصه if/elif |
| الفرع (Branch) | الكتلة المُزاحة التي تُنفَّذ عندما يكون شرطها True |
elif |
"else if": تُفحص فقط إذا كانت الشروط السابقة False |
| الإزاحة (Indentation) | مسافات في بداية السطر تحدّد أي الأسطر تنتمي إلى الفرع (استخدم 4) |
| الحد / الحالة الطرفية (Boundary / edge case) | قيمة عند حد معيّن بالضبط، أو أقل منه بقليل، أو أعلى منه بقليل |
SyntaxError / IndentationError |
أخطاء تظهر عندما يخالف الكود قواعد لغة Python أو قواعد الإزاحة |
18. تأمّل
فكّر في قاعدة تتبعها في حياتك اليومية، مثل سياسة الإرجاع في متجر أو خصم على السفر. حاول أن تكتبها باستخدام if/elif/else. أي كلمات في القاعدة ظهر غموضها عندما اضطررت إلى الاختيار بين > و>=؟
19. الخطوة التالية
حتى الآن، تعامل كودك مع طلب واحد في كل مرة. في L15 — القوائم والقواميس والحلقات التكرارية، ستخزّن معاملات كثيرة في قائمة (list) وتستخدم الحلقات التكرارية (loops) لمعالجتها. وستحسب إجمالي الإيرادات لقائمة كاملة، مع تطبيق شروط مثل التي كتبتها هنا.
20. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| توقّع المخرجات، الجزء A (A1–A6) | قراءة العوامل والمنطق وترتيب الفروع بشكل صحيح | 5 إجابات صحيحة أو أكثر من 6؛ ويجب أن تكون A5 صحيحة (ترتيب الفروع) |
| مهمة كتابة الكود، الجزء B (نقاط الولاء) | تحويل قاعدة مكتوبة إلى كود بحدود صريحة واختبارات | معايير L14-KCB |
| الذكاء الاصطناعي في التطبيق (الحالات الطرفية) | توليد الحالات الطرفية وتشغيلها والحكم عليها وفق القاعدة | معايير L14-AI |
| التدريب الموجَّه والمستقل، ومهمة العمل، والتحدي القصير | كتابة قواعد الأعمال واختبار حدودها | معايير L14-GP وL14-IP وL14-WT وL14-MC |
المراجع
- Python Software Foundation. The Python Tutorial، الفصل 4 "More Control Flow Tools". https://docs.python.org/3/tutorial/controlflow.html (فُتح وروجع في 12 أكتوبر 2026). يدعم: جمل
if؛ و"The keyword 'elif' is short for 'else if'"؛ و"Use 4-space indentation, and no tabs"؛ وأسماء الدوال بنمط lowercase_with_underscores. - Python Software Foundation. The Python Tutorial، الفصل 3. https://docs.python.org/3/tutorial/introduction.html (فُتح وروجع في 12 أكتوبر 2026). يدعم: أن
/تعطي float؛ والقسمة الصحيحة//؛ وباقي القسمة%. - Peters, T. PEP 20 – The Zen of Python. https://peps.python.org/pep-0020/ (فُتح وروجع في 12 أكتوبر 2026). يدعم: "Explicit is better than implicit."؛ و"Readability counts."
- Python Software Foundation. General Python FAQ. https://docs.python.org/3/faq/general.html (فُتحت وروجعت في 12 أكتوبر 2026). يدعم: رواية Guido van Rossum (CWI؛ عطلة عيد الميلاد 1989؛ USENET، فبراير 1991)؛ ووصف PSF.
- van Rossum, G., Warsaw, B., & Coghlan, A. PEP 8. https://peps.python.org/pep-0008/ (فُتح وروجع في 12 أكتوبر 2026). يدعم: المؤلفين؛ والإزاحة؛ والتسمية.
- D.World Curriculum Map v1.0 (صف L14) وCurriculum Bible v1.0. وثائق داخلية.
L15 · Lists, Dictionaries & LoopsL15 · القوائم والقواميس والحلقات التكرارية Freeمجاني
L15 — Lists, Dictionaries & Loops
Learner file. Answers and model solutions are in a separate instructor-only file. Version: U04 v1.0 · Content date: 12 October 2026. Time estimates are provisional until learner-tested. Code examples were tested with Python 3.13 (see the U04 QA report).
1. Lesson Identity
| Field | Value |
|---|---|
| Title | Lists, Dictionaries & Loops |
| Stage | Stage 1 — Foundations |
| Unit | U04 — Python Fundamentals |
| Lesson ID | L15 |
| Skills | Data structures; iteration |
| Difficulty | Beginner |
| Estimated time | About 2 hours (provisional) |
| Prerequisites | L13 (variables, types) and L14 (comparisons, if). U03 L11 (the Cedar Lane order lines; AOV = paid revenue ÷ distinct paid orders). |
Time breakdown (provisional): concept and worked example, 40 min · guided practice, 15 min · independent practice, 15 min · knowledge check and debugging, 15 min · AI in Practice and Verification, 10 min · workplace task, 20 min · mini challenge, 5 min.
2. Learning Objective
By the end of this lesson, you will be able to use lists, dictionaries and for loops to process a simple collection of business records. That means totals, counts and per-product summaries, checked against hand calculations.
D.World map objective (verbatim): Use basic data structures and loops to process simple collections.
3. Why It Matters
Real data rarely comes one value at a time. A store has a list of transactions, a price list and stock levels for many products. Writing one variable per value does not scale.
Collections hold many values together, and loops repeat the same steps for each one. Together they turn your one-order calculation from L13–L14 into one that works for a whole day's orders.
Choosing the right structure makes code shorter and easier to check: - a list when order matters; - a dictionary when you look things up by name.
Key principle: choose a structure that matches the problem.
4. Concept
Lists: ordered collections
prices = [12.0, 8.0, 20.0]
print(prices[0])
print(prices[-1])
print(len(prices))
prices.append(5.5)
print(prices)
12.0
20.0
3
[12.0, 8.0, 20.0, 5.5]
- Items are inside
[ ], separated by commas. - Positions (indexes) start at 0.
prices[0]is the first item;prices[-1]is the last. len(...)gives the number of items..append(x)addsxto the end.- Asking for a position that does not exist (e.g.,
prices[10]) raises anIndexError.
Dictionaries: look-up by key
unit_prices = {"Notebook": 12.0, "Pen set": 8.0, "Planner": 20.0}
print(unit_prices["Planner"])
unit_prices["Planner"] = 18.0 # change a value
unit_prices["Bookmark"] = 2.5 # add a new key
print(unit_prices)
print(unit_prices.get("Stapler", 0.0))
print("Notebook" in unit_prices)
20.0
{'Notebook': 12.0, 'Pen set': 8.0, 'Planner': 18.0, 'Bookmark': 2.5}
0.0
True
- A dictionary is a set of key: value pairs, and keys are unique within one dictionary (Python Tutorial, 5.5).
d[key]gets a value. If the key does not exist, Python raises aKeyError.d.get(key, default)returns the default instead of raising an error. Use it only when a default makes business sense, such as "0 units sold".key in dchecks whether a key exists (True/False).
Lists of dictionaries: records
A common way to hold transactions is a list of dictionaries, one dictionary per line:
transactions = [ {"order_id": 1001, "product": "Notebook", "qty": 2, ...},
{"order_id": 1001, "product": "Pen set", "qty": 1, ...}, ... ]
for loops
quantities = [2, 1, 1, 4]
total_units = 0
for qty in quantities:
total_units = total_units + qty
print(total_units)
8
for qty in quantities:runs the indented block once per item, withqtyset to each item in turn.- Accumulator pattern: create the total before the loop (
total_units = 0), then update it inside the loop. - Looping over a dictionary:
for product, price in unit_prices.items():gives each key and value. range(start, stop)produces numbers fromstartup to, but not including,stop. The Tutorial says: "The given end point is never part of the generated sequence." Sorange(1, 4)gives 1, 2, 3. You rarely needrangeto loop over a list:for item in my_listis simpler, and it avoids skipping or repeating items by mistake.
Lists and dictionaries can change in place
Lists and dictionaries are mutable: you can change them after creating them. One consequence:
orders = [1001, 1002]
same_orders = orders # NOT a copy: two names for one list
same_orders.append(1003)
print(orders)
backup = orders.copy() # a real copy
backup.append(1004)
print(orders)
[1001, 1002, 1003]
[1001, 1002, 1003]
Which structure?
| Problem | Good structure | Why |
|---|---|---|
| Sequence of values in order (daily sales) | List | Order and position matter |
| Look up a value by name (price of "Planner") | Dictionary | Direct look-up by key |
| Many records with several fields (transactions) | List of dictionaries | Each record has named fields; the list keeps them together |
| Totals per category (revenue per product) | Dictionary built in a loop | One key per category, value = running total |
5. Worked Example
Task: total paid revenue from Cedar Lane's order lines (synthetic, the same week as U03 L11).
Step 1: expected answer first. In U03 L11 you calculated paid revenue = 124 by hand (the refunded Planner is excluded).
Step 2: code. (Run)
transactions = [
{"order_id": 1001, "product": "Notebook", "qty": 2, "price": 12.0, "status": "paid"},
{"order_id": 1001, "product": "Pen set", "qty": 1, "price": 8.0, "status": "paid"},
{"order_id": 1002, "product": "Notebook", "qty": 1, "price": 12.0, "status": "paid"},
{"order_id": 1003, "product": "Planner", "qty": 1, "price": 20.0, "status": "refunded"},
{"order_id": 1004, "product": "Notebook", "qty": 1, "price": 12.0, "status": "paid"},
{"order_id": 1005, "product": "Notebook", "qty": 4, "price": 12.0, "status": "paid"},
{"order_id": 1005, "product": "Planner", "qty": 1, "price": 20.0, "status": "paid"},
]
paid_revenue = 0.0
for line in transactions:
if line["status"] == "paid":
paid_revenue = paid_revenue + line["qty"] * line["price"]
print(f"Paid revenue: {paid_revenue} USD")
Paid revenue: 124.0 USD
Step 3: trace. Check the running total after each line:
| Line | status | Added | paid_revenue after |
|---|---|---|---|
| 1001 Notebook | paid | 2 × 12 = 24 | 24.0 |
| 1001 Pen set | paid | 8 | 32.0 |
| 1002 Notebook | paid | 12 | 44.0 |
| 1003 Planner | refunded | 0 (skipped) | 44.0 |
| 1004 Notebook | paid | 12 | 56.0 |
| 1005 Notebook | paid | 48 | 104.0 |
| 1005 Planner | paid | 20 | 124.0 ✔ |
(The transaction lines are longer than PEP 8's 79-character guideline, kept on one line so each record is easy to read.)
6. Visual Explanation
transactions (list) ──► [ {line 1}, {line 2}, {line 3}, ... {line 7} ]
│
for line in transactions: ← takes each dictionary in turn
│
line["status"] == "paid" ?
│ yes │ no
paid_revenue += qty * price skip
│
after the loop: paid_revenue = 124.0
Alt text: A list called transactions holds seven dictionaries, one per order line. A for loop takes each dictionary in turn. For each one, it checks whether the status equals "paid". If yes, quantity times price is added to paid_revenue; if no, the line is skipped. After the loop, paid_revenue equals 124.0.
7. Guided Practice
(Run.) Using the worked-example transactions, calculate units sold per product (paid lines only) as a dictionary.
- Expected answer first: count the paid units per product by hand.
- Complete this template (not runnable as shown):
text
units = {}
for line in transactions:
if line["status"] == ___:
product = line["product"]
units[product] = units.get(product, ___) + line[___]
print(units)
- Run it and compare with your hand count.
- Explain in one sentence why
units.get(product, 0)is used instead ofunits[product]the first time a product appears. (Hint: what would happen with an empty dictionary?)
8. Independent Practice
(Run.) Using the same transactions:
- Build a dictionary
revenue_by_productof paid revenue per product. - Using a loop over
revenue_by_product.items()and anif, find the product with the highest paid revenue. Store its name and value in two variables and print them. - In a separate loop, calculate the total value of refunded lines.
- Check all results by hand and record matches.
No model answer is shown here.
9. Knowledge Check — Hands-on Task + Debugging
Part A — Predict the output, then run to check.
A1.
prices = [12.0, 8.0, 20.0]
print(prices[1])
- A)
12.0 - B)
8.0 - C)
20.0 - D) An
IndexError
A2.
prices = [12.0, 8.0, 20.0]
print(len(prices), prices[-1])
- A)
3 20.0 - B)
2 20.0 - C)
3 12.0 - D) An error
A3.
stock = {"Notebook": 40, "Planner": 5}
stock["Planner"] = stock["Planner"] - 2
print(stock)
- A)
{'Notebook': 40, 'Planner': 5} - B)
{'Notebook': 38, 'Planner': 5} - C) An error, because dictionaries cannot change
- D)
{'Notebook': 40, 'Planner': 3}
A4.
stock = {"Notebook": 40, "Planner": 5}
print(stock.get("Pen set", 0))
- A)
0 - B)
None - C) A
KeyError - D)
Pen set
A5.
total = 0
for n in range(1, 4):
total = total + n
print(total)
- A)
10 - B)
4 - C)
6 - D)
3
A6.
a = [1, 2]
b = a
b.append(3)
print(a)
- A)
[1, 2] - B)
[1, 2, 3] - C)
[3] - D) An error
Part B — Debugging (Run). Each program below is meant to print the total paid revenue of the worked-example transactions (expected 124.0). Paste the transactions list above each program before running it. For each: (1) predict and then run to find the actual output; (2) explain the cause in one sentence; (3) fix it with the smallest change; (4) rerun and confirm 124.0.
B1.
paid_revenue = 0.0
for line in transactions:
paid_revenue = 0.0
if line["status"] == "paid":
paid_revenue = paid_revenue + line["qty"] * line["price"]
print(paid_revenue)
B2.
paid_revenue = 0.0
for i in range(1, len(transactions)):
line = transactions[i]
if line["status"] == "paid":
paid_revenue = paid_revenue + line["qty"] * line["price"]
print(paid_revenue)
10. AI in Practice
Ask AI to explain iteration choices and create test cases for a loop.
- Ask an AI assistant (synthetic code only):
"I'm a Python beginner. Here is a loop that totals paid revenue from a list of dictionaries (below). (1) Explain the difference between
for line in transactions:andfor i in range(len(transactions)):, and when each is appropriate. (2) Suggest 5 small test lists (each with 0–3 lines) that check this loop, including edge cases, with the expected total for each. Do not rewrite the loop. """ (paste the worked-example loop and two sample lines) """
- Read the explanation and compare it with Section 4. Mark anything that is unclear or contradicts the lesson.
- Run every test list yourself. Set
transactions = [...]to each test list and run the loop. Record expected (from the AI), expected (from your hand calculation) and actual. - Make sure the tests include at least these: - an empty list; - a list where all lines are refunded; - a single paid line; - a line with qty 0.
Add any that are missing.
11. AI Verification
- Your hand calculation is the reference. If the AI's expected total differs from yours, recompute; if you are right, record the AI's value as wrong.
- Run, don't assume: every test list must actually be run.
- Check the explanation against the Tutorial: for example, the claim that
range's end point is excluded. - Watch for advanced code you did not ask for (e.g., comprehensions, external libraries). Ask for a beginner version, or reject it.
- Edge cases: an empty list should give
0.0, not an error. If any test crashes, note which line and why. - Privacy: use synthetic toy lists only. Never paste real transaction exports.
12. Business Lens
Calculate total revenue from a list of transactions. This is one of the most common data tasks, and the business definitions you learned in U02–U03 still apply inside a loop:
- Filter correctly: paid vs refunded, the right period, the right product.
- Count the right thing: revenue per line is
qty × price; orders need distinctorder_ids (U03 L11). - Summaries per category (revenue by product) support decisions on stock, promotion and pricing.
- Check totals by hand on a small sample before trusting a loop on thousands of lines.
13. Workplace Task — Daily Sales Summary
Synthetic data, fictional Cedar Lane, one day:
day = [
{"order_id": 2001, "product": "Notebook", "qty": 3, "price": 12.0, "status": "paid"},
{"order_id": 2001, "product": "Planner", "qty": 1, "price": 20.0, "status": "paid"},
{"order_id": 2002, "product": "Pen set", "qty": 2, "price": 8.0, "status": "paid"},
{"order_id": 2003, "product": "Notebook", "qty": 1, "price": 12.0, "status": "refunded"},
{"order_id": 2004, "product": "Planner", "qty": 2, "price": 20.0, "status": "paid"},
{"order_id": 2005, "product": "Pen set", "qty": 1, "price": 8.0, "status": "paid"},
]
The manager wants a short end-of-day summary. Write one program that prints:
1. total paid revenue (USD);
2. number of paid lines;
3. number of distinct paid orders. (Hint: build a list paid_orders and use if order_id not in paid_orders: before appending.)
4. total refunded value (USD);
5. AOV = paid revenue ÷ distinct paid orders (USD, 2 decimals).
By hand first: calculate all five values. Then run and record matches. Finally, write one sentence for the manager explaining why "number of paid lines" and "number of paid orders" differ.
14. Mini Challenge
Fictional business: Greenleaf Plants keeps stock in a dictionary and receives a list of sales (synthetic):
stock = {"Fern": 12, "Cactus": 5, "Orchid": 8}
sales = [
{"plant": "Fern", "qty": 3},
{"plant": "Orchid", "qty": 6},
{"plant": "Cactus", "qty": 1},
{"plant": "Fern", "qty": 4},
{"plant": "Basil", "qty": 2},
]
- Write a loop that subtracts each sale from
stock. One sale is for a plant that is not instock. Decide what your code should do (e.g., print a warning and skip it), and explain why silently adding it, or crashing, would both be poor choices here. - After the loop, print every plant with stock 3 or below as needing reorder.
- Write the expected final
stockby hand before running, and compare.
Submit before feedback. No solution is provided here.
15. Resources
- Required (about 20 min): The Python Tutorial, chapter 5, "Data Structures". Read section 5.1 "More on Lists" up to, but not including, "List Comprehensions" (not needed yet). Then read 5.5 "Dictionaries" and 5.6 "Looping Techniques". https://docs.python.org/3/tutorial/datastructures.html (Opened and checked 12 Oct 2026.)
- Recommended (about 10 min): The Python Tutorial, sections 4.2 "
forStatements" and 4.3 "Therange()Function". https://docs.python.org/3/tutorial/controlflow.html (Opened and checked 12 Oct 2026.) - Deeper (optional): the remaining parts of section 5.1 (stacks, queues and comprehensions), once you are comfortable with plain loops.
16. Person to Follow / Role Model
Community perspective: Python community maintainers (no named person). The D.World map lists a community, not an individual.
Try this: the official General Python FAQ (https://docs.python.org/3/faq/general.html, opened 12 Oct 2026) answers practical community questions. Read two answers: 1. "I've never programmed before. Is there a Python tutorial?" 2. "How do I submit bug reports and patches for Python?" It points to the issue tracker at https://github.com/python/cpython/issues.
Note one way the community supports learners, and one way problems in Python itself are reported and fixed. You do not need an account to read these pages.
17. Glossary
| Term | Meaning in this lesson |
|---|---|
| Collection | A value that holds several values (list, dictionary) |
| List | Ordered collection in [ ]; items accessed by position |
| Index | Position in a list, starting at 0; -1 is the last item |
| Dictionary | Collection of unique keys mapped to values, in { } |
| Key / value | The look-up name / the data stored under it |
KeyError / IndexError |
Errors for a missing dictionary key / a list position that does not exist |
.get(key, default) |
Dictionary look-up that returns a default instead of an error |
for loop |
Repeats a block once per item in a collection |
| Iteration | One pass of a loop; also, looping in general |
| Accumulator | A variable created before a loop and updated inside it (e.g., a running total) |
range(start, stop) |
Numbers from start up to, but not including, stop |
| Mutable | Can be changed after creation (lists, dictionaries) |
| Record | One row of data with several fields (here, one dictionary) |
18. Reflection
In Part B, both bugs ran without any error message. What habit from this lesson would have caught them before anyone used the result?
19. Next Step
You have written loops that work on one specific list. In L16 — Functions, Errors & Debugging, you will package such logic into reusable functions with clear inputs and outputs, decide what should happen with invalid input, and diagnose errors systematically.
20. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Output prediction, Part A (A1–A6) | Reads list, dictionary, loop and mutability behaviour | 5 or more of 6 correct |
| Debugging, Part B (B1–B2) | Finds and fixes accumulator and loop-boundary bugs | Rubric L15-KCB; both outputs must reach 124.0 after the fix |
| AI in Practice (iteration explanation and tests) | Checks an AI explanation and runs loop tests including edge cases | Rubric L15-AI |
| Guided and independent practice, workplace summary, mini challenge | Builds per-category summaries; handles a missing key deliberately | Rubrics L15-GP, L15-IP, L15-WT, L15-MC |
References
- Python Software Foundation. The Python Tutorial, ch. 5 "Data Structures". https://docs.python.org/3/tutorial/datastructures.html (opened and checked 12 Oct 2026). Supports:
- dictionaries as "a set of key: value pairs, with the requirement that the keys are unique";
-
KeyErrorfor a non-existent key andget()returningNoneor a default; -list.append. - Python Software Foundation. The Python Tutorial, ch. 4. https://docs.python.org/3/tutorial/controlflow.html (opened and checked 12 Oct 2026). Supports: "The given end point is never part of the generated sequence."
- Python Software Foundation. General Python FAQ. https://docs.python.org/3/faq/general.html (opened and checked 12 Oct 2026). Supports: the beginner-tutorial and bug-report answers; the issue tracker URL.
- D.World Curriculum Map v1.0 (L15 row) and Curriculum Bible v1.0. Internal.
L15 — القوائم والقواميس والحلقات التكرارية
ملف المتعلّم. الإجابات والحلول النموذجية في ملف منفصل خاص بالمدرّس فقط. الإصدار: U04 v1.0 · تاريخ المحتوى: 12 أكتوبر 2026. تقديرات الوقت مبدئية إلى أن تُجرَّب مع المتعلّمين. أمثلة الكود مُختبَرة على Python 3.13 (راجع تقرير الجودة QA الخاص بـ U04).
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | القوائم والقواميس والحلقات التكرارية |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U04 — أساسيات Python |
| رقم الدرس | L15 |
| المهارات | هياكل البيانات (data structures)؛ التكرار (iteration) |
| المستوى | مبتدئ |
| الوقت المتوقع | حوالي ساعتين (مبدئي) |
| المتطلبات السابقة | L13 (المتغيرات، والأنواع) وL14 (المقارنات، وif). وL11 في U03 (بنود طلبات Cedar Lane؛ ومتوسط قيمة الطلب AOV = الإيرادات المدفوعة ÷ عدد الطلبات المدفوعة المختلفة). |
تفصيل الوقت (مبدئي): المفهوم والمثال المحلول 40 دقيقة · التدريب الموجَّه 15 دقيقة · التدريب المستقل 15 دقيقة · اختبار الفهم وتصحيح الأخطاء 15 دقيقة · الذكاء الاصطناعي في التطبيق والتحقق 10 دقائق · مهمة العمل 20 دقيقة · التحدي القصير 5 دقائق.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تستخدم القوائم والقواميس وحلقات for لكي تعالج مجموعة بسيطة من سجلات الأعمال. ويعني ذلك حساب المجاميع والأعداد والملخصات لكل منتج، ومراجعتها بالحسابات اليدوية.
هدف خريطة D.World (بنصّه): Use basic data structures and loops to process simple collections.
3. لماذا يهمّك هذا؟
البيانات الحقيقية نادرًا ما تأتي قيمةً واحدة في كل مرة. فالمتجر لديه قائمة معاملات، وقائمة أسعار، ومستويات مخزون لمنتجات كثيرة. وكتابة متغير مستقل لكل قيمة لا تصلح مع الأعداد الكبيرة.
المجموعات (collections) تحفظ قيمًا كثيرة معًا، والحلقات التكرارية (loops) تكرّر الخطوات نفسها مع كل قيمة. ومعًا يحوّلان حسابك لطلب واحد من L13–L14 إلى حساب يعمل على طلبات يوم كامل.
اختيار الهيكل المناسب يجعل الكود أقصر وأسهل في المراجعة:
- القائمة (list) عندما يكون الترتيب مهمًا؛
- القاموس (dictionary) عندما تبحث عن الأشياء بأسمائها.
المبدأ الأساسي: اختر هيكلًا يناسب المشكلة.
4. المفهوم
القوائم: مجموعات مرتّبة
prices = [12.0, 8.0, 20.0]
print(prices[0])
print(prices[-1])
print(len(prices))
prices.append(5.5)
print(prices)
12.0
20.0
3
[12.0, 8.0, 20.0, 5.5]
- العناصر تكون داخل
[ ]، وتفصل بينها فواصل. - المواضع (الفهارس، indexes) تبدأ من 0.
prices[0]هو العنصر الأول؛ وprices[-1]هو الأخير. len(...)تعطي عدد العناصر. و.append(x)تضيفxإلى النهاية.- طلب موضع غير موجود (مثل
prices[10]) يُطلق خطأIndexError.
القواميس: البحث بالمفتاح
unit_prices = {"Notebook": 12.0, "Pen set": 8.0, "Planner": 20.0}
print(unit_prices["Planner"])
unit_prices["Planner"] = 18.0 # change a value
unit_prices["Bookmark"] = 2.5 # add a new key
print(unit_prices)
print(unit_prices.get("Stapler", 0.0))
print("Notebook" in unit_prices)
20.0
{'Notebook': 12.0, 'Pen set': 8.0, 'Planner': 18.0, 'Bookmark': 2.5}
0.0
True
(التعليقان في الكود يعنيان: تغيير قيمة، وإضافة مفتاح جديد.)
- القاموس مجموعة من أزواج مفتاح: قيمة (key: value)، والمفاتيح لا تتكرر داخل القاموس الواحد (The Python Tutorial، القسم 5.5).
d[key]تجلب القيمة. وإذا لم يكن المفتاح موجودًا، يُطلق Python خطأKeyError.d.get(key, default)تُرجع القيمة الافتراضية بدلًا من إطلاق خطأ. استخدمها فقط عندما تكون القيمة الافتراضية منطقية في الأعمال، مثل "0 وحدات مباعة".key in dتفحص هل المفتاح موجود (True/False).
قوائم من القواميس: السجلات
من الطرق الشائعة لحفظ المعاملات استخدام قائمة من القواميس، قاموس واحد لكل بند:
transactions = [ {"order_id": 1001, "product": "Notebook", "qty": 2, ...},
{"order_id": 1001, "product": "Pen set", "qty": 1, ...}, ... ]
حلقات for
quantities = [2, 1, 1, 4]
total_units = 0
for qty in quantities:
total_units = total_units + qty
print(total_units)
8
for qty in quantities:تنفّذ الكتلة المُزاحة مرة لكل عنصر، وفي كل مرة يأخذqtyقيمة العنصر التالي.- نمط المُجمِّع (Accumulator pattern): أنشئ المجموع قبل الحلقة (
total_units = 0)، ثم حدّثه داخل الحلقة. - المرور على قاموس:
for product, price in unit_prices.items():تعطيك كل مفتاح وقيمته. range(start, stop)تنتج أعدادًا منstartحتىstopدون أن تشمله. ويقول الدليل التعليمي: "The given end point is never part of the generated sequence." (نقطة النهاية المعطاة لا تكون أبدًا جزءًا من التسلسل الناتج). لذلكrange(1, 4)تعطي 1 و2 و3. ونادرًا ما تحتاج إلىrangeللمرور على قائمة:for item in my_listأبسط، وتجنّبك تخطّي عناصر أو تكرارها بالخطأ.
القوائم والقواميس يمكن تغييرها في مكانها
القوائم والقواميس قابلة للتغيير (mutable): يمكنك تعديلها بعد إنشائها. ومن نتائج ذلك:
orders = [1001, 1002]
same_orders = orders # NOT a copy: two names for one list
same_orders.append(1003)
print(orders)
backup = orders.copy() # a real copy
backup.append(1004)
print(orders)
[1001, 1002, 1003]
[1001, 1002, 1003]
(التعليق الأول يعني: هذه ليست نسخة، بل اسمان لقائمة واحدة. والتعليق الثاني يعني: نسخة حقيقية.)
أي هيكل تختار؟
| المشكلة | الهيكل المناسب | السبب |
|---|---|---|
| تسلسل من القيم بترتيب معيّن (المبيعات اليومية) | قائمة | الترتيب والموضع مهمان |
| البحث عن قيمة بالاسم (سعر "Planner") | قاموس | بحث مباشر بالمفتاح |
| سجلات كثيرة لكل منها عدة حقول (المعاملات) | قائمة من القواميس | كل سجل له حقول بأسماء؛ والقائمة تجمعها معًا |
| مجاميع لكل فئة (الإيرادات لكل منتج) | قاموس يُبنى داخل حلقة | مفتاح واحد لكل فئة، والقيمة = المجموع المتراكم |
5. مثال محلول
المهمة: احسب إجمالي الإيرادات المدفوعة من بنود طلبات Cedar Lane (بيانات مصطنعة، الأسبوع نفسه في L11 من U03).
الخطوة 1: الإجابة المتوقعة أولًا. في L11 من U03 حسبت يدويًا أن الإيرادات المدفوعة = 124 (مع استبعاد الأجندة المستردّة).
الخطوة 2: الكود. (Run)
transactions = [
{"order_id": 1001, "product": "Notebook", "qty": 2, "price": 12.0, "status": "paid"},
{"order_id": 1001, "product": "Pen set", "qty": 1, "price": 8.0, "status": "paid"},
{"order_id": 1002, "product": "Notebook", "qty": 1, "price": 12.0, "status": "paid"},
{"order_id": 1003, "product": "Planner", "qty": 1, "price": 20.0, "status": "refunded"},
{"order_id": 1004, "product": "Notebook", "qty": 1, "price": 12.0, "status": "paid"},
{"order_id": 1005, "product": "Notebook", "qty": 4, "price": 12.0, "status": "paid"},
{"order_id": 1005, "product": "Planner", "qty": 1, "price": 20.0, "status": "paid"},
]
paid_revenue = 0.0
for line in transactions:
if line["status"] == "paid":
paid_revenue = paid_revenue + line["qty"] * line["price"]
print(f"Paid revenue: {paid_revenue} USD")
Paid revenue: 124.0 USD
الخطوة 3: التتبّع. راجع المجموع المتراكم بعد كل بند:
| البند | status | المُضاف | paid_revenue بعده |
|---|---|---|---|
| 1001 Notebook | paid | 2 × 12 = 24 | 24.0 |
| 1001 Pen set | paid | 8 | 32.0 |
| 1002 Notebook | paid | 12 | 44.0 |
| 1003 Planner | refunded | 0 (تم تخطّيه) | 44.0 |
| 1004 Notebook | paid | 12 | 56.0 |
| 1005 Notebook | paid | 48 | 104.0 |
| 1005 Planner | paid | 20 | 124.0 ✔ |
(أسطر المعاملات أطول من الحد الإرشادي في PEP 8 وهو 79 حرفًا، لكنها بقيت في سطر واحد ليسهل قراءة كل سجل.)
6. شرح بصري
transactions (list) ──► [ {line 1}, {line 2}, {line 3}, ... {line 7} ]
│
for line in transactions: ← takes each dictionary in turn
│
line["status"] == "paid" ?
│ yes │ no
paid_revenue += qty * price skip
│
after the loop: paid_revenue = 124.0
وصف الرسم: قائمة اسمها transactions تحتوي على سبعة قواميس، قاموس لكل بند طلب. وحلقة for تأخذ كل قاموس بدوره. ومع كل قاموس تفحص هل الحالة status تساوي "paid". إذا كانت الإجابة نعم، يُضاف حاصل ضرب الكمية في السعر إلى paid_revenue؛ وإذا كانت لا، يُتخطّى البند. وبعد انتهاء الحلقة تكون قيمة paid_revenue هي 124.0.
7. تدريب موجَّه
(Run.) باستخدام transactions من المثال المحلول، احسب عدد الوحدات المباعة لكل منتج (البنود المدفوعة فقط) في صورة قاموس.
- الإجابة المتوقعة أولًا: عُدّ الوحدات المدفوعة لكل منتج يدويًا.
- أكمل هذا القالب (لا يمكن تشغيله كما هو):
units = {}
for line in transactions:
if line["status"] == ___:
product = line["product"]
units[product] = units.get(product, ___) + line[___]
print(units)
- شغّله وقارن النتيجة بعدّك اليدوي.
- اشرح في جملة واحدة لماذا نستخدم
units.get(product, 0)بدلًا منunits[product]في أول مرة يظهر فيها منتج. (تلميح: ماذا سيحدث مع قاموس فارغ؟)
8. تدريب مستقل
(Run.) باستخدام transactions نفسها:
- ابنِ قاموسًا اسمه
revenue_by_productيحتوي على الإيرادات المدفوعة لكل منتج. - باستخدام حلقة على
revenue_by_product.items()وجملةif، اعثر على المنتج صاحب أعلى إيرادات مدفوعة. خزّن اسمه وقيمته في متغيرين واطبعهما. - في حلقة منفصلة، احسب إجمالي قيمة البنود المستردّة.
- راجع كل النتائج يدويًا وسجّل ما يطابق منها.
لا تُعرض هنا إجابة نموذجية.
9. اختبار الفهم — مهمة عملية + تصحيح الأخطاء
الجزء A — توقّع المخرجات، ثم شغّل الكود لتتأكد.
A1.
prices = [12.0, 8.0, 20.0]
print(prices[1])
- A)
12.0 - B)
8.0 - C)
20.0 - D) خطأ
IndexError
A2.
prices = [12.0, 8.0, 20.0]
print(len(prices), prices[-1])
- A)
3 20.0 - B)
2 20.0 - C)
3 12.0 - D) خطأ
A3.
stock = {"Notebook": 40, "Planner": 5}
stock["Planner"] = stock["Planner"] - 2
print(stock)
- A)
{'Notebook': 40, 'Planner': 5} - B)
{'Notebook': 38, 'Planner': 5} - C) خطأ، لأن القواميس لا يمكن تغييرها
- D)
{'Notebook': 40, 'Planner': 3}
A4.
stock = {"Notebook": 40, "Planner": 5}
print(stock.get("Pen set", 0))
- A)
0 - B)
None - C) خطأ
KeyError - D)
Pen set
A5.
total = 0
for n in range(1, 4):
total = total + n
print(total)
- A)
10 - B)
4 - C)
6 - D)
3
A6.
a = [1, 2]
b = a
b.append(3)
print(a)
- A)
[1, 2] - B)
[1, 2, 3] - C)
[3] - D) خطأ
الجزء B — تصحيح الأخطاء (Debugging) (Run). المفروض أن يطبع كل برنامج بالأسفل إجمالي الإيرادات المدفوعة لـ transactions في المثال المحلول (المتوقع 124.0). الصق قائمة transactions فوق كل برنامج قبل تشغيله. ولكل برنامج: (1) توقّع المخرجات ثم شغّله لتعرف المخرجات الفعلية؛ (2) اشرح السبب في جملة واحدة؛ (3) أصلحه بأصغر تغيير ممكن؛ (4) أعِد التشغيل وتأكد أن الناتج 124.0.
B1.
paid_revenue = 0.0
for line in transactions:
paid_revenue = 0.0
if line["status"] == "paid":
paid_revenue = paid_revenue + line["qty"] * line["price"]
print(paid_revenue)
B2.
paid_revenue = 0.0
for i in range(1, len(transactions)):
line = transactions[i]
if line["status"] == "paid":
paid_revenue = paid_revenue + line["qty"] * line["price"]
print(paid_revenue)
10. الذكاء الاصطناعي في التطبيق
اطلب من الذكاء الاصطناعي أن يشرح اختيارات التكرار، وأن ينشئ حالات اختبار لحلقة.
- اسأل مساعد ذكاء اصطناعي (كود مصطنع فقط):
"I'm a Python beginner. Here is a loop that totals paid revenue from a list of dictionaries (below). (1) Explain the difference between
for line in transactions:andfor i in range(len(transactions)):, and when each is appropriate. (2) Suggest 5 small test lists (each with 0–3 lines) that check this loop, including edge cases, with the expected total for each. Do not rewrite the loop. """ (paste the worked-example loop and two sample lines) """
وبالعربية: "أنا مبتدئ في Python. هذه حلقة تحسب إجمالي الإيرادات المدفوعة من قائمة قواميس (بالأسفل). (1) اشرح الفرق بين for line in transactions: وfor i in range(len(transactions)):، ومتى يكون كل منهما مناسبًا. (2) اقترح 5 قوائم اختبار صغيرة (كل منها من 0 إلى 3 بنود) تفحص هذه الحلقة، ومنها حالات طرفية، مع المجموع المتوقع لكل منها. لا تُعِد كتابة الحلقة. """ (الصق حلقة المثال المحلول وبندين كعينة) """"
- اقرأ الشرح وقارنه بالقسم 4. وضع علامة على أي شيء غير واضح أو يتعارض مع الدرس.
- شغّل كل قائمة اختبار بنفسك. اجعل
transactions = [...]تساوي كل قائمة اختبار وشغّل الحلقة. وسجّل القيمة المتوقعة (من الذكاء الاصطناعي)، والقيمة المتوقعة (من حسابك أنت اليدوي)، والقيمة الفعلية. - تأكد أن الاختبارات تشمل على الأقل:
- قائمة فارغة؛
- قائمة كل بنودها مستردّة؛
- بندًا مدفوعًا واحدًا؛
- بندًا فيه qty تساوي 0.
أضف أي حالة ناقصة.
11. التحقق من مخرجات الذكاء الاصطناعي
- حسابك اليدوي هو المرجع. إذا اختلف المجموع المتوقع من الذكاء الاصطناعي عن مجموعك، فأعِد الحساب؛ وإذا كنت على صواب، فسجّل قيمة الذكاء الاصطناعي على أنها خاطئة.
- شغّل ولا تفترض: يجب أن تُشغَّل كل قائمة اختبار فعلًا.
- قارن الشرح بالدليل التعليمي: مثلًا، الادعاء بأن نقطة نهاية
rangeمستبعدة. - انتبه للكود المتقدم الذي لم تطلبه (مثل comprehensions، أو المكتبات الخارجية). اطلب نسخة للمبتدئين، أو ارفضه.
- الحالات الطرفية: القائمة الفارغة يجب أن تعطي
0.0، وليس خطأ. وإذا تعطّل أي اختبار، فسجّل في أي سطر ولماذا. - الخصوصية: استخدم قوائم تجريبية مصطنعة فقط. لا تلصق أبدًا ملفات معاملات حقيقية مُصدَّرة من أي نظام.
12. منظور الأعمال
احسب إجمالي الإيرادات من قائمة معاملات. هذه من أكثر مهام البيانات شيوعًا، وتعريفات الأعمال التي تعلمتها في U02–U03 ما زالت تنطبق داخل الحلقة:
- صفِّ البيانات بشكل صحيح: المدفوع مقابل المستردّ، والفترة الصحيحة، والمنتج الصحيح.
- عُدّ الشيء الصحيح: إيراد كل بند هو
qty × price؛ أما الطلبات فتحتاج إلى قيمorder_idمختلفة (L11 في U03). - الملخصات لكل فئة (الإيرادات لكل منتج) تدعم قرارات المخزون والترويج والتسعير.
- راجع المجاميع يدويًا على عينة صغيرة قبل أن تثق في حلقة تعمل على آلاف البنود.
13. مهمة عمل — ملخص المبيعات اليومي
بيانات مصطنعة، لمتجر Cedar Lane الخيالي، ليوم واحد:
day = [
{"order_id": 2001, "product": "Notebook", "qty": 3, "price": 12.0, "status": "paid"},
{"order_id": 2001, "product": "Planner", "qty": 1, "price": 20.0, "status": "paid"},
{"order_id": 2002, "product": "Pen set", "qty": 2, "price": 8.0, "status": "paid"},
{"order_id": 2003, "product": "Notebook", "qty": 1, "price": 12.0, "status": "refunded"},
{"order_id": 2004, "product": "Planner", "qty": 2, "price": 20.0, "status": "paid"},
{"order_id": 2005, "product": "Pen set", "qty": 1, "price": 8.0, "status": "paid"},
]
يريد المدير ملخصًا قصيرًا في نهاية اليوم. اكتب برنامجًا واحدًا يطبع:
- إجمالي الإيرادات المدفوعة (USD)؛
- عدد البنود المدفوعة؛
- عدد الطلبات المدفوعة المختلفة. (تلميح: ابنِ قائمة
paid_ordersواستخدمif order_id not in paid_orders:قبل الإضافة.) - إجمالي القيمة المستردّة (USD)؛
- متوسط قيمة الطلب AOV = الإيرادات المدفوعة ÷ عدد الطلبات المدفوعة المختلفة (USD، برقمين عشريين).
يدويًا أولًا: احسب القيم الخمس كلها. ثم شغّل البرنامج وسجّل ما يطابق منها. وأخيرًا، اكتب جملة واحدة للمدير تشرح فيها لماذا يختلف "عدد البنود المدفوعة" عن "عدد الطلبات المدفوعة".
14. تحدٍّ قصير
نشاط تجاري خيالي: Greenleaf Plants يحفظ المخزون في قاموس، ويستقبل قائمة بالمبيعات (بيانات مصطنعة):
stock = {"Fern": 12, "Cactus": 5, "Orchid": 8}
sales = [
{"plant": "Fern", "qty": 3},
{"plant": "Orchid", "qty": 6},
{"plant": "Cactus", "qty": 1},
{"plant": "Fern", "qty": 4},
{"plant": "Basil", "qty": 2},
]
- اكتب حلقة تطرح كل عملية بيع من
stock. إحدى عمليات البيع لنبات غير موجود فيstock. قرّر ماذا يجب أن يفعل كودك (مثلًا: يطبع تحذيرًا ويتخطّاها)، واشرح لماذا يكون كلٌّ من إضافته بصمت، أو توقّف البرنامج بخطأ، اختيارًا سيئًا هنا. - بعد الحلقة، اطبع كل نبات وصل مخزونه إلى 3 أو أقل على أنه يحتاج إلى إعادة طلب.
- اكتب قيمة
stockالنهائية المتوقعة يدويًا قبل التشغيل، ثم قارن.
سلّم إجابتك قبل الحصول على التعليقات. لا يوجد حل هنا.
15. المصادر
- مطلوب (حوالي 20 دقيقة): The Python Tutorial، الفصل 5، "Data Structures". اقرأ القسم 5.1 "More on Lists" حتى "List Comprehensions" دون أن تقرأه (لا تحتاجه الآن). ثم اقرأ 5.5 "Dictionaries" و5.6 "Looping Techniques". https://docs.python.org/3/tutorial/datastructures.html (فُتح وروجع في 12 أكتوبر 2026.)
- موصى به (حوالي 10 دقائق): The Python Tutorial، القسمان 4.2 "
forStatements" و4.3 "Therange()Function". https://docs.python.org/3/tutorial/controlflow.html (فُتح وروجع في 12 أكتوبر 2026.) - للتعمّق (اختياري): باقي أجزاء القسم 5.1 (المكدّسات stacks، والطوابير queues، وcomprehensions)، بعد أن ترتاح في استخدام الحلقات العادية.
16. شخصية تتابعها / قدوة
منظور المجتمع: القائمون على صيانة Python في المجتمع (دون شخص بعينه). خريطة D.World تذكر مجتمعًا، وليس فردًا.
جرّب هذا: صفحة General Python FAQ الرسمية (https://docs.python.org/3/faq/general.html، فُتحت في 12 أكتوبر 2026) تجيب عن أسئلة عملية تخص المجتمع. اقرأ إجابتين:
- "I've never programmed before. Is there a Python tutorial?" (لم أبرمج من قبل. هل يوجد دليل تعليمي لـ Python؟)
- "How do I submit bug reports and patches for Python?" (كيف أُرسل بلاغات الأخطاء والتعديلات الخاصة بـ Python؟) وهي تشير إلى متتبّع المشكلات على https://github.com/python/cpython/issues.
دوّن طريقة واحدة يدعم بها المجتمع المتعلّمين، وطريقة واحدة يُبلَّغ بها عن مشكلات Python نفسه وتُصلَح. لا تحتاج إلى حساب لقراءة هذه الصفحات.
17. المصطلحات
| المصطلح | معناه في هذا الدرس |
|---|---|
| المجموعة (Collection) | قيمة تحتوي على عدة قيم (قائمة، قاموس) |
| القائمة (List) | مجموعة مرتّبة داخل [ ]؛ ويُوصَل إلى عناصرها بالموضع |
| الفهرس (Index) | الموضع في القائمة، ويبدأ من 0؛ و-1 هو العنصر الأخير |
| القاموس (Dictionary) | مجموعة من مفاتيح لا تتكرر، يرتبط كل منها بقيمة، داخل { } |
| المفتاح / القيمة (Key / value) | الاسم الذي نبحث به / البيانات المخزّنة تحته |
KeyError / IndexError |
أخطاء عند طلب مفتاح غير موجود في القاموس / موضع غير موجود في القائمة |
.get(key, default) |
بحث في القاموس يُرجع قيمة افتراضية بدلًا من الخطأ |
حلقة for (for loop) |
تكرّر كتلة من الكود مرة لكل عنصر في مجموعة |
| التكرار (Iteration) | مرور واحد في الحلقة؛ ويُقصد به أيضًا استخدام الحلقات عمومًا |
| المُجمِّع (Accumulator) | متغير يُنشأ قبل الحلقة ويُحدَّث داخلها (مثل المجموع المتراكم) |
range(start, stop) |
أعداد من start حتى stop دون أن تشمله |
| قابل للتغيير (Mutable) | يمكن تغييره بعد إنشائه (القوائم، القواميس) |
| السجل (Record) | صف واحد من البيانات له عدة حقول (هنا: قاموس واحد) |
18. تأمّل
في الجزء B، عمل الخطآن دون أي رسالة خطأ. أي عادة من هذا الدرس كانت ستكشفهما قبل أن يستخدم أحد النتيجة؟
19. الخطوة التالية
كتبت حلقات تعمل على قائمة واحدة محددة. في L16 — الدوال والأخطاء وتصحيحها، ستجمع هذا المنطق في دوال قابلة لإعادة الاستخدام (functions) لها مدخلات ومخرجات واضحة، وتقرّر ماذا يجب أن يحدث مع المدخلات غير الصالحة، وتشخّص الأخطاء بطريقة منهجية.
20. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| توقّع المخرجات، الجزء A (A1–A6) | قراءة سلوك القوائم والقواميس والحلقات وقابلية التغيير | 5 إجابات صحيحة أو أكثر من 6 |
| تصحيح الأخطاء، الجزء B (B1–B2) | العثور على أخطاء المُجمِّع وحدود الحلقة وإصلاحها | معايير L15-KCB؛ ويجب أن يصل البرنامجان إلى 124.0 بعد الإصلاح |
| الذكاء الاصطناعي في التطبيق (شرح التكرار والاختبارات) | مراجعة شرح الذكاء الاصطناعي وتشغيل اختبارات الحلقة بما فيها الحالات الطرفية | معايير L15-AI |
| التدريب الموجَّه والمستقل، وملخص العمل، والتحدي القصير | بناء ملخصات لكل فئة؛ والتعامل المقصود مع مفتاح غير موجود | معايير L15-GP وL15-IP وL15-WT وL15-MC |
المراجع
- Python Software Foundation. The Python Tutorial، الفصل 5 "Data Structures". https://docs.python.org/3/tutorial/datastructures.html (فُتح وروجع في 12 أكتوبر 2026). يدعم:
- وصف القواميس بأنها "a set of key: value pairs, with the requirement that the keys are unique"؛
- خطأ
KeyErrorعند طلب مفتاح غير موجود، وأنget()تُرجعNoneأو قيمة افتراضية؛ list.append.
- Python Software Foundation. The Python Tutorial، الفصل 4. https://docs.python.org/3/tutorial/controlflow.html (فُتح وروجع في 12 أكتوبر 2026). يدعم: "The given end point is never part of the generated sequence."
- Python Software Foundation. General Python FAQ. https://docs.python.org/3/faq/general.html (فُتحت وروجعت في 12 أكتوبر 2026). يدعم: إجابتي الدليل التعليمي للمبتدئين وبلاغات الأخطاء؛ ورابط متتبّع المشكلات.
- D.World Curriculum Map v1.0 (صف L15) وCurriculum Bible v1.0. وثائق داخلية.
L16 · Functions, Errors & DebuggingL16 · الدوال والأخطاء وتصحيحها Freeمجاني
L16 — Functions, Errors & Debugging
Learner file. Answers and model solutions are in a separate instructor-only file. Version: U04 v1.0 · Content date: 12 October 2026. Time estimates are provisional until learner-tested. Code examples were tested with Python 3.13 (see the U04 QA report). Error-message wording can differ slightly between Python versions; the error type (e.g.,
ValueError) is what matters.
1. Lesson Identity
| Field | Value |
|---|---|
| Title | Functions, Errors & Debugging |
| Stage | Stage 1 — Foundations |
| Unit | U04 — Python Fundamentals |
| Lesson ID | L16 |
| Skills | Functions; debugging |
| Difficulty | Beginner |
| Estimated time | About 2 hours 5 minutes (provisional) |
| Prerequisites | L13–L15. U02 L06–L07 (gross margin, conversion, AOV); U03 L11 (expected answer first; test types). |
Time breakdown (provisional): concept and worked example, 40 min · guided practice, 15 min · independent practice, 15 min · knowledge check and debugging challenge, 20 min · AI in Practice and Verification, 10 min · workplace task, 20 min · mini challenge, 5 min.
2. Learning Objective
By the end of this lesson, you will be able to write reusable functions with clear inputs, outputs and invalid-input behaviour, and diagnose common syntax, runtime, type and logic errors by fixing their cause and confirming the fix with tests.
D.World map objective (verbatim): Write reusable functions and diagnose common runtime/type/logic errors.
3. Why It Matters
In L13–L15 you wrote calculations that worked on one set of values. Businesses need the same KPI calculated correctly every day, for every product, by different people.
A function packages the calculation once, with a name, inputs and an output, so it can be reused and tested. Real inputs are sometimes wrong: zero orders, missing fields, text instead of numbers. A function must handle them explicitly. A KPI that quietly shows a misleading number is worse than one that clearly says "this input is invalid". Key principle: fix the cause, not only the symptom.
4. Concept
Defining and calling a function
def gross_profit(revenue, cogs):
"""Return gross profit: revenue minus cost of goods sold."""
return revenue - cogs
september = gross_profit(12000.0, 5000.0)
print(september)
print(gross_profit(13200.0, 6000.0))
7000.0
7200.0
defstarts a function definition, followed by the name and the parameters in parentheses, then a colon.- The indented body runs only when the function is called, e.g.,
gross_profit(12000.0, 5000.0). The values you pass in are called arguments. - The text in triple quotes is a docstring: a short description of what the function does.
returnsends a value back to the caller, which can store it, print it or use it in another calculation.
return vs print
print only shows a value on screen; return gives it back for further use. A function with no return still returns a value: None, which the Python Tutorial calls "a rather boring one". If you see None where you expected a number, check for a missing return.
Default parameter values
def shipping_fee(total, threshold=30.0):
if total >= threshold:
return 0.0
return 4.99
print(shipping_fee(35.0))
print(shipping_fee(25.0, 20.0))
0.0
0.0
threshold=30.0 is used unless the caller provides another value.
Kinds of errors
The Python Tutorial distinguishes "syntax errors and exceptions". For debugging, it helps to add a third kind: logic errors.
| Kind | When you see it | Examples | Typical message (last line) |
|---|---|---|---|
| Syntax error | Before the program runs | Missing :, wrong indentation, = instead of == in a condition |
SyntaxError: ..., IndentationError: ... |
| Runtime error (exception) | While running; the program stops | Name not defined; dividing by zero; missing key | NameError, ZeroDivisionError, KeyError, IndexError |
| Type error (a common runtime error) | An operation gets the wrong type | "Total: " + 5 |
TypeError: can only concatenate str (not "int") to str |
| Logic error | The program runs, but the result is wrong | Dividing by lines instead of orders; wrong boundary | No message at all |
Reading an error message: the Tutorial notes that "The last line of the error message indicates what happened". Start with the last line (the error type and description). Then look above it for the line number where it happened.
A debugging routine
- Reproduce: run it again with the same input and confirm you see the same problem.
- Read: the last line of the message (or, for a logic error, compare actual vs expected).
- Locate: find the line; trace the values just before it (L15 trace tables).
- Hypothesise the cause: why is the value wrong at that point?
- Fix the cause with the smallest change that addresses it, not by hiding the symptom.
- Test: rerun the failing case, plus normal and edge cases, to check that nothing else broke.
Handling invalid input explicitly
Decide, in words, what the function should do with bad input. Then make the code do exactly that.
- Raise a clear error with
raise ValueError("message")orraise TypeError("message"). The Tutorial explains that "The raise statement allows the programmer to force a specified exception to occur." PEP 20 puts it as "Errors should never pass silently." - Don't silently return a misleading number. For example, returning
0as the AOV when there are no orders makes "no data" look like "zero value". isinstance(value, int)checks a value's type and givesTrueorFalse.isinstance(value, (int, float))accepts either type. (Note: Python also treatsTrue/Falseas a kind ofint; this lesson does not handle that case.)- The caller can handle an expected error with
try/except, naming the specific exception type. PEP 8 advises: "mention specific exceptions whenever possible instead of using a bareexcept:clause".
try:
value = int("five")
except ValueError:
print("Quantity must be a whole number")
Quantity must be a whole number
Quick tests with assert
assert condition does nothing if the condition is True, and stops with an AssertionError if it is False. It is a simple way to record a test with its expected answer. U05 goes further into testing.
assert gross_profit(12000.0, 5000.0) == 7000.0
assert gross_profit(0.0, 0.0) == 0.0
print("All gross_profit tests passed")
All gross_profit tests passed
Avoid == on results of division with long decimals (L14). Compare rounded values instead, e.g., round(x, 1) == 58.3.
5. Worked Example
KPI: average order value (U02 L07): AOV = revenue ÷ number of orders.
Step 1: decide the behaviour in words.
| Input | Expected behaviour |
|---|---|
| revenue 124.0, orders 4 | Return 31.0 |
| orders = 0 | Raise ValueError: AOV is undefined with no orders. Do not return 0 |
| orders negative, or revenue negative | Raise ValueError |
revenue given as text, e.g., "124", or orders not a whole number |
Raise TypeError |
Step 2: code. (Run)
def average_order_value(revenue, orders):
"""Return average order value (revenue / number of orders).
Raises TypeError for non-numeric input and ValueError for
orders <= 0 or negative revenue.
"""
if not isinstance(revenue, (int, float)) or not isinstance(orders, int):
raise TypeError("revenue must be a number and orders a whole number")
if orders <= 0:
raise ValueError("orders must be greater than 0")
if revenue < 0:
raise ValueError("revenue cannot be negative")
return revenue / orders
print(average_order_value(124.0, 4))
print(average_order_value(15000.0, 600))
try:
average_order_value(100.0, 0)
except ValueError as error:
print("Invalid input:", error)
try:
average_order_value("124", 4)
except TypeError as error:
print("Invalid input:", error)
31.0
25.0
Invalid input: orders must be greater than 0
Invalid input: revenue must be a number and orders a whole number
Step 3: check.
- 124 ÷ 4 = 31 ✔ (U03 L11).
- 15,000 ÷ 600 = 25 ✔ (U02 L07).
- Both invalid inputs produce clear, specific messages instead of a crash with ZeroDivisionError or a misleading 0.
6. Visual Explanation
arguments ──► average_order_value(revenue, orders) ──► return value
(124.0, 4) │ 31.0
├─ wrong type? ──► raise TypeError
├─ orders <= 0? ──► raise ValueError
├─ revenue < 0? ──► raise ValueError
└─ otherwise ──► revenue / orders
DEBUG LOOP: reproduce → read last line → locate → find CAUSE → fix → test (old + new cases)
Alt text: Arguments 124.0 and 4 enter the function average_order_value, which returns 31.0. Inside, the function checks in order: if the input has the wrong type, it raises a TypeError; if orders is zero or less, it raises a ValueError; if revenue is negative, it raises a ValueError; otherwise it returns revenue divided by orders. Below, the debugging loop has six steps: reproduce, read the last line, locate, find the cause, fix, and test both the old and new cases.
7. Guided Practice
(Run.) Write gross_margin_pct(revenue, cogs), returning gross margin as a percentage (U02 L06).
- Behaviour in words first:
- revenue must be greater than 0 → otherwise raise
ValueError; - a negative margin (costs higher than revenue) is allowed, because it is real information. - Complete the template (not runnable as shown):
text
def gross_margin_pct(revenue, cogs):
"""Return gross margin as a percentage of revenue."""
if revenue ___ 0:
raise ValueError(___)
return (revenue - cogs) / ___ * 100
- Expected answers by hand (rounded to 1 decimal), then test with
assert round(...) == ...orprint: - (12000.0, 5000.0); - (13200.0, 6000.0); - (100.0, 120.0); - (0.0, 50.0), usingtry/except ValueError. - Explain why the condition is
revenue <= 0and notrevenue < 0.
8. Independent Practice
(Run.) Write conversion_rate_pct(orders, sessions) (U02 L07: orders ÷ sessions × 100).
- Write the invalid-input rules in words first. At minimum, cover: - sessions of 0 or fewer; - negative orders; - orders greater than sessions (impossible in this simple funnel).
- Implement the function with clear
ValueErrormessages. - Test at least these cases, with expected results calculated by hand first: - (600, 20000); - (550, 22000); - (0, 100); - (10, 0); - (30, 20).
- Record each test as input → expected → actual → pass/fail.
No model answer is shown here.
9. Knowledge Check — Function Task + Debugging Challenge
Part A — Predict and classify.
A1. What does this print?
def double(price):
print(price * 2)
result = double(10)
print(result)
- A)
20then20 - B)
20thenNone - C)
Nonethen20 - D) Only
20
A2. What does this print?
def shipping_fee(total, threshold=30.0):
if total >= threshold:
return 0.0
return 4.99
print(shipping_fee(30.0), shipping_fee(25.0, 20.0))
- A)
0.0 4.99 - B)
4.99 0.0 - C)
0.0 0.0 - D)
4.99 4.99
A3. A program stops with NameError: name 'revenue' is not defined. What is the most likely cause?
- A) revenue is used before it was assigned, or its name is misspelled.
- B) revenue is a float instead of an int.
- C) Division by zero
- D) A missing dictionary key
A4. Which error does print("Total: " + 5) raise?
- A) ValueError
- B) NameError
- C) SyntaxError
- D) TypeError
A5. Which error does int("five") raise?
- A) TypeError
- B) ValueError
- C) ZeroDivisionError
- D) No error; it returns 5
A6. A conversion-rate function runs without any error but returns 30.0 when the right result is 3.0. What kind of error is this? - A) Syntax error - B) Runtime error - C) Logic error - D) Not an error, because the program did not crash
Part B — Debugging challenge (Run). This function should return the AOV of the paid lines in a list of transactions. That is paid revenue ÷ distinct paid orders (U03 L11). For the L15 worked-example transactions, the expected result is 31.0. If there are no paid lines, it should raise ValueError("no paid orders").
def aov_from_transactions(transactions):
paid_revenue = 0.0
paid_lines = 0
for line in transactions:
if line["status"] == "paid":
paid_revenue = paid_revenue + line["qty"] * line["price"]
paid_lines = paid_lines + 1
return paid_revenue / paid_lines
- Paste the L15
transactionslist above the function. Runprint(aov_from_transactions(transactions)). Record the actual and expected values. - Run
aov_from_transactions([]). Record the last line of the error. - For each problem, name the kind of error (Section 4) and its cause.
- Fix both causes. (Hint: L15 Workplace Task, distinct orders.)
- Write at least three tests:
- the normal case (31.0);
- an empty list (expects
ValueError); - a list where all lines are refunded (expectsValueError).
Run them and record the results.
10. AI in Practice
Ask AI for a minimal fix, but require an explanation and a test before accepting it.
- Reproduce first (Run):
```python def conversion_rate_pct(orders, sessions): return orders / sessions * 100
print(conversion_rate_pct(600, 20000)) print(conversion_rate_pct(5, 0)) ```
Record the output and the last line of the error.
- Ask an AI assistant (synthetic code only):
"This Python function crashes when sessions is 0 (code and error below). Suggest the minimal fix. Explain why it fixes the cause rather than hiding the symptom, and give 3 tests (input → expected result) that I can run to confirm it. Do not add libraries. """ (paste the function and the error's last line) """
- Evaluate the suggestion before accepting it. A common suggestion is
if sessions == 0: return 0. Ask: - Does returning 0 tell the truth? - Would a dashboard showing "0% conversion" for a day with no data mislead someone? - Decide and implement your own version with an explicit rule (for example, raise
ValueErrorwith a clear message). Then run the AI's tests and your own, including normal, zero-session and negative cases. - Write a 2–3-line note: what you accepted, what you rejected, and why.
11. AI Verification
- Explanation required: do not accept a fix you cannot explain line by line.
- Symptom vs cause: does the fix make the error message disappear while leaving a wrong or misleading result? If so, reject it.
- Tests required: run the failing case, a normal case and at least one other edge case. Record expected (by hand) vs actual.
- Minimal: reject unrelated rewrites, renamed variables or new libraries you did not ask for.
- Consistency: check that the function behaves the same way for similar invalid inputs (PEP 8: "Be consistent in return statements").
- Licensing and honesty: if you reuse code from AI or from a website, check the licence for website code, test the code, and note its use in your AI-use note.
- Privacy: synthetic code and data only. Never paste real customer data, credentials or company code you are not allowed to share.
12. Business Lens
Create a function that computes an e-commerce KPI and handles invalid input. A KPI function is a small piece of business policy:
- One definition everywhere. Everyone who calls
average_order_valuegets the same formula (U02 KPI definition card). - Invalid input is a business question. What should a report show when there were no orders? "Not available" is usually more honest than 0. Agree this with the KPI owner.
- Clear error messages save time for whoever runs the report.
- Tests are documentation. A short list of
asserts shows reviewers exactly what the KPI is expected to return.
13. Workplace Task — Refund-Rate Function
Fictional Cedar Lane request: "We need a refund rate we can trust: the refunded value as a percentage of total sold value (paid + refunded)."
- Write the definition and invalid-input rules in words. At minimum, cover:
- an empty list;
- a line with a status other than
"paid"or"refunded"; - a line missing the"qty","price"or"status"field. - Write
refund_rate_pct(transactions)with a docstring and clearValueErrormessages for the cases you defined. - By hand first, calculate the expected refund rate (1 decimal) for:
- the L15 worked-example
transactions; - the L15 workplacedaylist. - Write and run at least five tests: - the two lists above; - an empty list; - an unknown status; - a missing field.
- Write a 3-line note to the owner covering the result for each list, what the function does with bad data, and one limitation (e.g., refunds recorded on a later day).
14. Mini Challenge
Fictional business: Riverside Bikes (from U03 L11) repair jobs (synthetic):
jobs = [
{"job_id": "J1", "status": "done", "hours": 2},
{"job_id": "J2", "status": "done", "hours": 3},
{"job_id": "J3", "status": "cancelled", "hours": 0},
{"job_id": "J4", "status": "done", "hours": 1},
{"job_id": "J5", "status": "done", "hours": 2},
]
- Write
average_repair_hours(jobs)that averages completed jobs only, and raises a clearValueErrorif there are no completed jobs. - Write three tests (normal, all cancelled, empty list) with expected results calculated by hand.
- A colleague suggests
return 0when there are no completed jobs, "so the staffing sheet never crashes". In two sentences, explain the risk.
Submit before feedback. No solution is provided here.
15. Resources
- Required (about 15 min): The Python Tutorial, sections 4.8 "Defining Functions" and 4.9.1 "Default Argument Values". https://docs.python.org/3/tutorial/controlflow.html (Opened and checked 12 Oct 2026.)
- Required (about 15 min): The Python Tutorial, chapter 8, "Errors and Exceptions", sections 8.1–8.4 (syntax errors, exceptions, handling, raising). https://docs.python.org/3/tutorial/errors.html (Opened and checked 12 Oct 2026.)
- Required (about 10 min): PEP 8 – Style Guide for Python Code: the sections on function and variable names and the "Programming Recommendations" on exceptions and return statements. https://peps.python.org/pep-0008/ (Opened and checked 12 Oct 2026.)
- Deeper (optional): PEP 20 – The Zen of Python. https://peps.python.org/pep-0020/
16. Person to Follow / Role Model
Wes McKinney (mapped by D.World for this lesson and L13).
- Verified facts (12 Oct 2026): he states that he wrote Python for Data Analysis, whose 3rd edition is available as an "Open Access" HTML version on his website. The book page also says "In general, the content from this website may not be copied or reproduced", while "The code examples are MIT-licensed". https://wesmckinney.com/book/
- Honest note: his book is about data analysis with libraries such as pandas, not specifically about writing basic functions. D.World maps him here as a long-term role model for practical Python data work.
- Try this: find the licence statements on the book page. In two sentences, explain the difference between "free to read" and "free to copy". Then explain why you should check licences (and test the code) before reusing code you find online or receive from an AI tool.
17. Glossary
| Term | Meaning in this lesson |
|---|---|
| Function | A named, reusable block of code defined with def |
| Parameter / argument | The name in the definition / the value passed in a call |
| Return value | The value a function sends back with return (None if there is no return) |
| Docstring | A short description in triple quotes at the start of a function |
| Default value | A parameter value used when the caller does not supply one |
| Exception | An error raised while the program runs (e.g., ValueError) |
raise |
Deliberately signal an error |
try / except |
Run code and handle a specific expected error |
| Syntax / runtime / type / logic error | Breaks grammar / fails while running / wrong type for an operation / runs but gives a wrong result |
| Traceback | The error report; its last line says what happened |
| Debugging | Finding and fixing the cause of wrong behaviour |
assert |
A statement that stops with an error if a condition is false; used for quick tests |
isinstance(value, type) |
Checks whether a value is of a given type |
18. Reflection
Think of a time a tool or app showed you a misleading number instead of an error (e.g., "0 results" when the search actually failed). How did it affect your decision? How will that change the way you design your own functions?
19. Next Step
U04 finishes with the U04 Exit Assessment, a small Python task you complete and verify yourself, with tests and an AI-use note. Next comes U05 — Problem Solving & Computational Thinking. There you will break ambiguous business questions into steps, write pseudocode, and test solutions before and after coding.
20. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Part A (A1–A6) | Understands return vs print, default values and error kinds |
5 or more of 6 correct |
| Debugging challenge, Part B | Diagnoses a logic error and a runtime error, fixes both causes, tests | Rubric L16-KCB; the fixed function must return 31.0 and raise ValueError for no paid orders |
| AI in Practice (minimal fix) | Requires an explanation and tests; rejects symptom-hiding fixes | Rubric L16-AI |
| Guided and independent practice, workplace function, mini challenge | Writes KPI functions with explicit invalid-input rules and tests | Rubrics L16-GP, L16-IP, L16-WT, L16-MC |
References
- Python Software Foundation. The Python Tutorial, ch. 4. https://docs.python.org/3/tutorial/controlflow.html (opened and checked 12 Oct 2026). Supports: "The keyword
defintroduces a function definition"; functions withoutreturnreturnNone; default argument values. - Python Software Foundation. The Python Tutorial, ch. 8 "Errors and Exceptions". https://docs.python.org/3/tutorial/errors.html (opened and checked 12 Oct 2026). Supports: "syntax errors and exceptions"; "The last line of the error message indicates what happened"; how
tryworks; "The raise statement allows the programmer to force a specified exception to occur." - van Rossum, G., Warsaw, B., & Coghlan, A. PEP 8. https://peps.python.org/pep-0008/ (opened and checked 12 Oct 2026). Supports: specific exceptions rather than a bare
except:; "Be consistent in return statements." - Peters, T. PEP 20 – The Zen of Python. https://peps.python.org/pep-0020/ (opened and checked 12 Oct 2026). Supports: "Errors should never pass silently."
- McKinney, W. Python for Data Analysis, 3rd ed. https://wesmckinney.com/book/ (opened and checked 12 Oct 2026). Supports: open-access statement; content-copying and MIT code-licence statements.
- D.World Curriculum Map v1.0 (L16 row) and Curriculum Bible v1.0. Internal.
L16 — الدوال والأخطاء وتصحيحها
ملف المتعلّم. الإجابات والحلول النموذجية في ملف منفصل خاص بالمدرّس فقط. الإصدار: U04 v1.0 · تاريخ المحتوى: 12 أكتوبر 2026. تقديرات الوقت مبدئية إلى أن تُجرَّب مع المتعلّمين. أمثلة الكود مُختبَرة على Python 3.13 (راجع تقرير الجودة QA الخاص بـ U04). صياغة رسائل الخطأ قد تختلف قليلًا بين إصدارات Python؛ والمهم هو نوع الخطأ (مثل
ValueError).
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | الدوال والأخطاء وتصحيحها |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U04 — أساسيات Python |
| رقم الدرس | L16 |
| المهارات | الدوال (functions)؛ تصحيح الأخطاء (debugging) |
| المستوى | مبتدئ |
| الوقت المتوقع | حوالي ساعتين و5 دقائق (مبدئي) |
| المتطلبات السابقة | L13–L15. وL06–L07 في U02 (هامش الربح الإجمالي، ومعدل التحويل، ومتوسط قيمة الطلب AOV)؛ وL11 في U03 (الإجابة المتوقعة أولًا؛ وأنواع الاختبارات). |
تفصيل الوقت (مبدئي): المفهوم والمثال المحلول 40 دقيقة · التدريب الموجَّه 15 دقيقة · التدريب المستقل 15 دقيقة · اختبار الفهم وتحدي تصحيح الأخطاء 20 دقيقة · الذكاء الاصطناعي في التطبيق والتحقق 10 دقائق · مهمة العمل 20 دقيقة · التحدي القصير 5 دقائق.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تكتب دوال قابلة لإعادة الاستخدام لها مدخلات ومخرجات واضحة وسلوك محدد مع المدخلات غير الصالحة، وأن تشخّص الأخطاء الشائعة: أخطاء الصياغة، وأخطاء وقت التشغيل، وأخطاء الأنواع، والأخطاء المنطقية، وذلك بإصلاح سببها والتأكد من الإصلاح بالاختبارات.
هدف خريطة D.World (بنصّه): Write reusable functions and diagnose common runtime/type/logic errors.
3. لماذا يهمّك هذا؟
في L13–L15 كتبت حسابات تعمل على مجموعة واحدة من القيم. أما الأعمال فتحتاج إلى حساب مؤشر الأداء (KPI) نفسه بشكل صحيح كل يوم، ولكل منتج، وبواسطة أشخاص مختلفين.
الدالة (function) تجمع الحساب مرة واحدة، باسم ومدخلات ومخرج، بحيث يمكن إعادة استخدامه واختباره. والمدخلات الحقيقية تكون خاطئة أحيانًا: صفر طلبات، أو حقول ناقصة، أو نص بدلًا من أرقام. ويجب أن تتعامل الدالة معها بشكل صريح. فمؤشر الأداء الذي يعرض رقمًا مضلِّلًا بصمت أسوأ من مؤشر يقول بوضوح "هذا المُدخل غير صالح". المبدأ الأساسي: أصلِح السبب، وليس العَرَض فقط.
4. المفهوم
تعريف الدالة واستدعاؤها
def gross_profit(revenue, cogs):
"""Return gross profit: revenue minus cost of goods sold."""
return revenue - cogs
september = gross_profit(12000.0, 5000.0)
print(september)
print(gross_profit(13200.0, 6000.0))
7000.0
7200.0
defتبدأ تعريف الدالة، ويليها الاسم ثم المعاملات (parameters) بين قوسين، ثم نقطتان.- جسم الدالة المُزاح لا يُنفَّذ إلا عندما تُستدعى الدالة، مثل
gross_profit(12000.0, 5000.0). والقيم التي تمررها تسمى الوسائط (arguments). - النص الموجود بين ثلاث علامات تنصيص هو نص التوثيق (docstring): وصف قصير لما تفعله الدالة. (وهو هنا يقول: أرجِع مجمل الربح، أي الإيرادات ناقص تكلفة البضاعة المباعة.)
returnتُرسل قيمة عائدة إلى من استدعى الدالة، فيستطيع أن يخزّنها، أو يطبعها، أو يستخدمها في حساب آخر.
الفرق بين return وprint
print تعرض القيمة على الشاشة فقط؛ أما return فتُرجعها لتُستخدم لاحقًا. والدالة التي ليس فيها return تُرجع قيمة مع ذلك: None، ويصفها الدليل التعليمي بأنها "a rather boring one" (قيمة مملّة نوعًا ما). إذا رأيت None حيث كنت تتوقع رقمًا، فابحث عن return ناقصة.
القيم الافتراضية للمعاملات
def shipping_fee(total, threshold=30.0):
if total >= threshold:
return 0.0
return 4.99
print(shipping_fee(35.0))
print(shipping_fee(25.0, 20.0))
0.0
0.0
تُستخدم threshold=30.0 ما لم يمرّر المستدعي قيمة أخرى.
أنواع الأخطاء
يميّز الدليل التعليمي بين "syntax errors and exceptions" (أخطاء الصياغة والاستثناءات). وعند تصحيح الأخطاء يفيد أن نضيف نوعًا ثالثًا: الأخطاء المنطقية.
| النوع | متى تراه | أمثلة | الرسالة المعتادة (السطر الأخير) |
|---|---|---|---|
| خطأ صياغة (Syntax error) | قبل أن يبدأ البرنامج في العمل | نسيان :، أو إزاحة خاطئة، أو = بدلًا من == في شرط |
SyntaxError: ...، IndentationError: ... |
| خطأ وقت التشغيل (Runtime error، استثناء exception) | أثناء التشغيل؛ ويتوقف البرنامج | اسم غير معرَّف؛ القسمة على صفر؛ مفتاح غير موجود | NameError، ZeroDivisionError، KeyError، IndexError |
| خطأ نوع (Type error) (من أشهر أخطاء وقت التشغيل) | عندما تتلقى عملية نوعًا خاطئًا | "Total: " + 5 |
TypeError: can only concatenate str (not "int") to str |
| خطأ منطقي (Logic error) | البرنامج يعمل، لكن النتيجة خاطئة | القسمة على عدد البنود بدلًا من عدد الطلبات؛ حد خاطئ | لا توجد رسالة على الإطلاق |
قراءة رسالة الخطأ: يذكر الدليل التعليمي أن "The last line of the error message indicates what happened" (السطر الأخير من رسالة الخطأ يوضّح ما حدث). ابدأ بالسطر الأخير (نوع الخطأ ووصفه). ثم انظر فوقه لتجد رقم السطر الذي حدث فيه.
روتين لتصحيح الأخطاء
- أعِد إنتاج المشكلة: شغّل البرنامج مرة أخرى بالمُدخل نفسه وتأكد أنك ترى المشكلة نفسها.
- اقرأ: السطر الأخير من الرسالة (أو، في حالة الخطأ المنطقي، قارن النتيجة الفعلية بالمتوقعة).
- حدّد المكان: اعثر على السطر؛ وتتبّع القيم قبله مباشرة (جداول التتبّع من L15).
- افترض السبب: لماذا تكون القيمة خاطئة عند هذه النقطة؟
- أصلِح السبب بأصغر تغيير يعالجه، لا بإخفاء العَرَض.
- اختبر: أعِد تشغيل الحالة التي فشلت، إضافة إلى حالات عادية وحالات طرفية، لتتأكد أن شيئًا آخر لم يتعطل.
التعامل الصريح مع المدخلات غير الصالحة
قرّر بالكلمات ماذا يجب أن تفعل الدالة مع المُدخل السيئ. ثم اجعل الكود يفعل ذلك بالضبط.
- أطلِق خطأً واضحًا باستخدام
raise ValueError("message")أوraise TypeError("message"). ويوضّح الدليل التعليمي أن "The raise statement allows the programmer to force a specified exception to occur." (جملة raise تتيح للمبرمج أن يفرض حدوث استثناء محدد). ويعبّر PEP 20 عن ذلك بـ "Errors should never pass silently." (يجب ألا تمر الأخطاء بصمت أبدًا). - لا تُرجع رقمًا مضلِّلًا بصمت. مثلًا، إرجاع
0كمتوسط لقيمة الطلب عندما لا توجد طلبات يجعل "لا توجد بيانات" تبدو كأنها "القيمة صفر". isinstance(value, int)تفحص نوع القيمة وتعطيTrueأوFalse. وisinstance(value, (int, float))تقبل أيًّا من النوعين. (ملاحظة: Python يعاملTrue/Falseأيضًا كنوع منint؛ وهذا الدرس لا يتعامل مع هذه الحالة.)- يستطيع المستدعي أن يتعامل مع خطأ متوقع باستخدام
try/except، مع ذكر نوع الاستثناء المحدد. وينصح PEP 8 بـ: "mention specific exceptions whenever possible instead of using a bareexcept:clause" (اذكر الاستثناءات المحددة كلما أمكن بدلًا من استخدامexcept:وحدها).
try:
value = int("five")
except ValueError:
print("Quantity must be a whole number")
Quantity must be a whole number
اختبارات سريعة باستخدام assert
assert condition لا تفعل شيئًا إذا كان الشرط True، وتوقف البرنامج بخطأ AssertionError إذا كان False. وهي طريقة بسيطة لتسجيل اختبار مع إجابته المتوقعة. وستتعمق U05 أكثر في الاختبارات.
assert gross_profit(12000.0, 5000.0) == 7000.0
assert gross_profit(0.0, 0.0) == 0.0
print("All gross_profit tests passed")
All gross_profit tests passed
تجنّب استخدام == مع نتائج القسمة ذات الأرقام العشرية الطويلة (L14). وقارن القيم بعد تقريبها بدلًا من ذلك، مثل round(x, 1) == 58.3.
5. مثال محلول
مؤشر الأداء: متوسط قيمة الطلب (L07 في U02): AOV = الإيرادات ÷ عدد الطلبات.
الخطوة 1: قرّر السلوك بالكلمات.
| المُدخل | السلوك المتوقع |
|---|---|
| الإيرادات 124.0، والطلبات 4 | أرجِع 31.0 |
| الطلبات = 0 | أطلِق ValueError: متوسط قيمة الطلب غير معرَّف عندما لا توجد طلبات. لا تُرجع 0 |
| الطلبات سالبة، أو الإيرادات سالبة | أطلِق ValueError |
الإيرادات مكتوبة كنص، مثل "124"، أو الطلبات ليست عددًا صحيحًا |
أطلِق TypeError |
الخطوة 2: الكود. (Run)
def average_order_value(revenue, orders):
"""Return average order value (revenue / number of orders).
Raises TypeError for non-numeric input and ValueError for
orders <= 0 or negative revenue.
"""
if not isinstance(revenue, (int, float)) or not isinstance(orders, int):
raise TypeError("revenue must be a number and orders a whole number")
if orders <= 0:
raise ValueError("orders must be greater than 0")
if revenue < 0:
raise ValueError("revenue cannot be negative")
return revenue / orders
print(average_order_value(124.0, 4))
print(average_order_value(15000.0, 600))
try:
average_order_value(100.0, 0)
except ValueError as error:
print("Invalid input:", error)
try:
average_order_value("124", 4)
except TypeError as error:
print("Invalid input:", error)
31.0
25.0
Invalid input: orders must be greater than 0
Invalid input: revenue must be a number and orders a whole number
الخطوة 3: راجع.
- 124 ÷ 4 = 31 ✔ (L11 في U03).
- 15,000 ÷ 600 = 25 ✔ (L07 في U02).
- كلا المُدخلين غير الصالحين ينتج رسالة واضحة ومحددة، بدلًا من توقف البرنامج بخطأ
ZeroDivisionErrorأو ظهور 0 مضلِّل.
6. شرح بصري
arguments ──► average_order_value(revenue, orders) ──► return value
(124.0, 4) │ 31.0
├─ wrong type? ──► raise TypeError
├─ orders <= 0? ──► raise ValueError
├─ revenue < 0? ──► raise ValueError
└─ otherwise ──► revenue / orders
DEBUG LOOP: reproduce → read last line → locate → find CAUSE → fix → test (old + new cases)
وصف الرسم: الوسيطان 124.0 و4 يدخلان إلى الدالة average_order_value، فتُرجع 31.0. وداخل الدالة تُجرى الفحوصات بالترتيب: إذا كان المُدخل من نوع خاطئ، تُطلق TypeError؛ وإذا كانت الطلبات صفرًا أو أقل، تُطلق ValueError؛ وإذا كانت الإيرادات سالبة، تُطلق ValueError؛ وفي غير ذلك تُرجع الإيرادات مقسومة على الطلبات. وفي الأسفل حلقة تصحيح الأخطاء بخطواتها الست: أعِد إنتاج المشكلة، واقرأ السطر الأخير، وحدّد المكان، واعثر على السبب، وأصلِح، واختبر الحالات القديمة والجديدة معًا.
7. تدريب موجَّه
(Run.) اكتب الدالة gross_margin_pct(revenue, cogs)، التي تُرجع هامش الربح الإجمالي كنسبة مئوية (L06 في U02).
- السلوك بالكلمات أولًا:
- يجب أن تكون الإيرادات أكبر من 0 ← وإلا أطلِق
ValueError؛ - الهامش السالب (التكاليف أعلى من الإيرادات) مسموح به، لأنه معلومة حقيقية.
- يجب أن تكون الإيرادات أكبر من 0 ← وإلا أطلِق
- أكمل القالب (لا يمكن تشغيله كما هو):
def gross_margin_pct(revenue, cogs):
"""Return gross margin as a percentage of revenue."""
if revenue ___ 0:
raise ValueError(___)
return (revenue - cogs) / ___ * 100
- الإجابات المتوقعة يدويًا (مقرّبة إلى رقم عشري واحد)، ثم اختبر باستخدام
assert round(...) == ...أوprint:- (12000.0, 5000.0)؛
- (13200.0, 6000.0)؛
- (100.0, 120.0)؛
- (0.0, 50.0)، باستخدام
try/except ValueError.
- اشرح لماذا يكون الشرط
revenue <= 0وليسrevenue < 0.
8. تدريب مستقل
(Run.) اكتب الدالة conversion_rate_pct(orders, sessions) (L07 في U02: الطلبات ÷ الجلسات × 100).
- اكتب قواعد المدخلات غير الصالحة بالكلمات أولًا. وغطِّ على الأقل:
- عدد جلسات يساوي 0 أو أقل؛
- عدد طلبات سالب؛
- عدد طلبات أكبر من عدد الجلسات (وهذا مستحيل في هذا المسار البسيط).
- نفّذ الدالة مع رسائل
ValueErrorواضحة. - اختبر على الأقل هذه الحالات، بعد أن تحسب النتائج المتوقعة يدويًا أولًا:
- (600, 20000)؛
- (550, 22000)؛
- (0, 100)؛
- (10, 0)؛
- (30, 20).
- سجّل كل اختبار بهذه الصيغة: المُدخل ← المتوقع ← الفعلي ← نجح/فشل.
لا تُعرض هنا إجابة نموذجية.
9. اختبار الفهم — مهمة دالة + تحدي تصحيح الأخطاء
الجزء A — توقّع وصنّف.
A1. ماذا يطبع هذا الكود؟
def double(price):
print(price * 2)
result = double(10)
print(result)
- A)
20ثم20 - B)
20ثمNone - C)
Noneثم20 - D)
20فقط
A2. ماذا يطبع هذا الكود؟
def shipping_fee(total, threshold=30.0):
if total >= threshold:
return 0.0
return 4.99
print(shipping_fee(30.0), shipping_fee(25.0, 20.0))
- A)
0.0 4.99 - B)
4.99 0.0 - C)
0.0 0.0 - D)
4.99 4.99
A3. توقف برنامج برسالة NameError: name 'revenue' is not defined. ما السبب الأرجح؟
- A) استُخدم
revenueقبل أن تُسنَد إليه قيمة، أو كُتب اسمه بشكل خاطئ. - B)
revenueمن النوع float بدلًا من int. - C) القسمة على صفر
- D) مفتاح قاموس غير موجود
A4. أي خطأ يُطلقه print("Total: " + 5)؟
- A)
ValueError - B)
NameError - C)
SyntaxError - D)
TypeError
A5. أي خطأ يُطلقه int("five")؟
- A)
TypeError - B)
ValueError - C)
ZeroDivisionError - D) لا يوجد خطأ؛ تُرجع 5
A6. دالة لحساب معدل التحويل تعمل دون أي خطأ، لكنها تُرجع 30.0 بينما النتيجة الصحيحة 3.0. ما نوع هذا الخطأ؟
- A) خطأ صياغة
- B) خطأ وقت التشغيل
- C) خطأ منطقي
- D) ليس خطأً، لأن البرنامج لم يتوقف
الجزء B — تحدي تصحيح الأخطاء (Run). يجب أن تُرجع هذه الدالة متوسط قيمة الطلب للبنود المدفوعة في قائمة معاملات. أي: الإيرادات المدفوعة ÷ عدد الطلبات المدفوعة المختلفة (L11 في U03). ومع transactions من المثال المحلول في L15، النتيجة المتوقعة هي 31.0. وإذا لم توجد بنود مدفوعة، يجب أن تُطلق ValueError("no paid orders").
def aov_from_transactions(transactions):
paid_revenue = 0.0
paid_lines = 0
for line in transactions:
if line["status"] == "paid":
paid_revenue = paid_revenue + line["qty"] * line["price"]
paid_lines = paid_lines + 1
return paid_revenue / paid_lines
- الصق قائمة
transactionsمن L15 فوق الدالة. وشغّلprint(aov_from_transactions(transactions)). وسجّل القيمة الفعلية والمتوقعة. - شغّل
aov_from_transactions([]). وسجّل السطر الأخير من رسالة الخطأ. - لـ كل مشكلة، اذكر نوع الخطأ (القسم 4) وسببه.
- أصلِح السببين معًا. (تلميح: مهمة العمل في L15، الطلبات المختلفة.)
- اكتب ثلاثة اختبارات على الأقل:
- الحالة العادية (31.0)؛
- قائمة فارغة (المتوقع
ValueError)؛ - قائمة كل بنودها مستردّة (المتوقع
ValueError).
شغّلها وسجّل النتائج.
10. الذكاء الاصطناعي في التطبيق
اطلب من الذكاء الاصطناعي أصغر إصلاح ممكن، لكن اشترط شرحًا واختبارًا قبل أن تقبله.
- أعِد إنتاج المشكلة أولًا (Run):
def conversion_rate_pct(orders, sessions):
return orders / sessions * 100
print(conversion_rate_pct(600, 20000))
print(conversion_rate_pct(5, 0))
سجّل المخرجات والسطر الأخير من رسالة الخطأ.
- اسأل مساعد ذكاء اصطناعي (كود مصطنع فقط):
"This Python function crashes when sessions is 0 (code and error below). Suggest the minimal fix. Explain why it fixes the cause rather than hiding the symptom, and give 3 tests (input → expected result) that I can run to confirm it. Do not add libraries. """ (paste the function and the error's last line) """
وبالعربية: "دالة Python هذه تتوقف عندما تكون sessions تساوي 0 (الكود والخطأ بالأسفل). اقترح أصغر إصلاح ممكن. واشرح لماذا يعالج السبب بدلًا من إخفاء العَرَض، وأعطني 3 اختبارات (المُدخل ← النتيجة المتوقعة) أستطيع تشغيلها للتأكد. لا تُضِف مكتبات. """ (الصق الدالة والسطر الأخير من رسالة الخطأ) """"
- قيّم الاقتراح قبل أن تقبله. من الاقتراحات الشائعة
if sessions == 0: return 0. واسأل:- هل إرجاع 0 يقول الحقيقة؟
- هل ستضلّل لوحة متابعة تعرض "معدل تحويل 0%" ليوم لا توجد فيه بيانات أحدًا ما؟
- قرّر ونفّذ نسختك الخاصة بقاعدة صريحة (مثلًا: أطلِق
ValueErrorبرسالة واضحة). ثم شغّل اختبارات الذكاء الاصطناعي واختباراتك أنت، بما فيها الحالات العادية، وحالة صفر جلسات، والحالات السالبة. - اكتب ملاحظة من 2–3 أسطر: ما الذي قبلته، وما الذي رفضته، ولماذا.
11. التحقق من مخرجات الذكاء الاصطناعي
- الشرح شرط: لا تقبل إصلاحًا لا تستطيع أن تشرحه سطرًا سطرًا.
- العَرَض مقابل السبب: هل يجعل الإصلاح رسالة الخطأ تختفي بينما يترك نتيجة خاطئة أو مضلِّلة؟ إذا كان كذلك، فارفضه.
- الاختبارات شرط: شغّل الحالة التي فشلت، وحالة عادية، وحالة طرفية أخرى على الأقل. وسجّل المتوقع (يدويًا) مقابل الفعلي.
- أصغر تغيير: ارفض إعادة الكتابة التي لا علاقة لها بالمشكلة، أو إعادة تسمية المتغيرات، أو المكتبات الجديدة التي لم تطلبها.
- الاتساق: تأكد أن الدالة تتصرف بالطريقة نفسها مع المدخلات غير الصالحة المتشابهة (PEP 8: "Be consistent in return statements"، أي كن متسقًا في جمل الإرجاع).
- التراخيص والأمانة: إذا أعدت استخدام كود من الذكاء الاصطناعي أو من موقع على الإنترنت، فراجع ترخيص كود الموقع، واختبر الكود، واذكر استخدامه في ملاحظة استخدام الذكاء الاصطناعي.
- الخصوصية: كود وبيانات مصطنعة فقط. لا تلصق أبدًا بيانات عملاء حقيقية، أو بيانات دخول، أو كود شركة غير مسموح لك بمشاركته.
12. منظور الأعمال
أنشئ دالة تحسب مؤشر أداء للتجارة الإلكترونية وتتعامل مع المدخلات غير الصالحة. دالة مؤشر الأداء هي جزء صغير من سياسة الأعمال:
- تعريف واحد في كل مكان. كل من يستدعي
average_order_valueيحصل على المعادلة نفسها (بطاقة تعريف مؤشر الأداء في U02). - المُدخل غير الصالح سؤال أعمال. ماذا يجب أن يعرض التقرير عندما لا توجد طلبات؟ "غير متاح" غالبًا أصدق من 0. اتفق على ذلك مع صاحب المؤشر.
- رسائل الخطأ الواضحة توفّر الوقت على من يشغّل التقرير.
- الاختبارات توثيق. قائمة قصيرة من جمل
assertتوضّح للمراجعين بالضبط ما المتوقع أن يُرجعه المؤشر.
13. مهمة عمل — دالة معدل الاسترداد
طلب من متجر Cedar Lane الخيالي: "نحتاج إلى معدل استرداد نستطيع أن نثق فيه: القيمة المستردّة كنسبة مئوية من إجمالي القيمة المباعة (المدفوع + المستردّ)."
- اكتب التعريف وقواعد المدخلات غير الصالحة بالكلمات. وغطِّ على الأقل:
- قائمة فارغة؛
- بندًا حالته غير
"paid"وغير"refunded"؛ - بندًا ينقصه الحقل
"qty"أو"price"أو"status".
- اكتب الدالة
refund_rate_pct(transactions)مع نص توثيق (docstring) ورسائلValueErrorواضحة للحالات التي حددتها. - يدويًا أولًا، احسب معدل الاسترداد المتوقع (برقم عشري واحد) لـ:
transactionsمن المثال المحلول في L15؛- قائمة
dayمن مهمة العمل في L15.
- اكتب وشغّل خمسة اختبارات على الأقل:
- القائمتين السابقتين؛
- قائمة فارغة؛
- حالة غير معروفة؛
- حقلًا ناقصًا.
- اكتب ملاحظة من 3 أسطر لصاحب المتجر تذكر فيها النتيجة لكل قائمة، وماذا تفعل الدالة مع البيانات السيئة، وقيدًا واحدًا (مثلًا: عمليات استرداد سُجّلت في يوم لاحق).
14. تحدٍّ قصير
نشاط تجاري خيالي: أعمال الصيانة في Riverside Bikes (من L11 في U03) (بيانات مصطنعة):
jobs = [
{"job_id": "J1", "status": "done", "hours": 2},
{"job_id": "J2", "status": "done", "hours": 3},
{"job_id": "J3", "status": "cancelled", "hours": 0},
{"job_id": "J4", "status": "done", "hours": 1},
{"job_id": "J5", "status": "done", "hours": 2},
]
- اكتب الدالة
average_repair_hours(jobs)التي تحسب المتوسط للأعمال المكتملة فقط، وتُطلقValueErrorواضحًا إذا لم توجد أعمال مكتملة. - اكتب ثلاثة اختبارات (حالة عادية، وكل الأعمال ملغاة، وقائمة فارغة) مع نتائج متوقعة محسوبة يدويًا.
- يقترح زميل استخدام
return 0عندما لا توجد أعمال مكتملة، "حتى لا يتعطل جدول توزيع العاملين أبدًا". اشرح الخطر في جملتين.
سلّم إجابتك قبل الحصول على التعليقات. لا يوجد حل هنا.
15. المصادر
- مطلوب (حوالي 15 دقيقة): The Python Tutorial، القسمان 4.8 "Defining Functions" و4.9.1 "Default Argument Values". https://docs.python.org/3/tutorial/controlflow.html (فُتح وروجع في 12 أكتوبر 2026.)
- مطلوب (حوالي 15 دقيقة): The Python Tutorial، الفصل 8، "Errors and Exceptions"، الأقسام 8.1–8.4 (أخطاء الصياغة، والاستثناءات، والتعامل معها، وإطلاقها). https://docs.python.org/3/tutorial/errors.html (فُتح وروجع في 12 أكتوبر 2026.)
- مطلوب (حوالي 10 دقائق): PEP 8 – Style Guide for Python Code: الأجزاء الخاصة بأسماء الدوال والمتغيرات، و"Programming Recommendations" الخاصة بالاستثناءات وجمل الإرجاع. https://peps.python.org/pep-0008/ (فُتح وروجع في 12 أكتوبر 2026.)
- للتعمّق (اختياري): PEP 20 – The Zen of Python. https://peps.python.org/pep-0020/
16. شخصية تتابعها / قدوة
Wes McKinney (اختارته D.World لهذا الدرس ولـ L13).
- حقائق موثّقة (12 أكتوبر 2026): يذكر أنه كتب Python for Data Analysis، وطبعته الثالثة متاحة كنسخة HTML مفتوحة الوصول ("Open Access") على موقعه. وتقول صفحة الكتاب أيضًا: "In general, the content from this website may not be copied or reproduced" (بشكل عام، لا يجوز نسخ محتوى هذا الموقع أو إعادة إنتاجه)، بينما "The code examples are MIT-licensed" (أمثلة الكود مرخّصة بترخيص MIT). https://wesmckinney.com/book/
- ملاحظة صريحة: كتابه عن تحليل البيانات باستخدام مكتبات مثل pandas، وليس تحديدًا عن كتابة الدوال الأساسية. وتضعه D.World هنا كقدوة طويلة المدى للعمل العملي على البيانات باستخدام Python.
- جرّب هذا: ابحث عن عبارات الترخيص في صفحة الكتاب. واشرح في جملتين الفرق بين "مجاني للقراءة" و"مجاني للنسخ". ثم اشرح لماذا يجب أن تراجع التراخيص (وتختبر الكود) قبل أن تعيد استخدام كود وجدته على الإنترنت أو حصلت عليه من أداة ذكاء اصطناعي.
17. المصطلحات
| المصطلح | معناه في هذا الدرس |
|---|---|
| الدالة (Function) | كتلة كود لها اسم وقابلة لإعادة الاستخدام، تُعرَّف باستخدام def |
| المعامل / الوسيط (Parameter / argument) | الاسم في تعريف الدالة / القيمة التي تُمرَّر عند الاستدعاء |
| القيمة المُرجَعة (Return value) | القيمة التي تُرسلها الدالة باستخدام return (وNone إذا لم توجد return) |
| نص التوثيق (Docstring) | وصف قصير بين ثلاث علامات تنصيص في بداية الدالة |
| القيمة الافتراضية (Default value) | قيمة للمعامل تُستخدم عندما لا يمرّر المستدعي قيمة |
| الاستثناء (Exception) | خطأ يُطلَق أثناء تشغيل البرنامج (مثل ValueError) |
raise |
الإشارة إلى خطأ عن قصد |
try / except |
تشغيل كود والتعامل مع خطأ متوقع محدد |
| خطأ صياغة / وقت التشغيل / نوع / منطقي | يخالف قواعد اللغة / يفشل أثناء التشغيل / نوع خاطئ لعملية / يعمل لكنه يعطي نتيجة خاطئة |
| تقرير التتبّع (Traceback) | تقرير الخطأ؛ وسطره الأخير يقول ما حدث |
| تصحيح الأخطاء (Debugging) | العثور على سبب السلوك الخاطئ وإصلاحه |
assert |
جملة توقف البرنامج بخطأ إذا كان الشرط خاطئًا؛ وتُستخدم للاختبارات السريعة |
isinstance(value, type) |
تفحص هل القيمة من نوع معيّن |
18. تأمّل
فكّر في مرة عرضت لك فيها أداة أو تطبيق رقمًا مضلِّلًا بدلًا من رسالة خطأ (مثلًا: "0 نتائج" بينما البحث نفسه فشل). كيف أثّر ذلك في قرارك؟ وكيف سيغيّر ذلك طريقة تصميمك لدوالك؟
19. الخطوة التالية
تنتهي U04 بـ تقييم نهاية الوحدة U04، وهو مهمة Python صغيرة تنجزها وتتحقق منها بنفسك، مع اختبارات وملاحظة عن استخدام الذكاء الاصطناعي. وبعدها تأتي U05 — حل المشكلات والتفكير الحاسوبي. وهناك ستقسّم أسئلة الأعمال الغامضة إلى خطوات، وتكتب الكود الوصفي (pseudocode)، وتختبر الحلول قبل كتابة الكود وبعدها.
20. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| الجزء A (A1–A6) | فهم الفرق بين return وprint، والقيم الافتراضية، وأنواع الأخطاء |
5 إجابات صحيحة أو أكثر من 6 |
| تحدي تصحيح الأخطاء، الجزء B | تشخيص خطأ منطقي وخطأ وقت التشغيل، وإصلاح السببين، والاختبار | معايير L16-KCB؛ ويجب أن تُرجع الدالة بعد الإصلاح 31.0 وتُطلق ValueError عندما لا توجد طلبات مدفوعة |
| الذكاء الاصطناعي في التطبيق (أصغر إصلاح) | اشتراط الشرح والاختبارات؛ ورفض الإصلاحات التي تُخفي العَرَض | معايير L16-AI |
| التدريب الموجَّه والمستقل، ودالة مهمة العمل، والتحدي القصير | كتابة دوال لمؤشرات الأداء بقواعد صريحة للمدخلات غير الصالحة، مع اختبارات | معايير L16-GP وL16-IP وL16-WT وL16-MC |
المراجع
- Python Software Foundation. The Python Tutorial، الفصل 4. https://docs.python.org/3/tutorial/controlflow.html (فُتح وروجع في 12 أكتوبر 2026). يدعم: "The keyword
defintroduces a function definition"؛ وأن الدوال التي ليس فيهاreturnتُرجعNone؛ والقيم الافتراضية للوسائط. - Python Software Foundation. The Python Tutorial، الفصل 8 "Errors and Exceptions". https://docs.python.org/3/tutorial/errors.html (فُتح وروجع في 12 أكتوبر 2026). يدعم: "syntax errors and exceptions"؛ و"The last line of the error message indicates what happened"؛ وطريقة عمل
try؛ و"The raise statement allows the programmer to force a specified exception to occur." - van Rossum, G., Warsaw, B., & Coghlan, A. PEP 8. https://peps.python.org/pep-0008/ (فُتح وروجع في 12 أكتوبر 2026). يدعم: الاستثناءات المحددة بدلًا من
except:وحدها؛ و"Be consistent in return statements." - Peters, T. PEP 20 – The Zen of Python. https://peps.python.org/pep-0020/ (فُتح وروجع في 12 أكتوبر 2026). يدعم: "Errors should never pass silently."
- McKinney, W. Python for Data Analysis، الطبعة الثالثة. https://wesmckinney.com/book/ (فُتح وروجع في 12 أكتوبر 2026). يدعم: عبارة الوصول المفتوح؛ وعبارتي نسخ المحتوى وترخيص MIT للكود.
- D.World Curriculum Map v1.0 (صف L16) وCurriculum Bible v1.0. وثائق داخلية.
U04 Exit Assessment — Python Fundamentalsتقييم نهاية الوحدة U04 — أساسيات Python Freeمجاني
U04 Exit Assessment — Python Fundamentals
Learner-facing instructions and rubric. The reference solution, standard tests and marking notes are in the instructor-only file (05). Version: U04 v1.0 · 12 October 2026.
Unit exit criterion (D.World map): Complete a Python mini-task without copying an unverified solution.
Estimated time: 75 minutes (provisional).
Format: one Python script (.py) plus a short written verification report of 250–450 words. Tables are allowed, and code does not count toward the word limit.
You need: Python 3, installed on your computer or provided by your instructor. Standard Python only: no packages, accounts or internet required.
Allowed: - your U04 notes; - the Python Tutorial; - an AI assistant, only as described in Part E. Any AI help must be read, run, tested and declared.
The case (fictional business, synthetic data)
Harbor Tea Co. is a fictional online tea shop. The owner wants a small, trustworthy calculator for order totals:
Pricing policy (exact wording):
1. Subtotal = sum of qty × unit_price for all lines in the order.
2. Discount:
- subtotal of 60 USD or more → 10% off;
- otherwise, members get 5% off;
- otherwise no discount.
3. Shipping: free if the amount after discount is 40 USD or more; otherwise 5.00 USD.
4. Total = amount after discount + shipping, rounded to 2 decimals. Compare the 60 and 40 thresholds using the unrounded amounts.
5. Invalid orders must not produce a number:
- an order with no lines;
- a line whose qty is not a whole number (int), or is 0 or less;
- a line whose unit_price is negative.
Each of these must raise a ValueError with a clear message.
An order is a list of dictionaries, for example:
order = [
{"item": "Green tea", "qty": 2, "unit_price": 9.0},
{"item": "Teaware", "qty": 1, "unit_price": 25.0},
]
What to submit
Part A: code. Write a function order_total(lines, is_member) that applies the policy and returns the total. Your solution must use:
- clearly named variables of appropriate types;
- at least one loop over the lines;
- if/elif/else for the rules;
- explicit invalid-input handling (raise ValueError(...)).
Add a docstring and short comments stating the policy.
Part B: expected results by hand. Before running your code, calculate by hand the expected total for at least three test orders that you design. They must include:
- at least one boundary case (exactly at 60 or exactly at 40);
- at least one member case;
- at least one invalid case (expected: ValueError).
Show your working: subtotal → discount → after discount → shipping → total.
Part C: tests and comparison. Run your function on each test order. Record the results in a table: input → expected (by hand) → actual (code) → pass/fail. If a test failed, explain what was wrong (the code or your hand calculation) and what you changed.
Part D: explain your code. In your own words, explain three lines or blocks of your code: 1. the line that applies the discount rule; 2. the line that decides shipping; 3. one invalid-input check.
For each, say why it matches the policy.
Part E: AI-use and verification note (2–4 lines, required even if AI was not used). Say: - whether you used AI and for what; - what you checked (tests, hand calculations, reading the code); - what you changed or rejected; - what remained your own judgment.
If you did not use AI, write "No AI used", followed by how you verified your code.
Rubric (each criterion 0–2)
| # | Criterion | 2 — Meets | 1 — Partly | 0 — Not yet |
|---|---|---|---|---|
| C1 | Policy correctness (Part A) | Discount, shipping and total correct for all standard cases, including both boundaries and members | One rule or boundary wrong | Several rules wrong, or the function does not run |
| C2 | Python structure and readability (Part A) | Function with parameters and return; loop over lines; appropriate types; PEP 8-style names; docstring and comments state the policy |
Works, but structure or naming unclear (e.g., print instead of return, no docstring) |
No function or no loop; unreadable |
| C3 | Invalid-input handling (Part A) | All three invalid cases raise ValueError with clear messages; no misleading number returned |
One case missing or unclear | Invalid input returns a number or crashes with an unrelated error |
| C4 | Expected results and tests (Parts B–C) | At least three hand-worked tests, including a boundary, a member and an invalid case; table complete; failures explained | Fewer than three tests, or a required case type missing, or working not shown | No hand-calculated expectations, or tests not run |
| C5 | Code explanation (Part D) | Three explanations, accurate and linked to the policy wording | Explanations partly accurate or generic | Missing, or contradicts the code |
| C6 | AI-use and verification note (Part E) | Complete and specific (what was used, checked, changed, judged) | Present but vague | Missing |
Gate conditions (all must be met to pass)
- G1 — Independently verified: Part B contains hand-calculated expected results for at least three tests, and Part C shows that they were actually compared with code output.
- G2 — Correct on standard tests: the function gives the correct result on at least 6 of the 7 instructor standard tests, including both boundary tests.
- G3 — Own, explained work: the Part D explanations match the submitted code, and the AI-use note is present. Unexplained, unverified copied code fails this gate.
Result
- PASS: a total of 9 or more out of 12, no criterion scored 0, all gates met.
- REVISE: anything else. Feedback names the criteria to improve, and one resubmission is allowed.
Why this threshold? It requires solid performance overall (75%) while allowing small weaknesses. The gates protect the core of this unit: independent verification, correct handling of business-rule boundaries, and owning your code. The threshold is an instructional design choice, not statistically validated, and should be reviewed after learner pilot data.
This assessment checks understanding of U04 concepts. It is not a certification and makes no claim about job readiness.
تقييم نهاية الوحدة U04 — أساسيات Python
تعليمات ومعايير تقييم موجّهة للمتعلّم. الحل المرجعي والاختبارات القياسية وملاحظات التصحيح موجودة في ملف المدرّس فقط (05). الإصدار: U04 v1.0 · 12 أكتوبر 2026.
معيار إنهاء الوحدة (خريطة D.World): أنجز مهمة Python صغيرة دون نسخ حل لم تتحقق منه.
الوقت المتوقع: 75 دقيقة (مبدئي).
الشكل: سكربت Python واحد (.py) بالإضافة إلى تقرير تحقق مكتوب قصير من 250 إلى 450 كلمة. يُسمح بالجداول، والكود لا يُحسب ضمن عدد الكلمات.
ما تحتاجه: Python 3، مثبّتًا على جهازك أو يوفّره لك المدرّس. Python القياسي فقط: لا تحتاج إلى حزم أو حسابات أو اتصال بالإنترنت.
المسموح:
- ملاحظاتك من U04؛
- The Python Tutorial؛
- مساعد ذكاء اصطناعي، فقط بالطريقة الموضحة في الجزء E. وأي مساعدة من الذكاء الاصطناعي يجب أن تُقرأ، وتُشغَّل، وتُختبر، ويُصرَّح بها.
الحالة (نشاط خيالي، بيانات مصطنعة)
Harbor Tea Co. متجر شاي خيالي على الإنترنت. يريد صاحب المتجر حاسبة صغيرة يمكن الوثوق بها لحساب إجمالي الطلبات:
سياسة التسعير (بالصياغة الدقيقة):
- المجموع الفرعي (Subtotal) = مجموع
qty × unit_priceلكل البنود في الطلب. - الخصم:
- مجموع فرعي 60 دولارًا أو أكثر ← خصم 10%؛
- وإلا، يحصل الأعضاء على خصم 5%؛
- وإلا فلا خصم.
- الشحن: مجاني إذا كان المبلغ بعد الخصم 40 دولارًا أو أكثر؛ وإلا فتكلفته 5.00 دولار.
- الإجمالي (Total) = المبلغ بعد الخصم + الشحن، مقرّبًا إلى رقمين عشريين. وقارن بالحدين 60 و40 باستخدام المبالغ غير المقرَّبة.
- الطلبات غير الصالحة يجب ألا تنتج رقمًا:
- طلب بلا بنود؛
- بند قيمة
qtyفيه ليست عددًا صحيحًا (int)، أو تساوي 0 أو أقل؛ - بند قيمة
unit_priceفيه سالبة.
كل حالة من هذه يجب أن تُطلق ValueError برسالة واضحة.
الطلب عبارة عن قائمة من القواميس، مثلًا:
order = [
{"item": "Green tea", "qty": 2, "unit_price": 9.0},
{"item": "Teaware", "qty": 1, "unit_price": 25.0},
]
ما الذي تسلّمه؟
الجزء A: الكود. اكتب دالة order_total(lines, is_member) تطبّق السياسة وتُرجع الإجمالي. ويجب أن يستخدم حلّك:
- متغيرات بأسماء واضحة وأنواع مناسبة؛
- حلقة تكرارية واحدة على الأقل تمر على البنود؛
if/elif/elseلتطبيق القواعد؛- تعاملًا صريحًا مع المدخلات غير الصالحة (
raise ValueError(...)).
أضف نص توثيق (docstring) وتعليقات قصيرة تذكر السياسة.
الجزء B: النتائج المتوقعة يدويًا. قبل تشغيل الكود، احسب يدويًا الإجمالي المتوقع لـ ثلاثة طلبات اختبار على الأقل تصمّمها أنت. ويجب أن تشمل:
- حالة حدّية واحدة على الأقل (60 بالضبط أو 40 بالضبط)؛
- حالة عضو واحدة على الأقل؛
- حالة غير صالحة واحدة على الأقل (المتوقع:
ValueError).
اعرض خطوات الحل: المجموع الفرعي ← الخصم ← المبلغ بعد الخصم ← الشحن ← الإجمالي.
الجزء C: الاختبارات والمقارنة. شغّل دالتك على كل طلب اختبار. وسجّل النتائج في جدول: المُدخل ← المتوقع (يدويًا) ← الفعلي (من الكود) ← نجح/فشل. وإذا فشل اختبار، فاشرح ما الذي كان خاطئًا (الكود أم حسابك اليدوي) وما الذي غيّرته.
الجزء D: اشرح كودك. بكلماتك أنت، اشرح ثلاثة أسطر أو كتل من كودك:
- السطر الذي يطبّق قاعدة الخصم؛
- السطر الذي يقرّر الشحن؛
- فحصًا واحدًا للمدخلات غير الصالحة.
ولكل منها، وضّح لماذا يطابق السياسة.
الجزء E: ملاحظة استخدام الذكاء الاصطناعي والتحقق (2–4 أسطر، وهي مطلوبة حتى لو لم تستخدم الذكاء الاصطناعي). اذكر:
- هل استخدمت الذكاء الاصطناعي، وفي ماذا؛
- ما الذي راجعته (الاختبارات، والحسابات اليدوية، وقراءة الكود)؛
- ما الذي غيّرته أو رفضته؛
- ما الذي بقي حكمك أنت.
إذا لم تستخدم الذكاء الاصطناعي، فاكتب "No AI used" (لم أستخدم الذكاء الاصطناعي)، ثم اذكر كيف تحققت من كودك.
معايير التقييم (كل معيار من 0 إلى 2)
| # | المعيار | 2 — يحقق المطلوب | 1 — يحققه جزئيًا | 0 — لم يحققه بعد |
|---|---|---|---|---|
| C1 | صحة تطبيق السياسة (الجزء A) | الخصم والشحن والإجمالي صحيحة في كل الحالات القياسية، بما فيها الحدّان والأعضاء | قاعدة واحدة أو حد واحد خاطئ | عدة قواعد خاطئة، أو الدالة لا تعمل |
| C2 | بنية كود Python ووضوحه (الجزء A) | دالة لها معاملات وreturn؛ وحلقة تمر على البنود؛ وأنواع مناسبة؛ وأسماء على نمط PEP 8؛ ونص توثيق وتعليقات تذكر السياسة |
يعمل، لكن البنية أو التسمية غير واضحة (مثلًا print بدلًا من return، أو لا يوجد نص توثيق) |
لا توجد دالة أو لا توجد حلقة؛ أو الكود غير مقروء |
| C3 | التعامل مع المدخلات غير الصالحة (الجزء A) | الحالات الثلاث غير الصالحة كلها تُطلق ValueError برسائل واضحة؛ ولا يُرجَع أي رقم مضلِّل |
حالة واحدة ناقصة أو غير واضحة | المُدخل غير الصالح يُرجع رقمًا أو يوقف البرنامج بخطأ لا علاقة له بالمشكلة |
| C4 | النتائج المتوقعة والاختبارات (الجزءان B–C) | ثلاثة اختبارات محسوبة يدويًا على الأقل، منها حالة حدّية وحالة عضو وحالة غير صالحة؛ والجدول كامل؛ وحالات الفشل مشروحة | أقل من ثلاثة اختبارات، أو نوع حالة مطلوب ناقص، أو خطوات الحل غير معروضة | لا توجد نتائج متوقعة محسوبة يدويًا، أو الاختبارات لم تُشغَّل |
| C5 | شرح الكود (الجزء D) | ثلاثة شروح دقيقة ومرتبطة بصياغة السياسة | الشروح دقيقة جزئيًا أو عامة | غير موجودة، أو تتعارض مع الكود |
| C6 | ملاحظة استخدام الذكاء الاصطناعي والتحقق (الجزء E) | كاملة ومحددة (ما الذي استُخدم، وروجع، وغُيّر، وما الحكم الشخصي) | موجودة لكنها مبهمة | غير موجودة |
شروط أساسية (يجب تحقيقها كلها للنجاح)
- G1 — تحقق مستقل: يحتوي الجزء B على نتائج متوقعة محسوبة يدويًا لثلاثة اختبارات على الأقل، ويُظهر الجزء C أنها قورنت فعلًا بمخرجات الكود.
- G2 — صحيح في الاختبارات القياسية: تعطي الدالة النتيجة الصحيحة في 6 من 7 اختبارات قياسية على الأقل من اختبارات المدرّس، بما فيها اختبارا الحدّين معًا.
- G3 — عمل خاص بك ومشروح: شروح الجزء D تطابق الكود المسلَّم، وملاحظة استخدام الذكاء الاصطناعي موجودة. والكود المنسوخ غير المشروح وغير المتحقَّق منه يُسقط هذا الشرط.
النتيجة
- PASS (ناجح): مجموع 9 أو أكثر من 12، ولا يوجد معيار حصل على 0، وكل الشروط الأساسية متحققة.
- REVISE (يحتاج تعديلًا): أي نتيجة أخرى. تحدد الملاحظات المعايير التي تحتاج إلى تحسين؛ ويُسمح بإعادة التسليم مرة واحدة.
لماذا هذا الحد؟ لأنه يتطلب أداءً قويًا في المجمل (75%) مع السماح بنقاط ضعف صغيرة. والشروط الأساسية تحمي جوهر هذه الوحدة: التحقق المستقل، والتعامل الصحيح مع حدود قواعد الأعمال، وتحمّل مسؤولية كودك. هذا الحد حكم تصميمي، وليس مُثبتًا إحصائيًا، ويجب مراجعته بعد توفر بيانات التجربة مع المتعلّمين.
هذا التقييم يقيس فهمك لمفاهيم U04. وهو ليس شهادة معتمدة، ولا يدّعي أي شيء عن جاهزيتك للعمل.
U05 · Problem Solving & Computational Thinkingحل المشكلات والتفكير الحاسوبي
Stage 1المرحلة 1Free: every lesson in this unit.
مجاني: كل دروس هذه الوحدة.
L17 · Decompose a Business ProblemL17 · تفكيك مشكلة أعمال Freeمجاني
L17 — Decompose a Business Problem
Learner file. Answers and model solutions are in a separate instructor-only file. Version: U05 v1.0 · Content date: 12 October 2026. Time estimates are provisional planning guides for a self-paced path, not waiting periods. Code examples were tested with Python 3.13 (see the U05 QA report).
1. Lesson Identity
| Field | Value |
|---|---|
| Title | Decompose a Business Problem |
| Stage | Stage 1 — Foundations |
| Unit | U05 — Problem Solving & Computational Thinking |
| Lesson ID | L17 |
| Skills | Problem decomposition; assumptions |
| Difficulty | Beginner |
| Estimated time | About 1 hour 45 minutes (provisional) |
| Prerequisites | U02 (especially L08: KPIs and diagnostic questions; revenue = sessions × conversion × AOV), U03 (prompting, verification, privacy), U04 (Python basics). |
Time breakdown (provisional): concept and worked example, 35 min · guided practice, 15 min · independent practice, 15 min · knowledge check, 10 min · AI in Practice and Verification, 15 min · workplace task, 10 min · mini challenge, 5 min.
2. Learning Objective
By the end of this lesson, you will be able to break an ambiguous business question into smaller analytical questions. You will also label each statement as a fact, requirement, assumption, estimate or unknown, and plan the measures, data, order of work and success checks before any coding starts.
D.World map objective (verbatim): Break an ambiguous business question into smaller analytical questions and assumptions.
3. Why It Matters
Business questions usually arrive vague: - "Revenue dropped. What's going on?" - "Should we stock more planners?"
If you start coding straight away, you may answer the wrong question very precisely. Good analysts first turn a vague question into smaller questions that data can answer, and they write down what they are assuming.
AWS's guidance on data science starts the same way: "Begin by defining business problems … and have a clear idea of the business value to be gained." It also warns: "Some business problems don't need ML and simple business rules can do a much better job." This unit is about choosing the simplest adequate method and thinking before coding. Key principle: business question → analytical questions.
4. Concept
The D.World decomposition method (9 stages)
| Stage | Question to ask | Example output |
|---|---|---|
| 1. Clarify the decision | Who will decide what, and when? | "The owner decides by Friday whether to spend more on ads or fix the checkout." |
| 2. Knowns and unknowns | What do we already know? What don't we know? | Known: monthly sessions, orders, revenue. Unknown: traffic by source |
| 3. Assumptions | What are we treating as true without proof? | "December tracking worked the same way as November." |
| 4. Constraints | Time, data, tools, privacy, budget? | "2 hours; order export and analytics summary only; no personal data." |
| 5. Sub-questions | Which smaller questions add up to the answer? | "Did fewer people visit? Did fewer visitors buy? Did they spend less per order?" |
| 6. Measures and data | Which metric answers each sub-question, from which data? | Sessions (analytics); conversion = orders ÷ sessions; AOV = revenue ÷ orders |
| 7. Order the tasks | What must be done first? | Check data quality → calculate the formula parts → drill into the part that changed |
| 8. Success checks | How will we know the analysis is right and useful? | "The parts multiply back to actual revenue; each finding names its evidence." |
| 9. Then implement | Only now: calculations, code, charts | A small Python script (U04 skills) |
Five kinds of statement: don't mix them up
| Kind | Meaning | Example |
|---|---|---|
| Fact | Observed and recorded; can be checked | "December revenue was 13,200 USD." (synthetic) |
| Requirement | Something the answer must satisfy, set by the decision owner | "The answer is needed by Friday." |
| Assumption | Treated as true for now; may be wrong; must be stated | "No tracking change happened in December." |
| Estimate | A number that is calculated or guessed, with uncertainty | "About 3,000 fewer visits next month if nothing changes." |
| Unknown | Information you do not have yet | "Why did visitors buy less?" |
A common mistake is to let an assumption quietly become a "fact" in the final report. Keep the labels until you have evidence.
A decision tree of diagnostic questions
A decision tree (here, a tree of questions) splits a big question into branches. Each branch is a smaller question, and each leaf is a question you can answer with specific data. In U02 L08 you learned that revenue = sessions × conversion × AOV. That formula gives a natural first split.
Choose the simplest adequate method
Most beginner business questions need arithmetic, comparisons and clear thinking, not machine learning or AI. Ask: "What is the simplest calculation that would answer this sub-question well enough for the decision?"
5. Worked Example
Synthetic data, fictional Cedar Lane (from U02 L08). The owner says: "Revenue dropped in December. What's going on?"
| Metric | November | December |
|---|---|---|
| Sessions | 25,000 | 22,000 |
| Orders | 750 | 550 |
| Revenue (USD) | 18,000 | 13,200 |
1. Decision: the owner must choose, by Friday, between spending more on advertising (to bring visitors) and improving the website checkout (to convert visitors).
2. Knowns / unknowns: the three monthly totals above are known. Traffic sources, funnel steps and product-level sales are unknown, or not yet looked at.
3. Assumptions (stated, not proven): - A1: November and December were tracked the same way. - A2: revenue is after discounts, as in U02. - A3: the drop is not just a seasonal pattern. (Could be wrong: there is no December data from last year.)
4. Constraints: 2 hours; order export and analytics summary only; no customer personal data.
5. Sub-questions:
Revenue dropped (18,000 → 13,200)
├── Q1 Did fewer people visit? → sessions
│ └── Q1a Which traffic source fell? → sessions by source
├── Q2 Did a smaller share of visitors buy? → conversion = orders ÷ sessions
│ └── Q2a At which funnel step? → step conversion rates
├── Q3 Did buyers spend less per order? → AOV = revenue ÷ orders
└── Q0 Is the data right? → tracking/definition changes (check first)
6–7. Measures and order: - Check Q0 first. - Then calculate the parts: - sessions −12% (25,000 → 22,000); - conversion 3.0% → 2.5%; - AOV 24 → 24 USD (unchanged). - Q3 is answered: AOV did not change. Drill into Q1 and Q2 next.
8. Success check: - The parts multiply back to actual revenue: 22,000 × 2.5% × 24 = 13,200 ✔. - Each finding names its evidence, and each cause stays labelled a hypothesis until it is tested.
9. Implement: a few lines of Python (U04) can calculate the parts for any two months:
months = {
"Nov": {"sessions": 25000, "orders": 750, "revenue": 18000.0},
"Dec": {"sessions": 22000, "orders": 550, "revenue": 13200.0},
}
for name, m in months.items():
conversion_pct = m["orders"] / m["sessions"] * 100
aov = m["revenue"] / m["orders"]
check = m["sessions"] * (conversion_pct / 100) * aov
print(name, round(conversion_pct, 2), round(aov, 2), round(check, 2))
Nov 3.0 24.0 18000.0
Dec 2.5 24.0 13200.0
The code comes last. The thinking above decided what to calculate and why.
6. Visual Explanation
AMBIGUOUS QUESTION ──► DECISION ──► KNOWN / UNKNOWN ──► ASSUMPTIONS & CONSTRAINTS
│
SUB-QUESTIONS (tree)
├─ Q0 data right?
├─ Q1 visits? → sessions
├─ Q2 buying? → conversion
└─ Q3 spend? → AOV
│
MEASURES & DATA ─► ORDER ─► SUCCESS CHECKS ─► CODE
Alt text: A flow from left to right. An ambiguous question leads to the decision, then to known and unknown information, then to assumptions and constraints. These feed a tree of sub-questions: - Q0: is the data right? - Q1: did visits fall? (measured by sessions) - Q2: did buying fall? (measured by conversion) - Q3: did spending per order fall? (measured by AOV)
The tree then leads to measures and data, the order of tasks, success checks, and finally code.
7. Guided Practice
Fictional Cedar Lane. The owner asks: "Are our discounts working?" Cedar Lane gives 10% off orders of 100 USD or more (U04 L14).
Work through stages 1–8 using the table template below. Hints are given; answers are not.
| Stage | Your answer |
|---|---|
| 1. Decision | (Hint: keep, change, or stop the discount?) |
| 2. Knowns / unknowns | |
| 3. Assumptions (at least 2) | (Hint: would those customers have spent 100+ anyway?) |
| 4. Constraints | |
| 5. Sub-questions (at least 4, as a tree) | (Hint: think volume, order size, margin, customer behaviour.) |
| 6. Measure + data for each sub-question | |
| 7. Order of tasks | |
| 8. Success checks |
Then label each of your assumptions as one you could test with data, or one you cannot test with the data available.
8. Independent Practice
Fictional Cedar Lane. The buyer asks: "Should we stock more planners for January?"
- Complete all eight planning stages.
- Write at least five statements about this case and label each as fact, requirement, assumption, estimate or unknown.
- Identify one sub-question that does not need any code, and explain why.
- Name the simplest method that would answer the main question well enough. Explain why a more complex method (e.g., an ML forecast) is not needed at this stage.
No model answer is shown here.
9. Knowledge Check — Case Decomposition
Part A — Label each statement (synthetic Cedar Lane case). Choose: Fact, Requirement, Assumption, Estimate or Unknown.
| # | Statement |
|---|---|
| 1 | "December had 22,000 sessions." |
| 2 | "The owner needs a recommendation before Friday's supplier call." |
| 3 | "We treat December's tracking as identical to November's." |
| 4 | "If conversion returns to 3.0%, December-like traffic would bring about 15,840 USD." |
| 5 | "We don't know which traffic source fell." |
| 6 | "The analysis must not use customers' personal data." |
Part B — Choose the best answer.
B1. A manager asks, "Why are customers unhappy?" What is the best first step? - A) Build a machine-learning model on all customer emails. - B) Clarify the decision and what "unhappy" means (complaints? refunds? low ratings?) and how it will be measured. - C) Ask an AI tool for the answer. - D) Start coding a dashboard with every available metric.
B2. Which sub-question is answerable with data as written? - A) "Is our website bad?" - B) "Why do people dislike us?" - C) "What share of December sessions reached the checkout page, compared with November?" - D) "What should we do?"
B3. An analyst writes in the final report: "Revenue fell because of the holidays." The data shows only monthly totals. What is wrong? - A) Nothing. Holidays always reduce sales. - B) The report should not mention December. - C) The analyst should have used more decimal places. - D) A hypothesis (or assumption) is presented as a fact, without evidence.
B4. Following the AWS guidance, which approach is most appropriate for "flag orders above 1,000 USD for manual review"?
- A) A simple business rule (if total > 1000)
- B) A deep-learning model
- C) A generative-AI chatbot
- D) A survey of customers
Part C — Case decomposition (rubric-marked). Fictional Riverside Bikes: "We're losing money on repairs." Produce a one-page plan with: - the decision and the decision owner; - knowns and unknowns; - three labelled assumptions; - constraints; - a question tree with at least five sub-questions; - a measure and data source for each sub-question; - the order of tasks; - two success checks.
10. AI in Practice
Ask AI for 3 decomposition strategies and compare their assumptions.
- Make your own plan first. Spend 5 minutes on a quick question tree for: "Revenue dropped this month at a small online store" (no data needed).
- Prompt (synthetic, no real company data):
"Act as an analytics mentor. A small fictional online store says 'revenue dropped this month'. Propose three different strategies to decompose this problem into smaller analytical questions (for example: by formula components, by customer segments, by time/events). For each strategy, list the sub-questions, the data needed, and every assumption the strategy makes. Do not state causes as facts."
- Compare the three strategies and your own in a table: - sub-questions; - data needed; - assumptions; - what each strategy would miss.
- Choose one strategy, or a combination, for the Cedar Lane case under the Section 5 constraints (2 hours, no personal data), and justify it in 3 sentences.
11. AI Verification
- Assumptions audit: for each AI strategy, check that every assumption is stated. Add any hidden ones; a common one is "the data is correct".
- Answerable? Mark each AI sub-question answerable with available data, needs new data or not answerable as written. Rewrite vague ones.
- No causes as facts: reject any statement such as "this is caused by…" that has no evidence. Relabel it as a hypothesis.
- Constraints: remove steps that need data you do not have, or that would require sharing personal data.
- Simplest adequate method: reject suggestions to use ML or complex tools when arithmetic answers the question.
- You own the plan: the AI suggests; the decision owner and you decide. Record what you accepted and rejected.
- Privacy: never paste real customer, revenue or employee data into an AI tool to "make it realistic".
12. Business Lens
Turn "revenue dropped" into a decision tree of diagnostic questions. A good tree:
- starts from the decision the owner faces (what will change depending on the answer);
- uses a formula where one exists (revenue = sessions × conversion × AOV), so branches are complete and do not overlap;
- checks data first (Q0), because a tracking change can look like a business problem;
- ends in questions with a named metric and data source;
- keeps causes as hypotheses until tested.
This saves time and money. The team investigates the branch that actually moved, instead of guessing.
13. Workplace Task — One-Page Diagnostic Plan
Fictional Cedar Lane (Section 5 data). Write a one-page plan (150–250 words + a tree) for the owner covering:
- the decision and deadline;
- a decision tree with Q0–Q3 and at least one further level under the branch that changed;
- the calculated values for each formula part (sessions change %, conversion both months, AOV both months) and the success check;
- three labelled assumptions and one constraint;
- a recommendation of which branch to investigate next, and why. This is a next step, not a final cause.
14. Mini Challenge
Fictional business: Greenleaf Plants. The owner asks: "Should we start offering delivery?"
- Identify the decision and three things that must be true for delivery to be a good idea. Write them as labelled assumptions.
- Build a question tree with at least four sub-questions, each with a measure.
- Mark one sub-question you could answer from existing sales data, and one that would need new data (e.g., a small customer survey).
Submit before feedback. No solution is provided here.
15. Resources
- Required (about 15 min): AWS Cloud Adoption Framework, Business Perspective, Data science. Read the "Start" recommendations on defining the business problem and value, and on measurable outcomes. Note the line "Some business problems don't need ML and simple business rules can do a much better job." https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-science.html (Opened and checked 12 Oct 2026. The page states it is "for historical reference only".)
- Recommended: your U02 L08 notes on KPI trees and diagnostic questions.
- Deeper (optional): ONET OnLine, Data Scientists summary. Look at the task "Identify business problems or management objectives that can be addressed through data analysis." This is a US occupational description. https://www.onetonline.org/link/summary/15-2051.00 (Opened and checked 12 Oct 2026.)*
16. Person to Follow / Role Model
Cassie Kozyrkov (mapped by D.World; the map's area is "Decision intelligence / data-informed decisions").
- Verified fact (12 Oct 2026): Fortune (6 September 2023) reported that she served as Google's chief decision scientist. It said she helped pioneer the field of decision intelligence, and that she was leaving Google to work independently. https://fortune.com/2023/09/06/google-chief-decision-scientist-cassie-kozyrkove-why-left-company-helping-business-leaders-choices-ai
- Not verified: her own website (https://www.kozyr.com/, linked in the D.World map) could not be opened by our checking tool, so no details from it are used here. Check it yourself for her current work.
- Why D.World recommends her: her focus on decision quality, meaning starting from the decision rather than the data, matches stage 1 of this lesson.
- Try this: find one of her talks or articles on decision-making. Note one idea about defining the decision before looking at data, and compare it with stage 1 of this lesson.
17. Glossary
| Term | Meaning in this lesson |
|---|---|
| Decomposition | Breaking a big, vague question into smaller answerable questions |
| Decision owner | The person or role who will act on the answer |
| Fact | An observed, recorded, checkable statement |
| Requirement | A condition the answer must meet, set by the decision owner |
| Assumption | Something treated as true for now, stated openly, that may be wrong |
| Estimate | A calculated or judged number with uncertainty |
| Unknown | Information not yet available |
| Constraint | A limit on time, data, tools, privacy or budget |
| Question tree / decision tree of questions | A diagram that splits a question into sub-questions |
| Success check | A test that shows the analysis is correct and useful |
| Simplest adequate method | The least complex approach that answers the question well enough for the decision |
18. Reflection
Think of the last time you jumped straight into solving a problem (at work, in study or at home). Which of the nine stages did you skip? What would have changed if you had written your assumptions down first?
19. Next Step
Once a problem is decomposed, each sub-question needs a clear procedure. In L18 — Algorithms, Pseudocode & Clear Thinking, you will write ordered steps and pseudocode, for example to calculate daily sales and flag unusual days, before writing any Python.
20. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Part A (6 statements) | Distinguishes fact, requirement, assumption, estimate, unknown | 5 or more of 6 correct |
| Part B (B1–B4) | Clarifies before acting; recognises answerable questions; avoids causes stated as facts; chooses a simple method | 3 or more of 4 correct; B3 must be correct |
| Part C (Riverside case decomposition) | Full decomposition plan | Rubric L17-KCC |
| AI in Practice | Compares AI strategies and audits their assumptions | Rubric L17-AI |
| Guided and independent practice, workplace plan, mini challenge | Applies the 9-stage method | Rubrics L17-GP, L17-IP, L17-WT, L17-MC |
References
- Amazon Web Services. AWS CAF Business Perspective — Data science. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-science.html (opened and checked 12 Oct 2026; historical-reference notice). Supports: "Begin by defining business problems … and have a clear idea of the business value to be gained"; "Establish an observable and quantifiable performance metric"; "Some business problems don't need ML and simple business rules can do a much better job."
- ONET OnLine. 15-2051.00 – Data Scientists* (summary; US). https://www.onetonline.org/link/summary/15-2051.00 (opened and checked 12 Oct 2026; site updated 6 Oct 2026). Supports: the task "Identify business problems or management objectives that can be addressed through data analysis."
- Fortune, 6 Sep 2023, on Cassie Kozyrkov leaving Google. https://fortune.com/2023/09/06/google-chief-decision-scientist-cassie-kozyrkove-why-left-company-helping-business-leaders-choices-ai (opened and checked 12 Oct 2026).
- The 9-stage decomposition method and the five statement types are D.World teaching tools, not an external standard.
- D.World Curriculum Map v1.0 (L17 row) and Curriculum Bible v1.0. Internal.
L17 — تفكيك مشكلة أعمال
ملف المتعلّم. الإجابات والحلول النموذجية في ملف منفصل خاص بالمدرّس فقط. الإصدار: U05 v1.0 · تاريخ المحتوى: 12 أكتوبر 2026. تقديرات الوقت إرشادات مبدئية للتخطيط في مسار ذاتي الوتيرة، وليست فترات انتظار. أمثلة الكود مُختبَرة على Python 3.13 (راجع تقرير الجودة QA الخاص بـ U05).
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | تفكيك مشكلة أعمال |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U05 — حل المشكلات والتفكير الحاسوبي |
| رقم الدرس | L17 |
| المهارات | تفكيك المشكلات (problem decomposition)؛ الافتراضات |
| المستوى | مبتدئ |
| الوقت المتوقع | حوالي ساعة و45 دقيقة (مبدئي) |
| المتطلبات السابقة | U02 (وخاصة L08: مؤشرات الأداء والأسئلة التشخيصية؛ الإيرادات = الجلسات × معدل التحويل × متوسط قيمة الطلب AOV)، وU03 (كتابة الطلبات، والتحقق، والخصوصية)، وU04 (أساسيات Python). |
تفصيل الوقت (مبدئي): المفهوم والمثال المحلول 35 دقيقة · التدريب الموجَّه 15 دقيقة · التدريب المستقل 15 دقيقة · اختبار الفهم 10 دقائق · الذكاء الاصطناعي في التطبيق والتحقق 15 دقيقة · مهمة العمل 10 دقائق · التحدي القصير 5 دقائق.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تقسّم سؤال أعمال غامضًا إلى أسئلة تحليلية أصغر. وستستطيع أيضًا أن تصنّف كل عبارة على أنها حقيقة، أو متطلب، أو افتراض، أو تقدير، أو مجهول، وأن تخطّط للمقاييس والبيانات وترتيب العمل وفحوصات النجاح قبل أن تبدأ أي برمجة.
هدف خريطة D.World (بنصّه): Break an ambiguous business question into smaller analytical questions and assumptions.
3. لماذا يهمّك هذا؟
أسئلة الأعمال تصل عادةً غامضة:
- "الإيرادات انخفضت. ماذا يحدث؟"
- "هل نزيد مخزون الأجندات؟"
إذا بدأت البرمجة فورًا، فقد تجيب عن السؤال الخطأ بدقة شديدة. المحللون الجيدون يحوّلون السؤال الغامض أولًا إلى أسئلة أصغر تستطيع البيانات أن تجيب عنها، ويكتبون ما يفترضونه.
وإرشادات AWS في علم البيانات تبدأ بالطريقة نفسها: "Begin by defining business problems … and have a clear idea of the business value to be gained." (ابدأ بتعريف مشكلات الأعمال… وكوِّن فكرة واضحة عن القيمة التي ستحققها للأعمال). وتحذّر أيضًا: "Some business problems don't need ML and simple business rules can do a much better job." (بعض مشكلات الأعمال لا تحتاج إلى تعلم الآلة، والقواعد البسيطة قد تؤدي المهمة أفضل بكثير). هذه الوحدة تدور حول اختيار أبسط طريقة كافية، والتفكير قبل البرمجة. المبدأ الأساسي: سؤال الأعمال ← أسئلة تحليلية.
4. المفهوم
طريقة D.World للتفكيك (9 مراحل)
| المرحلة | السؤال الذي تطرحه | مثال على الناتج |
|---|---|---|
| 1. وضّح القرار | من سيقرر ماذا، ومتى؟ | "صاحب المتجر سيقرر قبل الجمعة: هل يزيد الإنفاق على الإعلانات أم يصلح صفحة الدفع." |
| 2. المعلوم والمجهول | ماذا نعرف بالفعل؟ وماذا لا نعرف؟ | المعلوم: الجلسات والطلبات والإيرادات الشهرية. المجهول: الزيارات حسب المصدر |
| 3. الافتراضات | ما الذي نعامله على أنه صحيح دون دليل؟ | "التتبّع في ديسمبر عمل بالطريقة نفسها التي عمل بها في نوفمبر." |
| 4. القيود | الوقت، والبيانات، والأدوات، والخصوصية، والميزانية؟ | "ساعتان؛ ملف الطلبات المُصدَّر وملخص التحليلات فقط؛ لا بيانات شخصية." |
| 5. الأسئلة الفرعية | ما الأسئلة الأصغر التي تُكوِّن معًا الإجابة؟ | "هل زار الموقعَ عددٌ أقل؟ هل اشترى عدد أقل من الزوار؟ هل أنفقوا أقل في كل طلب؟" |
| 6. المقاييس والبيانات | أي مقياس يجيب عن كل سؤال فرعي، ومن أي بيانات؟ | الجلسات (التحليلات)؛ معدل التحويل = الطلبات ÷ الجلسات؛ AOV = الإيرادات ÷ الطلبات |
| 7. رتّب المهام | ما الذي يجب إنجازه أولًا؟ | افحص جودة البيانات ← احسب أجزاء المعادلة ← تعمّق في الجزء الذي تغيّر |
| 8. فحوصات النجاح | كيف سنعرف أن التحليل صحيح ومفيد؟ | "حاصل ضرب الأجزاء يعيدنا إلى الإيرادات الفعلية؛ وكل نتيجة تذكر دليلها." |
| 9. ثم التنفيذ | الآن فقط: الحسابات، والكود، والرسوم البيانية | سكربت Python صغير (مهارات U04) |
خمسة أنواع من العبارات: لا تخلط بينها
| النوع | المعنى | مثال |
|---|---|---|
| حقيقة (Fact) | شيء رُصد وسُجّل؛ ويمكن التحقق منه | "إيرادات ديسمبر كانت 13,200 دولار." (بيانات مصطنعة) |
| متطلب (Requirement) | شيء يجب أن تحققه الإجابة، ويحدده صاحب القرار | "نحتاج الإجابة قبل الجمعة." |
| افتراض (Assumption) | شيء نعامله على أنه صحيح الآن؛ وقد يكون خاطئًا؛ ويجب التصريح به | "لم يحدث أي تغيير في التتبّع خلال ديسمبر." |
| تقدير (Estimate) | رقم محسوب أو مُخمَّن، وفيه قدر من عدم اليقين | "حوالي 3,000 زيارة أقل في الشهر القادم إذا لم يتغير شيء." |
| مجهول (Unknown) | معلومة لا تملكها بعد | "لماذا اشترى الزوار أقل؟" |
من الأخطاء الشائعة أن يتحول افتراض بهدوء إلى "حقيقة" في التقرير النهائي. احتفظ بالتصنيفات إلى أن يتوفر لديك دليل.
شجرة قرار من الأسئلة التشخيصية
شجرة القرار (decision tree؛ وهي هنا شجرة من الأسئلة) تقسّم سؤالًا كبيرًا إلى فروع. كل فرع سؤال أصغر، وكل ورقة في نهاية الشجرة سؤال تستطيع أن تجيب عنه ببيانات محددة. وفي L08 من U02 تعلمت أن الإيرادات = الجلسات × معدل التحويل × AOV. وهذه المعادلة تعطيك تقسيمًا أوليًا طبيعيًا.
اختر أبسط طريقة كافية
معظم أسئلة الأعمال للمبتدئين تحتاج إلى حساب ومقارنات وتفكير واضح، وليس إلى تعلم الآلة أو الذكاء الاصطناعي. اسأل: "ما أبسط حساب يجيب عن هذا السؤال الفرعي بدرجة كافية لاتخاذ القرار؟"
5. مثال محلول
بيانات مصطنعة، لمتجر Cedar Lane الخيالي (من L08 في U02). يقول صاحب المتجر: "الإيرادات انخفضت في ديسمبر. ماذا يحدث؟"
| المقياس | نوفمبر | ديسمبر |
|---|---|---|
| الجلسات (Sessions) | 25,000 | 22,000 |
| الطلبات (Orders) | 750 | 550 |
| الإيرادات (USD) | 18,000 | 13,200 |
1. القرار: يجب أن يختار صاحب المتجر، قبل الجمعة، بين زيادة الإنفاق على الإعلانات (لجلب زوار) وتحسين صفحة الدفع في الموقع (لتحويل الزوار إلى مشترين).
2. المعلوم والمجهول: المجاميع الشهرية الثلاثة أعلاه معلومة. أما مصادر الزيارات، وخطوات مسار الشراء (funnel)، والمبيعات على مستوى المنتج، فمجهولة أو لم يُنظر فيها بعد.
3. الافتراضات (مُصرَّح بها، وغير مُثبتة):
- A1: نوفمبر وديسمبر تُتُبِّعا بالطريقة نفسها.
- A2: الإيرادات بعد الخصومات، كما في U02.
- A3: الانخفاض ليس مجرد نمط موسمي. (قد يكون هذا خاطئًا: لا توجد بيانات لديسمبر من العام الماضي.)
4. القيود: ساعتان؛ ملف الطلبات المُصدَّر وملخص التحليلات فقط؛ لا بيانات شخصية للعملاء.
5. الأسئلة الفرعية:
Revenue dropped (18,000 → 13,200)
├── Q1 Did fewer people visit? → sessions
│ └── Q1a Which traffic source fell? → sessions by source
├── Q2 Did a smaller share of visitors buy? → conversion = orders ÷ sessions
│ └── Q2a At which funnel step? → step conversion rates
├── Q3 Did buyers spend less per order? → AOV = revenue ÷ orders
└── Q0 Is the data right? → tracking/definition changes (check first)
بالعربية: Q1 هل زار الموقعَ عددٌ أقل؟ (الجلسات)، وتحته Q1a أي مصدر زيارات انخفض؟ · Q2 هل اشترت نسبة أقل من الزوار؟ (معدل التحويل)، وتحته Q2a عند أي خطوة في مسار الشراء؟ · Q3 هل أنفق المشترون أقل في كل طلب؟ (AOV) · Q0 هل البيانات صحيحة؟ (تغييرات التتبّع أو التعريفات، ويُفحص أولًا).
6–7. المقاييس والترتيب:
- افحص Q0 أولًا.
- ثم احسب الأجزاء:
- الجلسات −12% (25,000 ← 22,000)؛
- معدل التحويل 3.0% ← 2.5%؛
- AOV من 24 إلى 24 دولارًا (لم يتغير).
- تمت الإجابة عن Q3: متوسط قيمة الطلب لم يتغير. تعمّق بعد ذلك في Q1 وQ2.
8. فحص النجاح:
- حاصل ضرب الأجزاء يعيدنا إلى الإيرادات الفعلية: 22,000 × 2.5% × 24 = 13,200 ✔.
- كل نتيجة تذكر دليلها، وكل سبب يبقى مصنّفًا فرضية إلى أن يُختبر.
9. التنفيذ: بضعة أسطر من Python (U04) تستطيع حساب الأجزاء لأي شهرين:
months = {
"Nov": {"sessions": 25000, "orders": 750, "revenue": 18000.0},
"Dec": {"sessions": 22000, "orders": 550, "revenue": 13200.0},
}
for name, m in months.items():
conversion_pct = m["orders"] / m["sessions"] * 100
aov = m["revenue"] / m["orders"]
check = m["sessions"] * (conversion_pct / 100) * aov
print(name, round(conversion_pct, 2), round(aov, 2), round(check, 2))
Nov 3.0 24.0 18000.0
Dec 2.5 24.0 13200.0
الكود يأتي في النهاية. التفكير السابق هو الذي حدّد ماذا نحسب ولماذا.
6. شرح بصري
AMBIGUOUS QUESTION ──► DECISION ──► KNOWN / UNKNOWN ──► ASSUMPTIONS & CONSTRAINTS
│
SUB-QUESTIONS (tree)
├─ Q0 data right?
├─ Q1 visits? → sessions
├─ Q2 buying? → conversion
└─ Q3 spend? → AOV
│
MEASURES & DATA ─► ORDER ─► SUCCESS CHECKS ─► CODE
وصف الرسم: تدفّق من اليسار إلى اليمين. السؤال الغامض يقود إلى القرار، ثم إلى المعلومات المعلومة والمجهولة، ثم إلى الافتراضات والقيود. وهذه كلها تغذّي شجرة من الأسئلة الفرعية:
- Q0: هل البيانات صحيحة؟
- Q1: هل انخفضت الزيارات؟ (تُقاس بالجلسات)
- Q2: هل انخفض الشراء؟ (يُقاس بمعدل التحويل)
- Q3: هل انخفض الإنفاق في كل طلب؟ (يُقاس بمتوسط قيمة الطلب AOV)
ثم تقود الشجرة إلى المقاييس والبيانات، وترتيب المهام، وفحوصات النجاح، وأخيرًا الكود.
7. تدريب موجَّه
متجر Cedar Lane الخيالي. يسأل صاحب المتجر: "هل الخصومات التي نقدمها ناجحة؟" يقدّم Cedar Lane خصم 10% على الطلبات التي قيمتها 100 دولار أو أكثر (L14 في U04).
اعمل على المراحل من 1 إلى 8 باستخدام قالب الجدول بالأسفل. التلميحات موجودة؛ والإجابات غير موجودة.
| المرحلة | إجابتك |
|---|---|
| 1. القرار | (تلميح: هل نُبقي الخصم، أم نغيّره، أم نوقفه؟) |
| 2. المعلوم والمجهول | |
| 3. الافتراضات (2 على الأقل) | (تلميح: هل كان هؤلاء العملاء سينفقون 100 أو أكثر على أي حال؟) |
| 4. القيود | |
| 5. الأسئلة الفرعية (4 على الأقل، في صورة شجرة) | (تلميح: فكّر في الحجم، وقيمة الطلب، والهامش، وسلوك العملاء.) |
| 6. مقياس + بيانات لكل سؤال فرعي | |
| 7. ترتيب المهام | |
| 8. فحوصات النجاح |
ثم صنّف كل افتراض من افتراضاتك: هل هو افتراض تستطيع اختباره بالبيانات، أم افتراض لا تستطيع اختباره بالبيانات المتاحة؟
8. تدريب مستقل
متجر Cedar Lane الخيالي. يسأل مسؤول المشتريات: "هل نزيد مخزون الأجندات لشهر يناير؟"
- أكمل مراحل التخطيط الثماني كلها.
- اكتب خمس عبارات على الأقل عن هذه الحالة، وصنّف كلًّا منها: حقيقة، أو متطلب، أو افتراض، أو تقدير، أو مجهول.
- حدّد سؤالًا فرعيًا واحدًا لا يحتاج إلى أي كود، واشرح السبب.
- اذكر أبسط طريقة تجيب عن السؤال الرئيسي بدرجة كافية. واشرح لماذا لا نحتاج في هذه المرحلة إلى طريقة أعقد (مثل التنبؤ بتعلم الآلة ML).
لا تُعرض هنا إجابة نموذجية.
9. اختبار الفهم — تفكيك حالة
الجزء A — صنّف كل عبارة (حالة Cedar Lane مصطنعة). اختر: حقيقة، أو متطلب، أو افتراض، أو تقدير، أو مجهول.
| # | العبارة |
|---|---|
| 1 | "شهر ديسمبر كان فيه 22,000 جلسة." |
| 2 | "يحتاج صاحب المتجر إلى توصية قبل مكالمة المورّد يوم الجمعة." |
| 3 | "نعامل التتبّع في ديسمبر على أنه مطابق للتتبّع في نوفمبر." |
| 4 | "إذا عاد معدل التحويل إلى 3.0%، فإن زيارات بحجم زيارات ديسمبر ستجلب حوالي 15,840 دولارًا." |
| 5 | "لا نعرف أي مصدر زيارات انخفض." |
| 6 | "يجب ألا يستخدم التحليل البيانات الشخصية للعملاء." |
الجزء B — اختر أفضل إجابة.
B1. يسأل مدير: "لماذا العملاء غير راضين؟" ما أفضل خطوة أولى؟
- A) بناء نموذج تعلم آلة على كل رسائل البريد الإلكتروني من العملاء.
- B) توضيح القرار، وما المقصود بـ "غير راضين" (شكاوى؟ طلبات استرداد؟ تقييمات منخفضة؟)، وكيف سيُقاس.
- C) سؤال أداة ذكاء اصطناعي عن الإجابة.
- D) البدء في برمجة لوحة متابعة فيها كل المقاييس المتاحة.
B2. أي سؤال فرعي يمكن الإجابة عنه بالبيانات بصيغته المكتوبة؟
- A) "هل موقعنا سيئ؟"
- B) "لماذا لا يحبنا الناس؟"
- C) "ما نسبة جلسات ديسمبر التي وصلت إلى صفحة الدفع، مقارنةً بنوفمبر؟"
- D) "ماذا يجب أن نفعل؟"
B3. كتب محلل في التقرير النهائي: "انخفضت الإيرادات بسبب العطلات." والبيانات لا تعرض إلا المجاميع الشهرية. ما الخطأ؟
- A) لا يوجد خطأ. العطلات تخفّض المبيعات دائمًا.
- B) يجب ألا يذكر التقرير شهر ديسمبر.
- C) كان يجب أن يستخدم المحلل أرقامًا عشرية أكثر.
- D) عُرضت فرضية (أو افتراض) على أنها حقيقة، دون دليل.
B4. وفقًا لإرشادات AWS، أي طريقة هي الأنسب لمهمة "ضع علامة على الطلبات التي تزيد عن 1,000 دولار لمراجعتها يدويًا"؟
- A) قاعدة أعمال بسيطة (
if total > 1000) - B) نموذج تعلم عميق (deep learning)
- C) روبوت محادثة يعتمد على الذكاء الاصطناعي التوليدي
- D) استبيان للعملاء
الجزء C — تفكيك حالة (يُقيَّم بالمعايير). Riverside Bikes الخيالي: "نحن نخسر مالًا في أعمال الصيانة." قدّم خطة من صفحة واحدة تحتوي على:
- القرار وصاحب القرار؛
- المعلوم والمجهول؛
- ثلاثة افتراضات مصنّفة؛
- القيود؛
- شجرة أسئلة فيها خمسة أسئلة فرعية على الأقل؛
- مقياسًا ومصدر بيانات لكل سؤال فرعي؛
- ترتيب المهام؛
- فحصين للنجاح.
10. الذكاء الاصطناعي في التطبيق
اطلب من الذكاء الاصطناعي 3 استراتيجيات للتفكيك، وقارن افتراضاتها.
- ضع خطتك أنت أولًا. اقضِ 5 دقائق في رسم شجرة أسئلة سريعة لهذه الحالة: "الإيرادات انخفضت هذا الشهر في متجر إلكتروني صغير" (لا تحتاج إلى بيانات).
- الطلب (مصطنع، بلا بيانات شركة حقيقية):
"Act as an analytics mentor. A small fictional online store says 'revenue dropped this month'. Propose three different strategies to decompose this problem into smaller analytical questions (for example: by formula components, by customer segments, by time/events). For each strategy, list the sub-questions, the data needed, and every assumption the strategy makes. Do not state causes as facts."
وبالعربية: "تصرّف كمرشد في التحليلات. متجر إلكتروني صغير خيالي يقول: 'الإيرادات انخفضت هذا الشهر'. اقترح ثلاث استراتيجيات مختلفة لتفكيك هذه المشكلة إلى أسئلة تحليلية أصغر (مثلًا: حسب مكونات المعادلة، أو حسب شرائح العملاء، أو حسب الوقت والأحداث). ولكل استراتيجية، اذكر الأسئلة الفرعية، والبيانات المطلوبة، وكل افتراض تقوم عليه. لا تذكر الأسباب على أنها حقائق."
- قارن الاستراتيجيات الثلاث وخطتك في جدول:
- الأسئلة الفرعية؛
- البيانات المطلوبة؛
- الافتراضات؛
- ما الذي ستُغفله كل استراتيجية.
- اختر استراتيجية واحدة، أو مزيجًا منها، لحالة Cedar Lane تحت قيود القسم 5 (ساعتان، ولا بيانات شخصية)، وبرّر اختيارك في 3 جمل.
11. التحقق من مخرجات الذكاء الاصطناعي
- مراجعة الافتراضات: لكل استراتيجية اقترحها الذكاء الاصطناعي، تأكد أن كل افتراض مُصرَّح به. وأضف أي افتراضات مخفية؛ ومن أشهرها "البيانات صحيحة".
- هل يمكن الإجابة عنه؟ صنّف كل سؤال فرعي من الذكاء الاصطناعي: يمكن الإجابة عنه بالبيانات المتاحة، أو يحتاج إلى بيانات جديدة، أو لا يمكن الإجابة عنه بصيغته الحالية. وأعِد صياغة الأسئلة الغامضة.
- لا أسباب على أنها حقائق: ارفض أي عبارة مثل "السبب في هذا هو…" ليس لها دليل. وأعِد تصنيفها كفرضية.
- القيود: احذف الخطوات التي تحتاج إلى بيانات لا تملكها، أو التي تتطلب مشاركة بيانات شخصية.
- أبسط طريقة كافية: ارفض اقتراحات استخدام تعلم الآلة أو الأدوات المعقدة عندما يكفي الحساب البسيط للإجابة عن السؤال.
- الخطة خطتك أنت: الذكاء الاصطناعي يقترح؛ وصاحب القرار وأنت تقرران. وسجّل ما قبلته وما رفضته.
- الخصوصية: لا تلصق أبدًا بيانات حقيقية عن العملاء أو الإيرادات أو الموظفين في أداة ذكاء اصطناعي لكي "تجعلها واقعية".
12. منظور الأعمال
حوّل "الإيرادات انخفضت" إلى شجرة قرار من الأسئلة التشخيصية. الشجرة الجيدة:
- تبدأ من القرار الذي يواجهه صاحب المتجر (ما الذي سيتغير حسب الإجابة)؛
- تستخدم معادلة عندما توجد واحدة (الإيرادات = الجلسات × معدل التحويل × AOV)، حتى تكون الفروع كاملة ولا تتداخل؛
- تفحص البيانات أولًا (Q0)، لأن تغييرًا في التتبّع قد يبدو كمشكلة في الأعمال؛
- تنتهي بأسئلة لكل منها مقياس ومصدر بيانات محدد؛
- تُبقي الأسباب فرضيات إلى أن تُختبر.
هذا يوفّر الوقت والمال. فالفريق يبحث في الفرع الذي تغيّر فعلًا، بدلًا من التخمين.
13. مهمة عمل — خطة تشخيصية من صفحة واحدة
متجر Cedar Lane الخيالي (بيانات القسم 5). اكتب خطة من صفحة واحدة (150–250 كلمة + شجرة) لصاحب المتجر تغطي:
- القرار والموعد النهائي؛
- شجرة قرار فيها Q0–Q3، ومستوى إضافي واحد على الأقل تحت الفرع الذي تغيّر؛
- القيم المحسوبة لكل جزء من المعادلة (نسبة تغير الجلسات، ومعدل التحويل في الشهرين، وAOV في الشهرين) وفحص النجاح؛
- ثلاثة افتراضات مصنّفة وقيدًا واحدًا؛
- توصية بـ الفرع الذي يجب البحث فيه بعد ذلك، ولماذا. وهذه خطوة تالية، وليست سببًا نهائيًا.
14. تحدٍّ قصير
نشاط تجاري خيالي: Greenleaf Plants. يسأل صاحب المتجر: "هل نبدأ في تقديم خدمة التوصيل؟"
- حدّد القرار وثلاثة أشياء يجب أن تكون صحيحة لكي يكون التوصيل فكرة جيدة. واكتبها كافتراضات مصنّفة.
- ابنِ شجرة أسئلة فيها أربعة أسئلة فرعية على الأقل، لكل منها مقياس.
- حدّد سؤالًا فرعيًا تستطيع الإجابة عنه من بيانات المبيعات الحالية، وسؤالًا يحتاج إلى بيانات جديدة (مثل استبيان صغير للعملاء).
سلّم إجابتك قبل الحصول على التعليقات. لا يوجد حل هنا.
15. المصادر
- مطلوب (حوالي 15 دقيقة): AWS Cloud Adoption Framework، Business Perspective، صفحة Data science. اقرأ توصيات "Start" الخاصة بتعريف مشكلة الأعمال وقيمتها، وبالنتائج القابلة للقياس. ولاحظ السطر "Some business problems don't need ML and simple business rules can do a much better job." https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-science.html (فُتحت وروجعت في 12 أكتوبر 2026. تذكر الصفحة أنها "for historical reference only"، أي للرجوع التاريخي فقط.)
- موصى به: ملاحظاتك من L08 في U02 عن أشجار مؤشرات الأداء والأسئلة التشخيصية.
- للتعمّق (اختياري): O*NET OnLine، ملخص Data Scientists. انظر إلى المهمة "Identify business problems or management objectives that can be addressed through data analysis." (تحديد مشكلات الأعمال أو أهداف الإدارة التي يمكن معالجتها بتحليل البيانات). وهذا وصف وظيفي أمريكي. https://www.onetonline.org/link/summary/15-2051.00 (فُتح وروجع في 12 أكتوبر 2026.)
16. شخصية تتابعها / قدوة
Cassie Kozyrkov (اختارتها D.World؛ ومجالها في الخريطة "Decision intelligence / data-informed decisions"، أي ذكاء القرار والقرارات المستندة إلى البيانات).
- حقيقة موثّقة (12 أكتوبر 2026): ذكرت Fortune (6 سبتمبر 2023) أنها عملت كبيرة علماء القرار (chief decision scientist) في Google. وقالت إنها ساعدت في ريادة مجال ذكاء القرار (decision intelligence)، وإنها تغادر Google لتعمل بشكل مستقل. https://fortune.com/2023/09/06/google-chief-decision-scientist-cassie-kozyrkove-why-left-company-helping-business-leaders-choices-ai
- غير موثّق: موقعها الشخصي (https://www.kozyr.com/، المذكور في خريطة D.World) لم تتمكن أداة المراجعة لدينا من فتحه، ولذلك لم نستخدم أي تفاصيل منه هنا. راجعه بنفسك لتعرف عملها الحالي.
- لماذا ترشّحها D.World: تركيزها على جودة القرار، أي البدء من القرار بدلًا من البيانات، يتوافق مع المرحلة 1 في هذا الدرس.
- جرّب هذا: ابحث عن إحدى محاضراتها أو مقالاتها عن اتخاذ القرار. ودوّن فكرة واحدة عن تعريف القرار قبل النظر في البيانات، وقارنها بالمرحلة 1 في هذا الدرس.
17. المصطلحات
| المصطلح | معناه في هذا الدرس |
|---|---|
| التفكيك (Decomposition) | تقسيم سؤال كبير وغامض إلى أسئلة أصغر يمكن الإجابة عنها |
| صاحب القرار (Decision owner) | الشخص أو الدور الذي سيتصرف بناءً على الإجابة |
| حقيقة (Fact) | عبارة مرصودة ومسجّلة ويمكن التحقق منها |
| متطلب (Requirement) | شرط يجب أن تحققه الإجابة، ويحدده صاحب القرار |
| افتراض (Assumption) | شيء نعامله على أنه صحيح الآن، ونصرّح به علنًا، وقد يكون خاطئًا |
| تقدير (Estimate) | رقم محسوب أو مبني على تقدير شخصي، وفيه قدر من عدم اليقين |
| مجهول (Unknown) | معلومة غير متاحة بعد |
| قيد (Constraint) | حدّ على الوقت، أو البيانات، أو الأدوات، أو الخصوصية، أو الميزانية |
| شجرة أسئلة / شجرة قرار من الأسئلة (Question tree) | رسم يقسّم سؤالًا إلى أسئلة فرعية |
| فحص النجاح (Success check) | اختبار يُظهر أن التحليل صحيح ومفيد |
| أبسط طريقة كافية (Simplest adequate method) | أقل الطرق تعقيدًا التي تجيب عن السؤال بدرجة كافية لاتخاذ القرار |
18. تأمّل
فكّر في آخر مرة قفزت فيها مباشرة إلى حل مشكلة (في العمل، أو الدراسة، أو البيت). أي مرحلة من المراحل التسع تخطّيتها؟ وما الذي كان سيتغير لو كتبت افتراضاتك أولًا؟
19. الخطوة التالية
بعد تفكيك المشكلة، يحتاج كل سؤال فرعي إلى إجراء واضح. في L18 — الخوارزميات والكود الوصفي والتفكير الواضح، ستكتب خطوات مرتّبة وكودًا وصفيًا (pseudocode)، مثلًا لحساب المبيعات اليومية ووضع علامة على الأيام غير المعتادة، قبل أن تكتب أي Python.
20. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| الجزء A (6 عبارات) | التمييز بين الحقيقة والمتطلب والافتراض والتقدير والمجهول | 5 إجابات صحيحة أو أكثر من 6 |
| الجزء B (B1–B4) | التوضيح قبل التصرف؛ والتعرّف على الأسئلة التي يمكن الإجابة عنها؛ وتجنّب ذكر الأسباب على أنها حقائق؛ واختيار طريقة بسيطة | 3 إجابات صحيحة أو أكثر من 4؛ ويجب أن تكون B3 صحيحة |
| الجزء C (تفكيك حالة Riverside) | خطة تفكيك كاملة | معايير L17-KCC |
| الذكاء الاصطناعي في التطبيق | مقارنة استراتيجيات الذكاء الاصطناعي ومراجعة افتراضاتها | معايير L17-AI |
| التدريب الموجَّه والمستقل، وخطة العمل، والتحدي القصير | تطبيق طريقة المراحل التسع | معايير L17-GP وL17-IP وL17-WT وL17-MC |
المراجع
- Amazon Web Services. AWS CAF Business Perspective — Data science. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-science.html (فُتحت وروجعت في 12 أكتوبر 2026؛ وعليها تنبيه بأنها للرجوع التاريخي). يدعم: "Begin by defining business problems … and have a clear idea of the business value to be gained"؛ و"Establish an observable and quantifiable performance metric"؛ و"Some business problems don't need ML and simple business rules can do a much better job."
- O*NET OnLine. 15-2051.00 – Data Scientists (ملخص؛ الولايات المتحدة). https://www.onetonline.org/link/summary/15-2051.00 (فُتح وروجع في 12 أكتوبر 2026؛ وحُدّث الموقع في 6 أكتوبر 2026). يدعم: المهمة "Identify business problems or management objectives that can be addressed through data analysis."
- Fortune، 6 سبتمبر 2023، عن مغادرة Cassie Kozyrkov لشركة Google. https://fortune.com/2023/09/06/google-chief-decision-scientist-cassie-kozyrkove-why-left-company-helping-business-leaders-choices-ai (فُتح وروجع في 12 أكتوبر 2026).
- طريقة التفكيك ذات المراحل التسع وأنواع العبارات الخمسة أدوات تعليمية من D.World، وليست معيارًا خارجيًا.
- D.World Curriculum Map v1.0 (صف L17) وCurriculum Bible v1.0. وثائق داخلية.
L18 · Algorithms, Pseudocode & Clear ThinkingL18 · الخوارزميات والكود الوصفي والتفكير الواضح Freeمجاني
L18 — Algorithms, Pseudocode & Clear Thinking
Learner file. Answers and model solutions are in a separate instructor-only file. Version: U05 v1.0 · Content date: 12 October 2026. Time estimates are provisional planning guides for a self-paced path, not waiting periods. Code examples were tested with Python 3.13 (see the U05 QA report).
1. Lesson Identity
| Field | Value |
|---|---|
| Title | Algorithms, Pseudocode & Clear Thinking |
| Stage | Stage 1 — Foundations |
| Unit | U05 — Problem Solving & Computational Thinking |
| Lesson ID | L18 |
| Skills | Algorithms; pseudocode |
| Difficulty | Beginner |
| Estimated time | About 1 hour 50 minutes (provisional) |
| Prerequisites | L17 (decomposition). U04 L14–L16 (conditions, lists and dictionaries, loops, functions). |
Time breakdown (provisional): concept and worked example, 35 min · guided practice, 15 min · independent practice, 15 min · knowledge check, 15 min · AI in Practice and Verification, 10 min · workplace task, 15 min · mini challenge, 5 min.
2. Learning Objective
By the end of this lesson, you will be able to represent a solution as ordered steps, first in plain language and then in pseudocode, and check those steps by tracing them on a small example before turning them into Python.
D.World map objective (verbatim): Represent a solution as ordered steps before coding it.
3. Why It Matters
In L17 you split a vague business question into smaller questions. Each one now needs a procedure that anyone, including a computer, can follow exactly.
If you go straight to Python, you have to think about two things at once: what to do and how to write it. Mistakes in the logic get buried under syntax. Writing the steps first, in plain language and then in pseudocode, lets you find gaps and unnecessary work while changes are cheap. It also gives colleagues and reviewers something they can read without knowing Python. Key principle: think before code.
4. Concept
What is an algorithm?
In D.World, an algorithm is a finite, ordered set of unambiguous steps that turns stated inputs into a stated output:
| Property | Meaning | Business example |
|---|---|---|
| Inputs | What the steps start from | The list of order lines for one week |
| Output | What the steps produce | Paid sales per day |
| Ordered | Steps happen in a defined sequence | Set the total to 0 before adding |
| Unambiguous | Each step has one meaning | "Add qty × price for paid lines", not "add the sales" |
| Finite | It always finishes | One pass through a list of known length |
A recipe, a checkout procedure and a refund policy are all everyday algorithms.
Three levels of description
| Level | Example | Who can use it |
|---|---|---|
| Plain-language steps | "For each paid line, add its value to that day's total." | Anyone, including the business owner |
| Pseudocode | FOR EACH line IN lines: IF line.status = "paid" THEN ADD … |
Analysts and reviewers; language-neutral |
| Executable code | for line in lines: if line["status"] == "paid": … |
A computer (Python) |
Pseudocode is structured, precise English. It is not a programming language, and there is no single official syntax. D.World uses the conventions below so that your pseudocode stays consistent:
INPUT lines -- what the algorithm receives
SET daily_totals TO empty mapping -- create / assign
FOR EACH line IN lines -- repeat for every item
IF line.status = "paid" THEN -- decision
ADD line.qty × line.price TO daily_totals[line.date]
END IF
END FOR
OUTPUT daily_totals -- what the algorithm produces
- Indentation shows what belongs inside a loop or decision.
=in pseudocode means "equals" (a comparison);SET … TOmeans assignment.- Leave out Python details such as brackets and quote styles. Keep business meaning in the names.
From steps to a trustworthy procedure
- Write plain steps in order.
- Rewrite them as pseudocode, naming every input, decision and output.
- Trace the pseudocode by hand on a tiny example and record each value.
- Look for gaps: missing starting values, unhandled cases (empty input, refunds) and unclear words.
- Remove unnecessary steps: anything that does not change the output or a check. Examples: sorting when order doesn't matter, or storing data that is never used.
- Only then translate to Python, one pseudocode line at a time. Keep the pseudocode as comments or in a docstring.
Simplest adequate algorithm
For most beginner business tasks, one pass through the data with a few running totals is enough. If your pseudocode needs many loops over the same data, ask whether one loop could do the job. Only add complexity, such as sorting or several passes, when the output actually requires it.
5. Worked Example
Task: calculate paid sales per day for Cedar Lane's first week of December. (Synthetic data.)
lines = [
{"date": "2026-12-01", "order_id": 3001, "qty": 2, "price": 12.0, "status": "paid"},
{"date": "2026-12-01", "order_id": 3002, "qty": 1, "price": 20.0, "status": "paid"},
{"date": "2026-12-02", "order_id": 3003, "qty": 3, "price": 8.0, "status": "paid"},
{"date": "2026-12-02", "order_id": 3004, "qty": 1, "price": 12.0, "status": "refunded"},
{"date": "2026-12-03", "order_id": 3005, "qty": 4, "price": 12.0, "status": "paid"},
{"date": "2026-12-03", "order_id": 3006, "qty": 1, "price": 8.0, "status": "paid"},
{"date": "2026-12-04", "order_id": 3007, "qty": 10, "price": 12.0, "status": "paid"},
{"date": "2026-12-05", "order_id": 3008, "qty": 2, "price": 20.0, "status": "paid"},
{"date": "2026-12-06", "order_id": 3009, "qty": 1, "price": 8.0, "status": "paid"},
{"date": "2026-12-07", "order_id": 3010, "qty": 2, "price": 12.0, "status": "paid"},
{"date": "2026-12-07", "order_id": 3011, "qty": 1, "price": 20.0, "status": "paid"},
]
(The records are longer than PEP 8's 79-character guideline, kept on one line for readability.)
Step 1: plain steps. 1. Start with an empty record of daily totals. 2. Look at each order line in turn. 3. Skip lines that are not paid. 4. Add the line's value (quantity × price) to the total for its date. 5. After the last line, report the daily totals.
Step 2: pseudocode.
INPUT lines
SET daily_totals TO empty mapping
FOR EACH line IN lines
IF line.status = "paid" THEN
SET value TO line.qty × line.price
ADD value TO daily_totals[line.date] -- start from 0 if the date is new
END IF
END FOR
OUTPUT daily_totals
Step 3: trace the first four lines by hand.
| Line | Paid? | value | daily_totals after |
|---|---|---|---|
| 3001 (Dec 1) | yes | 24.0 | Dec 1: 24.0 |
| 3002 (Dec 1) | yes | 20.0 | Dec 1: 44.0 |
| 3003 (Dec 2) | yes | 24.0 | Dec 1: 44.0, Dec 2: 24.0 |
| 3004 (Dec 2) | no | — | unchanged |
Continuing the trace gives the totals for all seven days. They should add up to 336.0 USD for the week.
Step 4: translate to Python, line by line. (Run; paste the lines list above first.)
def daily_paid_sales(lines):
"""Return a dictionary of paid sales per date (qty * price, paid lines only)."""
daily_totals = {}
for line in lines:
if line["status"] == "paid":
value = line["qty"] * line["price"]
daily_totals[line["date"]] = daily_totals.get(line["date"], 0.0) + value
return daily_totals
daily = daily_paid_sales(lines)
for date, total in daily.items():
print(date, total)
2026-12-01 44.0
2026-12-02 24.0
2026-12-03 56.0
2026-12-04 120.0
2026-12-05 40.0
2026-12-06 8.0
2026-12-07 44.0
Each Python line maps to one pseudocode line. That makes it easy to check, and easy to fix if the pseudocode was wrong.
6. Visual Explanation
PLAIN STEPS ──► PSEUDOCODE ──► TRACE ON TINY DATA ──► FIX GAPS / REMOVE EXTRA STEPS ──► PYTHON
(what) (precise) (does it work?) (simplest adequate) (how)
One pass: lines ──► [paid?] ──yes──► add qty×price to daily_totals[date]
└──no───► skip
Alt text: Two diagrams. The first is a pipeline: plain steps (what to do) lead to pseudocode (precise steps), then to a trace on tiny data (does it work?), then to fixing gaps and removing extra steps (simplest adequate method), and finally to Python (how). The second shows one pass through the order lines. Each line is checked for paid status; if paid, quantity times price is added to that date's total; if not, the line is skipped.
7. Guided Practice
Task: count the number of paid orders per day using the worked-example lines. (Trace OK, then Run.)
- Write the plain steps (4–6 steps).
- Complete the pseudocode template:
text
INPUT lines
SET orders_per_day TO ___
FOR EACH line IN lines
IF ___ THEN
ADD 1 TO orders_per_day[line.date]
END IF
END FOR
OUTPUT ___
- Trace it by hand for Dec 1 to Dec 3.
- (Hint: think about orders with several lines.) This dataset has one paid line per order. Would your pseudocode still be correct if an order had two lines? If not, what step would you add? Answer in words; you do not need to code it.
- Translate your pseudocode into a Python function and run it.
8. Independent Practice
Task: find the day with the highest and the day with the lowest paid sales, using the output of daily_paid_sales.
- Write plain steps and pseudocode. Use a single loop over the daily totals.
- Trace it by hand on the seven daily totals.
- Identify one unclear case your pseudocode must decide, such as a tie between two days or an empty input, and write how you handle it.
- Translate to Python, run, and compare with your trace.
No model answer is shown here.
9. Knowledge Check — Pseudocode Assessment
Part A — Choose the best answer.
A1. Which is not a property of an algorithm as defined in this lesson? - A) Its steps are in a defined order. - B) It must be written in Python. - C) It finishes. - D) Each step has one clear meaning.
A2. What is missing from this pseudocode?
INPUT lines
FOR EACH line IN lines
IF line.status = "paid" THEN
ADD line.qty × line.price TO total
END IF
END FOR
OUTPUT total
- A) Nothing; it is complete.
- B) A step that sorts the lines first
- C)
SET total TO 0before the loop - D) A second loop to check the result
A3. A colleague's pseudocode for "total paid sales for the week" includes: (1) sort lines by date; (2) remove refunded lines; (3) add up qty × price; (4) print each line. Which step is unnecessary for the stated output? - A) Step 1 (sorting) - B) Step 2 - C) Step 3 - D) None are unnecessary.
A4. Trace this pseudocode. What is the output?
INPUT sales = [5, 12, 7, 20]
SET flagged TO 0
FOR EACH s IN sales
IF s > 10 THEN
ADD 1 TO flagged
END IF
END FOR
OUTPUT flagged
- A)
1 - B)
3 - C)
4 - D)
2
Part B — Write pseudocode (rubric-marked). Fictional Cedar Lane stock report. Inputs:
- stock: a mapping of product → units on hand;
- reorder_level: a mapping of product → minimum units.
Output: a list of products to reorder (units on hand at or below their reorder level). Products missing from reorder_level should be reported separately as "no reorder level set".
- Write plain steps.
- Write pseudocode using the D.World conventions.
- Trace it on: stock = {Notebook: 40, Pen set: 12, Planner: 5, Bookmark: 30}; reorder_level = {Notebook: 20, Pen set: 15, Planner: 5}.
10. AI in Practice
Ask AI to propose pseudocode, then simplify it and identify unnecessary steps.
- Write your own pseudocode first for the Business Lens task (Section 12).
- Prompt (synthetic data only):
"Write language-neutral pseudocode for this task: given a list of order lines (date, order_id, qty, price, status), calculate paid sales per day, then flag any day whose paid sales are below 50% or above 150% of the average daily paid sales for the period. State the inputs, outputs and any assumptions. Do not write Python."
- Simplify: cross out every step that does not change the output. Typical candidates are sorting, converting dates, storing every line again, or computing extra statistics that are never used.
- Compare with your own pseudocode. List what the AI included that you missed, and what it added that is unnecessary or that changes the rule. For example, did it use a median instead of the average, or
<=instead of<? - Trace your final simplified pseudocode on the seven daily totals before coding.
11. AI Verification
- Rule fidelity: check that every comparison matches the business rule exactly: average vs median, "below" (
<) vs "at or below" (<=), 50% and 150%. - Inputs and outputs: check that the AI's inputs match the data you have, with no fields you don't have, and that the output is what the decision owner needs.
- Unnecessary steps: remove any step that does not change the output or a check. Shorter, clear pseudocode is easier to verify.
- Edge cases: ask what happens with no paid lines (no average can be calculated) or a single day. Add a decision for each.
- Trace before trust: trace the final pseudocode on the real seven-day totals and compare with your own expected flags.
- Privacy: synthetic data only; never paste real sales exports.
12. Business Lens
Design a procedure to calculate daily sales and flag unusual values. Owners notice strange days only when they look. A simple, documented procedure checks every day consistently:
- The rule must be explicit and agreed with the owner. In this unit's synthetic case: flag a day if its paid sales are below 50% or above 150% of the period's average daily paid sales. This rule is an assumption that the owner can change, not a universal standard.
- Unusual ≠ wrong. A flagged day is a prompt to investigate, perhaps a big order, a holiday or a website problem. It is not a conclusion.
- Know the method's limits. One very large day raises the average itself, which can change which other days are flagged. Write this limitation next to the result.
13. Workplace Task — Daily Sales with Flags
Fictional Cedar Lane (worked-example lines).
- Write the plain steps and pseudocode for the full procedure: daily paid sales → average daily sales → flags (rule in Section 12).
- By hand: calculate the average daily paid sales, the low and high thresholds, and which days are flagged and why.
- Translate to Python (a function is recommended), run it, and compare with your hand results.
- Recalculate the average without the highest day. Do the flags change? Write two sentences for the owner about what this means for trusting the rule.
14. Mini Challenge
Fictional Cedar Lane loyalty tiers. Rule: total spend of 500 USD or more → Gold; 200 USD or more → Silver; otherwise Standard.
- Write pseudocode that takes a mapping of customer ID → total spend and outputs a mapping of customer ID → tier.
- Trace it on: {C01: 520, C02: 200, C03: 199.99, C04: 0}.
- Translate to Python and write five test cases, including both boundaries.
Submit before feedback. No solution is provided here.
15. Resources
- Required (about 15 min): The Python Tutorial, sections 4.2 "
forStatements" and 4.8 "Defining Functions". Note the advice that "it's good practice to include docstrings in code that you write". A docstring is a natural home for your plain-language steps. https://docs.python.org/3/tutorial/controlflow.html (Opened and checked 12 Oct 2026.) - Recommended: The Python Tutorial index, for revisiting U04 topics. https://docs.python.org/3/tutorial/ (Opened and checked 12 Oct 2026.)
- Deeper (optional): Donald Knuth's The Art of Computer Programming page. See Section 16.
16. Person to Follow / Role Model
Donald Knuth / algorithmic thinking (mapped by D.World).
- Verified facts (12 Oct 2026): his Stanford page describes him as "Professor Emeritus of The Art of Computer Programming at Stanford University" (https://www-cs-faculty.stanford.edu/~knuth/). His The Art of Computer Programming (TAOCP) page lists volumes including Volume 1, "Fundamental Algorithms", and Volume 3, "Sorting and Searching" (https://www-cs-faculty.stanford.edu/~knuth/taocp.html).
- Relevance: TAOCP is a long-running, highly detailed work on algorithms. It is far beyond this lesson, but it shows how seriously computer science treats precise, step-by-step procedures.
- Try this: open the TAOCP page and read the volume titles. Pick one title and write one sentence guessing what kind of everyday business task it might relate to. For example, "Sorting and Searching" relates to finding a customer's order. Label your sentence as a guess.
17. Glossary
| Term | Meaning in this lesson |
|---|---|
| Algorithm | A finite, ordered set of unambiguous steps turning inputs into an output |
| Input / output | What the procedure starts from / what it produces |
| Plain-language steps | A numbered description anyone can read |
| Pseudocode | Structured, language-neutral steps using conventions such as SET, FOR EACH, IF, OUTPUT |
| Trace | Following steps by hand on a small example, recording values |
| Running total | A value updated on each pass through the data |
| Unnecessary step | A step that changes neither the output nor a check |
| Threshold | A cut-off value used in a rule (e.g., 50% of average) |
| Edge case | An unusual input that needs a decision (empty data, ties) |
| Docstring | A string at the start of a Python function describing what it does |
18. Reflection
Compare the time you spent writing pseudocode with the time you spent writing the Python. Did the pseudocode save time overall? Where did tracing reveal something you would otherwise have missed?
19. Next Step
A clear procedure can still be implemented wrongly, or rest on data you didn't expect. In L19 — Debugging, Testing & Verification, you will separate syntax, runtime and logic errors, and design tests and checks against hand-worked examples. Those tests are what make a result trustworthy.
20. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Part A (A1–A4) | Understands algorithm properties, missing and unnecessary steps; traces pseudocode | 3 or more of 4 correct |
| Part B (stock report pseudocode) | Writes complete, unambiguous pseudocode and traces it | Rubric L18-KCB |
| AI in Practice (simplify AI pseudocode) | Removes unnecessary steps; checks rule fidelity | Rubric L18-AI |
| Guided and independent practice, workplace flags, mini challenge | Moves from steps to pseudocode to trace to Python | Rubrics L18-GP, L18-IP, L18-WT, L18-MC |
References
- Python Software Foundation. The Python Tutorial, ch. 4. https://docs.python.org/3/tutorial/controlflow.html (opened and checked 12 Oct 2026). Supports:
forstatements; functions; docstrings ("it's good practice to include docstrings in code that you write"); "Use docstrings." - Python Software Foundation. The Python Tutorial (index). https://docs.python.org/3/tutorial/ (opened and checked 12 Oct 2026).
- Knuth, D. E. Home page and TAOCP page, Stanford University. https://www-cs-faculty.stanford.edu/~knuth/ and https://www-cs-faculty.stanford.edu/~knuth/taocp.html (both opened and checked 12 Oct 2026). Supports: title description; volume titles.
- The algorithm definition, pseudocode conventions and the 50%/150% flag rule are D.World teaching choices (the rule is a synthetic-case assumption), not external standards.
- D.World Curriculum Map v1.0 (L18 row) and Curriculum Bible v1.0. Internal.
L18 — الخوارزميات والكود الوصفي والتفكير الواضح
ملف المتعلّم. الإجابات والحلول النموذجية في ملف منفصل خاص بالمدرّس فقط. الإصدار: U05 v1.0 · تاريخ المحتوى: 12 أكتوبر 2026. تقديرات الوقت إرشادات مبدئية للتخطيط في مسار ذاتي الوتيرة، وليست فترات انتظار. أمثلة الكود مُختبَرة على Python 3.13 (راجع تقرير الجودة QA الخاص بـ U05).
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | الخوارزميات والكود الوصفي والتفكير الواضح |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U05 — حل المشكلات والتفكير الحاسوبي |
| رقم الدرس | L18 |
| المهارات | الخوارزميات (algorithms)؛ الكود الوصفي (pseudocode) |
| المستوى | مبتدئ |
| الوقت المتوقع | حوالي ساعة و50 دقيقة (مبدئي) |
| المتطلبات السابقة | L17 (التفكيك). وL14–L16 في U04 (الشروط، والقوائم والقواميس، والحلقات التكرارية، والدوال). |
تفصيل الوقت (مبدئي): المفهوم والمثال المحلول 35 دقيقة · التدريب الموجَّه 15 دقيقة · التدريب المستقل 15 دقيقة · اختبار الفهم 15 دقيقة · الذكاء الاصطناعي في التطبيق والتحقق 10 دقائق · مهمة العمل 15 دقيقة · التحدي القصير 5 دقائق.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تعرض الحل كخطوات مرتّبة، أولًا بلغة بسيطة ثم في صورة كود وصفي (pseudocode)، وأن تراجع هذه الخطوات بتتبّعها على مثال صغير قبل أن تحوّلها إلى Python.
هدف خريطة D.World (بنصّه): Represent a solution as ordered steps before coding it.
3. لماذا يهمّك هذا؟
في L17 قسّمت سؤال أعمال غامضًا إلى أسئلة أصغر. والآن يحتاج كل سؤال منها إلى إجراء يستطيع أي أحد، بما في ذلك الكمبيوتر، أن يتبعه بدقة.
إذا ذهبت مباشرة إلى Python، فستضطر إلى التفكير في أمرين معًا: ماذا تفعل، وكيف تكتبه. وتُدفَن أخطاء المنطق تحت تفاصيل الصياغة. أما كتابة الخطوات أولًا، بلغة بسيطة ثم في صورة كود وصفي، فتتيح لك أن تكتشف الثغرات والعمل الزائد بينما التغيير ما زال رخيصًا. كما تعطي زملاءك ومراجعيك شيئًا يستطيعون قراءته دون معرفة Python. المبدأ الأساسي: فكّر قبل أن تكتب الكود.
4. المفهوم
ما الخوارزمية؟
في D.World، الخوارزمية (algorithm) مجموعة محدودة ومرتّبة من الخطوات الواضحة التي لا تحتمل أكثر من معنى، تحوّل مدخلات محددة إلى مخرج محدد:
| الخاصية | المعنى | مثال من الأعمال |
|---|---|---|
| المدخلات (Inputs) | ما تبدأ منه الخطوات | قائمة بنود الطلبات لأسبوع واحد |
| المخرج (Output) | ما تنتجه الخطوات | المبيعات المدفوعة لكل يوم |
| مرتّبة (Ordered) | الخطوات تحدث بتسلسل محدد | اجعل المجموع 0 قبل الإضافة |
| واضحة (Unambiguous) | لكل خطوة معنى واحد | "أضف qty × price للبنود المدفوعة"، وليس "أضف المبيعات" |
| محدودة (Finite) | تنتهي دائمًا | مرور واحد على قائمة طولها معروف |
وصفة الطبخ، وإجراءات الدفع عند الشراء، وسياسة الاسترداد، كلها خوارزميات من الحياة اليومية.
ثلاثة مستويات للوصف
| المستوى | مثال | من يستطيع استخدامه |
|---|---|---|
| خطوات بلغة بسيطة | "لكل بند مدفوع، أضف قيمته إلى مجموع ذلك اليوم." | أي شخص، بما في ذلك صاحب النشاط |
| الكود الوصفي (Pseudocode) | FOR EACH line IN lines: IF line.status = "paid" THEN ADD … |
المحللون والمراجعون؛ ولا يرتبط بلغة برمجة معينة |
| كود قابل للتشغيل | for line in lines: if line["status"] == "paid": … |
الكمبيوتر (Python) |
الكود الوصفي لغة إنجليزية منظّمة ودقيقة. وهو ليس لغة برمجة، ولا توجد له صياغة رسمية واحدة. وتستخدم D.World الاصطلاحات التالية حتى يبقى الكود الوصفي الذي تكتبه متسقًا:
INPUT lines -- what the algorithm receives
SET daily_totals TO empty mapping -- create / assign
FOR EACH line IN lines -- repeat for every item
IF line.status = "paid" THEN -- decision
ADD line.qty × line.price TO daily_totals[line.date]
END IF
END FOR
OUTPUT daily_totals -- what the algorithm produces
(التعليقات بعد -- تعني بالترتيب: ما تستقبله الخوارزمية · إنشاء / إسناد · كرّر مع كل عنصر · قرار · ما تنتجه الخوارزمية.)
- الإزاحة تُظهر ما ينتمي إلى داخل الحلقة أو القرار.
=في الكود الوصفي تعني "يساوي" (مقارنة)؛ أماSET … TOفتعني الإسناد.- اترك تفاصيل Python مثل الأقواس وأنواع علامات التنصيص. واحتفظ بمعنى الأعمال في الأسماء.
من الخطوات إلى إجراء يمكن الوثوق به
- اكتب خطوات بسيطة بالترتيب.
- أعِد كتابتها كودًا وصفيًا، مع تسمية كل مُدخل وقرار ومخرج.
- تتبّع الكود الوصفي يدويًا على مثال صغير جدًا، وسجّل كل قيمة.
- ابحث عن الثغرات: القيم الابتدائية الناقصة، والحالات التي لم تُعالج (مُدخل فارغ، أو استرداد)، والكلمات غير الواضحة.
- احذف الخطوات غير الضرورية: أي شيء لا يغيّر المخرج أو أحد الفحوصات. ومن أمثلتها: الترتيب عندما لا يكون الترتيب مهمًا، أو تخزين بيانات لا تُستخدم أبدًا.
- عندها فقط حوّلها إلى Python، سطرًا من الكود الوصفي في كل مرة. واحتفظ بالكود الوصفي كتعليقات أو داخل نص التوثيق (docstring).
أبسط خوارزمية كافية
في معظم مهام الأعمال للمبتدئين، يكفي مرور واحد على البيانات مع بعض المجاميع المتراكمة. وإذا احتاج الكود الوصفي الذي كتبته إلى حلقات كثيرة على البيانات نفسها، فاسأل: هل تستطيع حلقة واحدة أن تؤدي المهمة؟ ولا تُضِف تعقيدًا، مثل الترتيب أو المرور عدة مرات، إلا عندما يتطلبه المخرج فعلًا.
5. مثال محلول
المهمة: احسب المبيعات المدفوعة لكل يوم لمتجر Cedar Lane في الأسبوع الأول من ديسمبر. (بيانات مصطنعة.)
lines = [
{"date": "2026-12-01", "order_id": 3001, "qty": 2, "price": 12.0, "status": "paid"},
{"date": "2026-12-01", "order_id": 3002, "qty": 1, "price": 20.0, "status": "paid"},
{"date": "2026-12-02", "order_id": 3003, "qty": 3, "price": 8.0, "status": "paid"},
{"date": "2026-12-02", "order_id": 3004, "qty": 1, "price": 12.0, "status": "refunded"},
{"date": "2026-12-03", "order_id": 3005, "qty": 4, "price": 12.0, "status": "paid"},
{"date": "2026-12-03", "order_id": 3006, "qty": 1, "price": 8.0, "status": "paid"},
{"date": "2026-12-04", "order_id": 3007, "qty": 10, "price": 12.0, "status": "paid"},
{"date": "2026-12-05", "order_id": 3008, "qty": 2, "price": 20.0, "status": "paid"},
{"date": "2026-12-06", "order_id": 3009, "qty": 1, "price": 8.0, "status": "paid"},
{"date": "2026-12-07", "order_id": 3010, "qty": 2, "price": 12.0, "status": "paid"},
{"date": "2026-12-07", "order_id": 3011, "qty": 1, "price": 20.0, "status": "paid"},
]
(السجلات أطول من الحد الإرشادي في PEP 8 وهو 79 حرفًا، لكنها بقيت في سطر واحد لسهولة القراءة.)
الخطوة 1: خطوات بسيطة.
- ابدأ بسجل فارغ للمجاميع اليومية.
- انظر إلى كل بند طلب بدوره.
- تخطَّ البنود غير المدفوعة.
- أضف قيمة البند (الكمية × السعر) إلى مجموع تاريخه.
- بعد آخر بند، اعرض المجاميع اليومية.
الخطوة 2: الكود الوصفي.
INPUT lines
SET daily_totals TO empty mapping
FOR EACH line IN lines
IF line.status = "paid" THEN
SET value TO line.qty × line.price
ADD value TO daily_totals[line.date] -- start from 0 if the date is new
END IF
END FOR
OUTPUT daily_totals
(التعليق يعني: ابدأ من 0 إذا كان التاريخ جديدًا.)
الخطوة 3: تتبّع البنود الأربعة الأولى يدويًا.
| البند | مدفوع؟ | value | daily_totals بعده |
|---|---|---|---|
| 3001 (1 ديسمبر) | نعم | 24.0 | 1 ديسمبر: 24.0 |
| 3002 (1 ديسمبر) | نعم | 20.0 | 1 ديسمبر: 44.0 |
| 3003 (2 ديسمبر) | نعم | 24.0 | 1 ديسمبر: 44.0، 2 ديسمبر: 24.0 |
| 3004 (2 ديسمبر) | لا | — | بلا تغيير |
إكمال التتبّع يعطيك المجاميع للأيام السبعة كلها. ويجب أن يصل مجموعها إلى 336.0 دولار للأسبوع.
الخطوة 4: حوّلها إلى Python سطرًا بسطر. (Run؛ والصق قائمة lines السابقة أولًا.)
def daily_paid_sales(lines):
"""Return a dictionary of paid sales per date (qty * price, paid lines only)."""
daily_totals = {}
for line in lines:
if line["status"] == "paid":
value = line["qty"] * line["price"]
daily_totals[line["date"]] = daily_totals.get(line["date"], 0.0) + value
return daily_totals
daily = daily_paid_sales(lines)
for date, total in daily.items():
print(date, total)
2026-12-01 44.0
2026-12-02 24.0
2026-12-03 56.0
2026-12-04 120.0
2026-12-05 40.0
2026-12-06 8.0
2026-12-07 44.0
كل سطر في Python يقابل سطرًا واحدًا في الكود الوصفي. وهذا يجعل المراجعة سهلة، والإصلاح سهلًا إذا كان الكود الوصفي خاطئًا.
6. شرح بصري
PLAIN STEPS ──► PSEUDOCODE ──► TRACE ON TINY DATA ──► FIX GAPS / REMOVE EXTRA STEPS ──► PYTHON
(what) (precise) (does it work?) (simplest adequate) (how)
One pass: lines ──► [paid?] ──yes──► add qty×price to daily_totals[date]
└──no───► skip
وصف الرسم: رسمان. الأول مسار متتابع: الخطوات البسيطة (ماذا نفعل) تقود إلى الكود الوصفي (خطوات دقيقة)، ثم إلى التتبّع على بيانات صغيرة جدًا (هل يعمل؟)، ثم إلى سد الثغرات وحذف الخطوات الزائدة (أبسط طريقة كافية)، وأخيرًا إلى Python (كيف ننفّذ). والثاني يعرض مرورًا واحدًا على بنود الطلبات. يُفحص كل بند هل هو مدفوع؛ فإذا كان مدفوعًا، يُضاف حاصل ضرب الكمية في السعر إلى مجموع ذلك التاريخ؛ وإذا لم يكن، يُتخطّى البند.
7. تدريب موجَّه
المهمة: عُدّ الطلبات المدفوعة لكل يوم باستخدام lines من المثال المحلول. (Trace OK، ثم Run.)
- اكتب الخطوات البسيطة (من 4 إلى 6 خطوات).
- أكمل قالب الكود الوصفي:
INPUT lines
SET orders_per_day TO ___
FOR EACH line IN lines
IF ___ THEN
ADD 1 TO orders_per_day[line.date]
END IF
END FOR
OUTPUT ___
- تتبّعه يدويًا من 1 ديسمبر إلى 3 ديسمبر.
- (تلميح: فكّر في الطلبات التي فيها أكثر من بند.) في هذه البيانات، لكل طلب بند مدفوع واحد. هل سيبقى الكود الوصفي الذي كتبته صحيحًا إذا كان لطلب ما بندان؟ وإذا لم يكن، فأي خطوة ستضيف؟ أجب بالكلمات؛ لا تحتاج إلى كتابة الكود.
- حوّل الكود الوصفي إلى دالة Python وشغّلها.
8. تدريب مستقل
المهمة: اعثر على اليوم صاحب أعلى مبيعات مدفوعة واليوم صاحب أقل مبيعات مدفوعة، باستخدام مخرجات daily_paid_sales.
- اكتب خطوات بسيطة وكودًا وصفيًا. واستخدم حلقة واحدة تمر على المجاميع اليومية.
- تتبّعه يدويًا على المجاميع اليومية السبعة.
- حدّد حالة واحدة غير واضحة يجب أن يحسمها الكود الوصفي، مثل تساوي يومين، أو مُدخل فارغ، واكتب كيف ستتعامل معها.
- حوّله إلى Python، وشغّله، وقارن النتيجة بتتبّعك.
لا تُعرض هنا إجابة نموذجية.
9. اختبار الفهم — تقييم الكود الوصفي
الجزء A — اختر أفضل إجابة.
A1. أي مما يلي ليس من خصائص الخوارزمية كما عرّفها هذا الدرس؟
- A) خطواتها بترتيب محدد.
- B) يجب أن تُكتب بلغة Python.
- C) تنتهي.
- D) لكل خطوة معنى واحد واضح.
A2. ما الناقص في هذا الكود الوصفي؟
INPUT lines
FOR EACH line IN lines
IF line.status = "paid" THEN
ADD line.qty × line.price TO total
END IF
END FOR
OUTPUT total
- A) لا شيء؛ إنه كامل.
- B) خطوة ترتّب البنود أولًا
- C)
SET total TO 0قبل الحلقة - D) حلقة ثانية للتحقق من النتيجة
A3. الكود الوصفي الذي كتبه زميل لحساب "إجمالي المبيعات المدفوعة للأسبوع" يتضمن: (1) ترتيب البنود حسب التاريخ؛ (2) حذف البنود المستردّة؛ (3) جمع qty × price؛ (4) طباعة كل بند. أي خطوة غير ضرورية للمخرج المطلوب؟
- A) الخطوة 1 (الترتيب)
- B) الخطوة 2
- C) الخطوة 3
- D) لا توجد خطوة غير ضرورية.
A4. تتبّع هذا الكود الوصفي. ما المخرج؟
INPUT sales = [5, 12, 7, 20]
SET flagged TO 0
FOR EACH s IN sales
IF s > 10 THEN
ADD 1 TO flagged
END IF
END FOR
OUTPUT flagged
- A)
1 - B)
3 - C)
4 - D)
2
الجزء B — اكتب كودًا وصفيًا (يُقيَّم بالمعايير). تقرير المخزون في متجر Cedar Lane الخيالي. المدخلات:
stock: ربط (mapping) من المنتج ← عدد الوحدات المتوفرة؛reorder_level: ربط من المنتج ← الحد الأدنى من الوحدات.
المخرج: قائمة بالمنتجات التي يجب إعادة طلبها (الوحدات المتوفرة عند مستوى إعادة الطلب أو أقل منه). والمنتجات غير الموجودة في reorder_level يجب أن تُذكر منفصلة على أنها "no reorder level set" (لم يُحدَّد لها مستوى إعادة طلب).
- اكتب خطوات بسيطة.
- اكتب كودًا وصفيًا باستخدام اصطلاحات D.World.
- تتبّعه على: stock = {Notebook: 40, Pen set: 12, Planner: 5, Bookmark: 30}؛ وreorder_level = {Notebook: 20, Pen set: 15, Planner: 5}.
10. الذكاء الاصطناعي في التطبيق
اطلب من الذكاء الاصطناعي أن يقترح كودًا وصفيًا، ثم بسّطه وحدّد الخطوات غير الضرورية.
- اكتب الكود الوصفي الخاص بك أولًا لمهمة منظور الأعمال (القسم 12).
- الطلب (بيانات مصطنعة فقط):
"Write language-neutral pseudocode for this task: given a list of order lines (date, order_id, qty, price, status), calculate paid sales per day, then flag any day whose paid sales are below 50% or above 150% of the average daily paid sales for the period. State the inputs, outputs and any assumptions. Do not write Python."
وبالعربية: "اكتب كودًا وصفيًا لا يرتبط بلغة برمجة معينة لهذه المهمة: لدينا قائمة ببنود الطلبات (التاريخ، ورقم الطلب، والكمية، والسعر، والحالة)؛ احسب المبيعات المدفوعة لكل يوم، ثم ضع علامة على أي يوم تكون مبيعاته المدفوعة أقل من 50% أو أعلى من 150% من متوسط المبيعات المدفوعة اليومية للفترة. اذكر المدخلات والمخرجات وأي افتراضات. لا تكتب Python."
- بسّط: اشطب كل خطوة لا تغيّر المخرج. ومن الأمثلة المعتادة: الترتيب، أو تحويل صيغة التواريخ، أو تخزين كل بند مرة أخرى، أو حساب إحصاءات إضافية لا تُستخدم أبدًا.
- قارن بالكود الوصفي الذي كتبته. واكتب ما أضافه الذكاء الاصطناعي وفاتك، وما أضافه وهو غير ضروري أو يغيّر القاعدة. مثلًا: هل استخدم الوسيط (median) بدلًا من المتوسط، أو
<=بدلًا من<؟ - تتبّع الكود الوصفي النهائي بعد التبسيط على المجاميع اليومية السبعة قبل كتابة الكود.
11. التحقق من مخرجات الذكاء الاصطناعي
- الالتزام بالقاعدة: تأكد أن كل مقارنة تطابق قاعدة الأعمال بالضبط: المتوسط مقابل الوسيط، و"أقل من" (
<) مقابل "عند أو أقل من" (<=)، و50% و150%. - المدخلات والمخرجات: تأكد أن المدخلات التي ذكرها الذكاء الاصطناعي تطابق البيانات التي لديك، دون حقول لا تملكها، وأن المخرج هو ما يحتاجه صاحب القرار.
- الخطوات غير الضرورية: احذف أي خطوة لا تغيّر المخرج أو أحد الفحوصات. فالكود الوصفي الأقصر والأوضح أسهل في التحقق.
- الحالات الطرفية: اسأل ماذا يحدث عندما لا توجد بنود مدفوعة (لا يمكن حساب متوسط) أو عندما يوجد يوم واحد فقط. وأضف قرارًا لكل حالة.
- تتبّع قبل أن تثق: تتبّع الكود الوصفي النهائي على مجاميع الأيام السبعة الفعلية، وقارن بالعلامات التي توقعتها أنت.
- الخصوصية: بيانات مصطنعة فقط؛ ولا تلصق أبدًا ملفات مبيعات حقيقية مُصدَّرة.
12. منظور الأعمال
صمّم إجراءً لحساب المبيعات اليومية ووضع علامة على القيم غير المعتادة. أصحاب الأعمال لا يلاحظون الأيام الغريبة إلا عندما يبحثون عنها. أما الإجراء البسيط الموثّق فيفحص كل يوم بالطريقة نفسها:
- يجب أن تكون القاعدة صريحة ومتفقًا عليها مع صاحب النشاط. في الحالة المصطنعة لهذه الوحدة: ضع علامة على اليوم إذا كانت مبيعاته المدفوعة أقل من 50% أو أعلى من 150% من متوسط المبيعات المدفوعة اليومية للفترة. وهذه القاعدة افتراض يستطيع صاحب النشاط تغييره، وليست معيارًا عامًا.
- غير المعتاد ≠ الخاطئ. اليوم الذي عليه علامة هو دعوة إلى البحث: ربما طلب كبير، أو عطلة، أو مشكلة في الموقع. وليس استنتاجًا.
- اعرف حدود الطريقة. يوم واحد كبير جدًا يرفع المتوسط نفسه، وقد يغيّر ذلك الأيام الأخرى التي توضع عليها علامة. اكتب هذا القيد بجوار النتيجة.
13. مهمة عمل — المبيعات اليومية مع العلامات
متجر Cedar Lane الخيالي (lines من المثال المحلول).
- اكتب الخطوات البسيطة والكود الوصفي للإجراء الكامل: المبيعات المدفوعة اليومية ← متوسط المبيعات اليومية ← العلامات (القاعدة في القسم 12).
- يدويًا: احسب متوسط المبيعات المدفوعة اليومية، والحدين الأدنى والأعلى، والأيام التي توضع عليها علامة ولماذا.
- حوّل الإجراء إلى Python (يُفضَّل في صورة دالة)، وشغّله، وقارن بنتائجك اليدوية.
- أعِد حساب المتوسط دون اليوم الأعلى. هل تتغير العلامات؟ اكتب جملتين لصاحب المتجر عمّا يعنيه هذا بالنسبة للثقة في القاعدة.
14. تحدٍّ قصير
مستويات الولاء في متجر Cedar Lane الخيالي. القاعدة: إجمالي إنفاق 500 دولار أو أكثر ← Gold؛ و200 دولار أو أكثر ← Silver؛ وفي غير ذلك Standard.
- اكتب كودًا وصفيًا يأخذ ربطًا من رقم العميل ← إجمالي الإنفاق، ويُخرج ربطًا من رقم العميل ← المستوى.
- تتبّعه على: {C01: 520, C02: 200, C03: 199.99, C04: 0}.
- حوّله إلى Python، واكتب خمس حالات اختبار، منها الحدّان كلاهما.
سلّم إجابتك قبل الحصول على التعليقات. لا يوجد حل هنا.
15. المصادر
- مطلوب (حوالي 15 دقيقة): The Python Tutorial، القسمان 4.2 "
forStatements" و4.8 "Defining Functions". ولاحظ النصيحة: "it's good practice to include docstrings in code that you write" (من الممارسات الجيدة أن تضع نصوص توثيق في الكود الذي تكتبه). ونص التوثيق مكان طبيعي لخطواتك المكتوبة بلغة بسيطة. https://docs.python.org/3/tutorial/controlflow.html (فُتح وروجع في 12 أكتوبر 2026.) - موصى به: فهرس The Python Tutorial، لمراجعة موضوعات U04. https://docs.python.org/3/tutorial/ (فُتح وروجع في 12 أكتوبر 2026.)
- للتعمّق (اختياري): صفحة The Art of Computer Programming الخاصة بـ Donald Knuth. راجع القسم 16.
16. شخصية تتابعها / قدوة
Donald Knuth / التفكير الخوارزمي (اختاره D.World).
- حقائق موثّقة (12 أكتوبر 2026): صفحته في جامعة Stanford تصفه بأنه "Professor Emeritus of The Art of Computer Programming at Stanford University" (أستاذ فخري لفن البرمجة في جامعة Stanford) (https://www-cs-faculty.stanford.edu/~knuth/). وصفحة كتابه The Art of Computer Programming (TAOCP) تذكر مجلدات منها المجلد 1، "Fundamental Algorithms"، والمجلد 3، "Sorting and Searching" (https://www-cs-faculty.stanford.edu/~knuth/taocp.html).
- الصلة بالدرس: TAOCP عمل مفصّل جدًا عن الخوارزميات، ويُكتب منذ زمن طويل. وهو يتجاوز هذا الدرس بكثير، لكنه يوضح مدى الجدية التي يتعامل بها علم الحاسوب مع الإجراءات الدقيقة خطوة بخطوة.
- جرّب هذا: افتح صفحة TAOCP واقرأ عناوين المجلدات. واختر عنوانًا واحدًا، واكتب جملة واحدة تخمّن فيها نوع مهمة الأعمال اليومية التي قد يرتبط بها. مثلًا، "Sorting and Searching" (الترتيب والبحث) يرتبط بالعثور على طلب عميل. وصنّف جملتك على أنها تخمين.
17. المصطلحات
| المصطلح | معناه في هذا الدرس |
|---|---|
| الخوارزمية (Algorithm) | مجموعة محدودة ومرتّبة من الخطوات الواضحة تحوّل المدخلات إلى مخرج |
| المُدخل / المخرج (Input / output) | ما يبدأ منه الإجراء / ما ينتجه |
| خطوات بلغة بسيطة (Plain-language steps) | وصف مرقّم يستطيع أي شخص قراءته |
| الكود الوصفي (Pseudocode) | خطوات منظّمة لا ترتبط بلغة برمجة، تستخدم اصطلاحات مثل SET وFOR EACH وIF وOUTPUT |
| التتبّع (Trace) | اتباع الخطوات يدويًا على مثال صغير مع تسجيل القيم |
| المجموع المتراكم (Running total) | قيمة تُحدَّث في كل مرور على البيانات |
| خطوة غير ضرورية (Unnecessary step) | خطوة لا تغيّر المخرج ولا أحد الفحوصات |
| الحد (Threshold) | قيمة فاصلة تُستخدم في قاعدة (مثل 50% من المتوسط) |
| الحالة الطرفية (Edge case) | مُدخل غير معتاد يحتاج إلى قرار (بيانات فارغة، أو تساوٍ) |
| نص التوثيق (Docstring) | نص في بداية دالة Python يصف ما تفعله |
18. تأمّل
قارن الوقت الذي قضيته في كتابة الكود الوصفي بالوقت الذي قضيته في كتابة Python. هل وفّر الكود الوصفي الوقت في المجمل؟ وأين كشف التتبّع شيئًا كان سيفوتك لولاه؟
19. الخطوة التالية
الإجراء الواضح قد يُنفَّذ مع ذلك بشكل خاطئ، أو يعتمد على بيانات لم تتوقعها. في L19 — تصحيح الأخطاء والاختبار والتحقق، ستفرّق بين أخطاء الصياغة وأخطاء وقت التشغيل والأخطاء المنطقية، وتصمّم اختبارات وفحوصات تقارن بأمثلة محلولة يدويًا. وهذه الاختبارات هي ما يجعل النتيجة جديرة بالثقة.
20. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| الجزء A (A1–A4) | فهم خصائص الخوارزمية، والخطوات الناقصة وغير الضرورية؛ وتتبّع الكود الوصفي | 3 إجابات صحيحة أو أكثر من 4 |
| الجزء B (كود وصفي لتقرير المخزون) | كتابة كود وصفي كامل وواضح وتتبّعه | معايير L18-KCB |
| الذكاء الاصطناعي في التطبيق (تبسيط كود الذكاء الاصطناعي الوصفي) | حذف الخطوات غير الضرورية؛ والتحقق من الالتزام بالقاعدة | معايير L18-AI |
| التدريب الموجَّه والمستقل، وعلامات مهمة العمل، والتحدي القصير | الانتقال من الخطوات إلى الكود الوصفي إلى التتبّع إلى Python | معايير L18-GP وL18-IP وL18-WT وL18-MC |
المراجع
- Python Software Foundation. The Python Tutorial، الفصل 4. https://docs.python.org/3/tutorial/controlflow.html (فُتح وروجع في 12 أكتوبر 2026). يدعم: جمل
for؛ والدوال؛ ونصوص التوثيق ("it's good practice to include docstrings in code that you write")؛ و"Use docstrings." - Python Software Foundation. The Python Tutorial (الفهرس). https://docs.python.org/3/tutorial/ (فُتح وروجع في 12 أكتوبر 2026).
- Knuth, D. E. الصفحة الرئيسية وصفحة TAOCP، Stanford University. https://www-cs-faculty.stanford.edu/~knuth/ وhttps://www-cs-faculty.stanford.edu/~knuth/taocp.html (فُتحتا وروجعتا في 12 أكتوبر 2026). يدعم: وصف اللقب؛ وعناوين المجلدات.
- تعريف الخوارزمية، واصطلاحات الكود الوصفي، وقاعدة العلامات 50%/150% اختيارات تعليمية من D.World (والقاعدة افتراض خاص بحالة مصطنعة)، وليست معايير خارجية.
- D.World Curriculum Map v1.0 (صف L18) وCurriculum Bible v1.0. وثائق داخلية.
L19 · Debugging, Testing & VerificationL19 · تصحيح الأخطاء والاختبار والتحقق Freeمجاني
L19 — Debugging, Testing & Verification
Learner file. Answers and model solutions are in a separate instructor-only file. Version: U05 v1.0 · Content date: 12 October 2026. Time estimates are provisional planning guides for a self-paced path, not waiting periods. Code examples were tested with Python 3.13 (see the U05 QA report). Error-message wording can vary slightly between Python versions.
1. Lesson Identity
| Field | Value |
|---|---|
| Title | Debugging, Testing & Verification |
| Stage | Stage 1 — Foundations |
| Unit | U05 — Problem Solving & Computational Thinking |
| Lesson ID | L19 |
| Skills | Testing; debugging; verification |
| Difficulty | Beginner |
| Estimated time | About 2 hours (provisional) |
| Prerequisites | L17–L18 (decomposition; pseudocode; the Cedar Lane December lines and daily_paid_sales). U04 L16 (error types, raise, assert). |
Time breakdown (provisional): concept and worked example, 35 min · guided practice, 15 min · independent practice, 15 min · debugging lab (knowledge check), 25 min · AI in Practice and Verification, 10 min · workplace task, 15 min · mini challenge, 5 min.
2. Learning Objective
By the end of this lesson, you will be able to separate syntax, runtime and logic errors, and design tests and checks that validate results against hand-worked examples. The tests cover normal, boundary, empty and invalid inputs.
D.World map objective (verbatim): Separate syntax, runtime, and logic errors and use tests/checks to validate results.
3. Why It Matters
The most dangerous result is one that looks right:
- a weekly revenue figure that is about 4% too high because refunds were included;
- a "low sales" flag that fires on a normal day because of <= instead of <.
Neither crashes, and both can drive a wrong decision.
In U04 you met error messages and quick tests. This lesson turns that into a method: 1. classify the problem; 2. design tests before trusting results; 3. add checks that confirm the numbers agree with independent calculations.
Key principle: a correct-looking result can still be wrong.
4. Concept
Three kinds of error
| Kind | Definition | When you find out | Example |
|---|---|---|---|
| Syntax error | The code cannot be parsed: it breaks Python's grammar rules | Before anything runs | Missing : after for … gives SyntaxError: expected ':' (Python 3.13 wording) |
| Runtime error | The code is valid but fails during execution (an exception) | While running; the program stops at that line | KeyError: 'quantity'; ZeroDivisionError; TypeError from adding text to a number |
| Logic error | The code runs to the end but gives the wrong answer | Only when you compare with an expected result | Refunded lines included in revenue; <= where the rule says "below" |
Syntax and runtime errors announce themselves. Logic errors stay silent, which is why tests are needed.
Tests: expected vs actual
A test is a specific input with an expected output worked out independently (by hand, from the rule), compared with the actual output of the code. The Python documentation's guide to reporting bugs asks for the same thing: "what you expected to happen and what did happen".
| Test type | Purpose | Example for daily sales |
|---|---|---|
| Normal | Typical data works | Two dates, all paid → known totals |
| Boundary | Values exactly at a rule's edge | A day exactly at 50% of the average (rule says "below") |
| Empty | Nothing to process | [] → {} (no days) |
| Exclusion | Items that must be ignored | Refunded lines do not count |
| Invalid / unexpected | Bad or missing data | A line without qty → a clear error, not a wrong total |
Keep test data tiny, small enough to calculate by hand in a minute.
A simple test helper
You don't need any testing package. A small function prints PASS or FAIL:
def check(name, actual, expected):
"""Print PASS if actual equals expected, otherwise FAIL with both values."""
if actual == expected:
print("PASS", name)
else:
print("FAIL", name, "| expected:", expected, "| got:", actual)
check("two plus two", 2 + 2, 4)
check("deliberate failure", 2 + 2, 5)
PASS two plus two
FAIL deliberate failure | expected: 5 | got: 4
(U04 L16 used assert for quick tests. The Python reference notes that assert statements are skipped when Python runs with the -O optimisation option. Use them for development checks, not as the only safeguard in a real report.)
Checks: does the result agree with itself?
A check (sometimes called a reconciliation or sanity check) compares a result with another, independent calculation:
- Totals reconcile: the sum of the daily totals equals the paid total calculated directly from the lines.
- Nothing impossible: no negative daily sales, and no day that isn't in the data.
- Counts agree: the number of days in the output equals the number of distinct dates with paid lines.
If a check fails, stop and investigate before you report anything.
A debugging routine (from U04, now with tests)
- Reproduce with the smallest input that shows the problem.
- Classify: syntax, runtime or logic?
- Locate: - for syntax and runtime errors, use the line in the message; - for logic errors, trace the pseudocode (L18) and find where the values diverge from your expectation.
- Fix the cause (U04 L16).
- Re-run every test, not only the one that failed.
5. Worked Example
Task: test daily_paid_sales from L18 before trusting its output.
Step 1: hand-worked test data (tiny, synthetic):
| Test | Input lines | Expected output |
|---|---|---|
| T1 normal | d1: 2 × 10.0 paid; d1: 1 × 5.0 paid; d2: 1 × 8.0 paid | {"d1": 25.0, "d2": 8.0} |
| T2 exclusion | d1: 1 × 10.0 refunded; d1: 1 × 4.0 paid | {"d1": 4.0} |
| T3 empty | (no lines) | {} |
Step 2: run the tests (Run):
def check(name, actual, expected):
if actual == expected:
print("PASS", name)
else:
print("FAIL", name, "| expected:", expected, "| got:", actual)
def daily_paid_sales(lines):
"""Return a dictionary of paid sales per date (qty * price, paid lines only)."""
daily_totals = {}
for line in lines:
if line["status"] == "paid":
value = line["qty"] * line["price"]
daily_totals[line["date"]] = daily_totals.get(line["date"], 0.0) + value
return daily_totals
t1 = [
{"date": "d1", "qty": 2, "price": 10.0, "status": "paid"},
{"date": "d1", "qty": 1, "price": 5.0, "status": "paid"},
{"date": "d2", "qty": 1, "price": 8.0, "status": "paid"},
]
t2 = [
{"date": "d1", "qty": 1, "price": 10.0, "status": "refunded"},
{"date": "d1", "qty": 1, "price": 4.0, "status": "paid"},
]
check("T1 normal", daily_paid_sales(t1), {"d1": 25.0, "d2": 8.0})
check("T2 refunded excluded", daily_paid_sales(t2), {"d1": 4.0})
check("T3 empty", daily_paid_sales([]), {})
PASS T1 normal
PASS T2 refunded excluded
PASS T3 empty
Step 3: a reconciliation check on the real week. The sum of the daily totals must equal the paid total calculated independently, directly from the lines. (Paste the L18 lines list and the functions above first.)
daily = daily_paid_sales(lines)
sum_of_days = sum(daily.values())
direct_total = 0.0
for line in lines:
if line["status"] == "paid":
direct_total = direct_total + line["qty"] * line["price"]
check("week reconciles", sum_of_days, direct_total)
check("week matches hand total", direct_total, 336.0)
PASS week reconciles
PASS week matches hand total
sum(...) is a built-in function that adds up the numbers in a collection, here the dictionary's values. The second check compares with the hand-worked total from L18 (336.0). Only after these pass do we trust the daily figures.
6. Visual Explanation
┌──────────────┐ can't parse ──► SYNTAX error (fix grammar)
CODE ───► │ Python reads │
└──────┬───────┘
│ parses OK
┌──────▼───────┐ stops with error ──► RUNTIME error (read last line)
│ Python runs │
└──────┬───────┘
│ finishes
┌──────▼──────────────────────┐
│ actual == expected (by hand)?│── no ──► LOGIC error (trace, fix cause)
└──────┬──────────────────────┘
│ yes, for normal, boundary, empty, exclusion, invalid tests + checks
▼
result can be trusted for this purpose
Alt text: A flowchart of three stages: 1. Python reads the code. If it cannot parse it, that is a syntax error: fix the grammar. 2. Python runs the code. If it stops with an error, that is a runtime error: read the last line of the message. 3. The program finishes, and its actual output is compared with the expected output worked out by hand. If they differ, that is a logic error: trace and fix the cause.
Only when the normal, boundary, empty, exclusion and invalid tests and the checks all pass can the result be trusted for its purpose.
7. Guided Practice
Test the flag rule from L18. Rule (synthetic assumption): flag a day LOW if its paid sales are below 50% of the average daily paid sales, and HIGH if above 150%.
- Hand-work three tiny test cases, using daily totals rather than lines:
- normal: {a: 5, b: 15, c: 40}. Average 20 → thresholds 10 and 30. What is flagged?
- boundary: {a: 10, b: 30, c: 20}. Average 20 → is
a(exactly 10) flagged? Isb(exactly 30)? - single day: {a: 50}. What should happen? - Write each as a row: input → expected flags.
- (Hint: "below" and "above" are strict.) Write the Python comparison for LOW and for HIGH that matches the rule exactly.
8. Independent Practice
Write a test plan for daily_paid_sales that covers all five test types in Section 4 (normal, boundary-like, empty, exclusion, invalid).
- For each test, give: name, tiny input, expected output (by hand) and the reason for the test.
- For the invalid case (a line without
"qty"), decide what the correct behaviour should be: a clear error or a silent skip. Justify your choice in two sentences, thinking about what the business needs. - Run your tests against the L18 function with the
checkhelper, and record PASS/FAIL.
No model answer is shown here.
9. Knowledge Check — Debugging Lab
Part A — Classify and choose.
A1. A program will not start, and the message ends with SyntaxError: expected ':'. What kind of error is it?
- A) Logic error
- B) Runtime error
- C) Syntax error
- D) Not an error
A2. A weekly report prints 348.0 USD. The hand-worked total is 336.0 USD. There is no error message. What kind of error is it? - A) Logic error - B) Syntax error - C) Runtime error - D) A rounding difference, so it can be ignored
A3. A program processes three lines, then stops with KeyError: 'quantity'. What kind of error is it?
- A) Syntax error
- B) Logic error
- C) Not an error, because the first three lines were processed
- D) Runtime error
A4. Which test is most likely to catch a <= written where the rule says "below 50% of average"?
- A) A day with sales far below the threshold
- B) A day with sales exactly at the threshold
- C) A day with sales far above the threshold
- D) A week with no sales at all
A5. Why is "the program printed a number" not enough to trust a revenue result? - A) Printing always rounds numbers. - B) Python cannot add decimal numbers correctly. - C) A logic error can produce a plausible number with no message; only comparison with an independent expected value reveals it. - D) Numbers should always be shown in a chart.
A6. Which check best confirms that a daily-sales calculation did not lose or duplicate any sales? - A) Checking that the code follows PEP 8 - B) Checking that the output has at least one day - C) Running the program twice - D) Checking that the sum of daily totals equals the paid total calculated directly from the lines
Part B — Debugging lab (Run). For each program:
1. run it (paste the L18 lines list first where needed);
2. classify the error (syntax / runtime / logic);
3. state the cause in one sentence;
4. fix it with the smallest change;
5. show one test or check that now passes and would have caught the problem.
Lab 1
total = 0.0
for line in lines
if line["status"] == "paid":
total = total + line["qty"] * line["price"]
print(total)
Lab 2
total = 0.0
for line in lines:
if line["status"] == "paid":
total = total + line["quantity"] * line["price"]
print(total)
Lab 3 (expected weekly paid total: 336.0)
daily_totals = {}
for line in lines:
value = line["qty"] * line["price"]
daily_totals[line["date"]] = daily_totals.get(line["date"], 0.0) + value
print(daily_totals["2026-12-02"], sum(daily_totals.values()))
Lab 4 (rule: LOW if below 50% of average)
daily = {"2026-12-01": 44.0, "2026-12-02": 24.0, "2026-12-03": 56.0,
"2026-12-04": 120.0, "2026-12-05": 40.0, "2026-12-06": 8.0,
"2026-12-07": 44.0}
average = sum(daily.values()) / len(daily)
for date, value in daily.items():
if value <= 0.5 * average:
print("LOW", date, value)
10. AI in Practice
Ask AI to invent likely failure cases, then write checks that catch them.
- Prompt (synthetic code only):
"Here is a beginner Python function that calculates paid sales per day from order lines (code below). List 8 realistic ways the function or its input data could produce a wrong or misleading result. Examples: refunds, duplicates, missing fields, wrong types, dates in different formats. For each, give a tiny test input and the expected correct behaviour. Do not rewrite the function. """ (paste daily_paid_sales from Section 5) """
- Sort the AI's failure cases into three groups: - already handled by the function; - not handled, and it matters for Cedar Lane; - not relevant to this data.
- For at least three cases that matter, write the test yourself with the
checkhelper. Work out the expected result by hand from the business rule, not from the AI. - Run the tests against the L18 function and against the Lab 3 program, which counts refunded lines. Record which tests catch the Lab 3 bug.
- For any "duplicate line" case, note that the function cannot tell a real repeat purchase from a duplicated export line on its own. Record this as a data-quality question for the owner, not as a code fix.
11. AI Verification
- Run every proposed test. An untested test idea is not evidence.
- Expected values come from the rule, worked out by you. If the AI's expected value differs, re-check by hand before accepting either.
- Check relevance: discard failure cases that cannot happen with your data source, but write down why.
- Watch for "fixes" you did not ask for. The task is to find failures and write checks, not to let the AI rewrite the function.
- Data vs code: some problems, such as duplicated exports or mixed date formats, are data-quality issues (U03 L10). Decide them with the data owner rather than hiding them in code.
- Privacy: synthetic lines only; never paste real order exports.
12. Business Lens
Validate a revenue calculation against hand-worked examples. Before a revenue figure goes into a report or decision:
- Hand-work a tiny case that covers each rule (paid, refunded, several lines on one day), and make sure the code matches it.
- Reconcile totals two ways: by day, and directly from the lines.
- Compare with a trusted reference where one exists, such as last month's agreed figure re-run with the new code.
- Record the checks next to the result: "Validated: 5 tests PASS; weekly total reconciles (336.0)."
Being able to show how a number was checked is what earns trust with a decision owner.
13. Workplace Task — Test Pack for the Flag Function
Fictional Cedar Lane. A colleague wrote this function for the L18 flag rule (Run):
def flag_unusual_days(daily, low_share=0.5, high_share=1.5):
"""Return a dictionary date -> "LOW" or "HIGH" for unusual days."""
average = sum(daily.values()) / len(daily)
flags = {}
for date, value in daily.items():
if value < low_share * average:
flags[date] = "LOW"
elif value > high_share * average:
flags[date] = "HIGH"
return flags
- Write a test pack of at least six tests using
check: - normal; - both boundaries (exactly 50% and exactly 150%); - no unusual days; - the real Cedar Lane week from L18; - an empty input. - Work out every expected result by hand first.
- Run the tests. For any failure, classify the error and decide the correct behaviour. For example, what should happen with no days at all? Then fix the cause and re-run all tests.
- Write a 3-line validation note for the owner: what was tested, what was fixed, and the results.
14. Mini Challenge
Fictional Cedar Lane bulk discount (U04 L14 rule: 100 or more units → 10%; 50 to 99 → 5%; otherwise 0%). A colleague says this version is "already tested":
def bulk_discount_rate(quantity):
if quantity >= 100:
return 0.10
elif quantity > 50:
return 0.05
else:
return 0.0
- Design five tests, including all relevant boundaries, with expected rates worked out from the rule.
- Run them and find the bug. Classify it and fix it.
- Explain in one sentence why the colleague's tests, quantities 10, 75 and 150, all passed.
Submit before feedback. No solution is provided here.
15. Resources
- Required (about 10 min): PEP 8 – Style Guide for Python Code: the section "A Foolish Consistency is the Hobgoblin of Little Minds" and the "Comments" section. Note: "Comments that contradict the code are worse than no comments." Readable code is easier to verify. https://peps.python.org/pep-0008/ (Opened and checked 12 Oct 2026.)
- Required (about 10 min): The Python Tutorial, ch. 8, "Errors and Exceptions", sections 8.1–8.2. https://docs.python.org/3/tutorial/errors.html (Opened and checked 12 Oct 2026.)
- Recommended: Python documentation, Dealing with Bugs. https://docs.python.org/3/bugs.html (Opened and checked 12 Oct 2026.)
- Deeper (optional): The Python Language Reference, "The
assertstatement" (section 7.3), including what happens with the-Ooption. https://docs.python.org/3/reference/simple_stmts.html (Opened and checked 12 Oct 2026.)
16. Person to Follow / Role Model
Community perspective: Python maintainers (no named person). The D.World map lists a group, not an individual.
Try this: read the Python documentation page Dealing with Bugs (https://docs.python.org/3/bugs.html). It asks reporters to "describe the problem in detail, including what you expected to happen and what did happen", and to give version information. Write a short "bug report" for one of your Part B lab programs in that format: - a title of fewer than ten words; - what you expected; - what happened; - your Python version.
This is exactly the expected-vs-actual habit of this lesson.
17. Glossary
| Term | Meaning in this lesson |
|---|---|
| Syntax error | Code that cannot be parsed because it breaks Python's grammar |
| Runtime error | Valid code that fails during execution (an exception) |
| Logic error | Code that runs but gives a wrong result |
| Test | A specific input with an independently worked-out expected output, compared with the actual output |
| Expected / actual | What the result should be (by hand, from the rule) / what the code produced |
| Normal / boundary / empty / exclusion / invalid test | Test types: typical data / exactly at a rule's edge / no data / items that must be ignored / bad or missing data |
| Check (reconciliation) | Comparing a result with an independent calculation of the same thing |
| Test pack | A set of tests kept together and re-run after every change |
| Regression | A fix that breaks something that used to work; caught by re-running all tests |
sum() |
Built-in function that adds the numbers in a collection |
18. Reflection
Which lab bug would you most likely have missed without a test or a check? What will you now always do before reporting a number, even when you are short of time?
19. Next Step
You can now decompose a question (L17), plan a procedure (L18), and test and verify the result (L19). In L20 — Foundations Mini Project, you will put it all together. Starting from a business question about a retail transaction list, you will produce a verified Python answer and a recommendation grounded in the evidence.
20. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Part A (A1–A6) | Classifies errors; chooses tests and checks | 5 or more of 6 correct |
| Part B debugging lab (Labs 1–4) | Classifies, finds causes, fixes, and proves the fix with a test or check | Rubric L19-KCB; all four classified correctly and Labs 3–4 fixed with a passing test |
| AI in Practice (failure cases → checks) | Turns AI ideas into runnable tests with independent expectations | Rubric L19-AI |
| Guided and independent practice, workplace test pack, mini challenge | Designs normal, boundary, empty, exclusion and invalid tests; validates against hand-worked results | Rubrics L19-GP, L19-IP, L19-WT, L19-MC |
References
- van Rossum, G., Warsaw, B., & Coghlan, A. PEP 8 – Style Guide for Python Code. https://peps.python.org/pep-0008/ (opened and checked 12 Oct 2026). Supports: section "A Foolish Consistency is the Hobgoblin of Little Minds"; "code is read much more often than it is written"; "Comments that contradict the code are worse than no comments."
- Python Software Foundation. The Python Tutorial, ch. 8. https://docs.python.org/3/tutorial/errors.html (opened and checked 12 Oct 2026). Supports: syntax errors vs exceptions; the last line of the message indicates what happened.
- Python Software Foundation. Dealing with Bugs. https://docs.python.org/3/bugs.html (opened and checked 12 Oct 2026). Supports: "describe the problem in detail, including what you expected to happen and what did happen"; a short title of "fewer than ten words".
- Python Software Foundation. The Python Language Reference, §7.3 "The
assertstatement". https://docs.python.org/3/reference/simple_stmts.html (opened and checked 12 Oct 2026). Supports: assertions are not executed when optimisation (-O) is requested. - D.World Curriculum Map v1.0 (L19 row) and Curriculum Bible v1.0 (AI Integration Standard: "Run it, inspect assumptions, add tests and compare with expected behavior"). Internal.
L19 — تصحيح الأخطاء والاختبار والتحقق
ملف المتعلّم. الإجابات والحلول النموذجية في ملف منفصل خاص بالمدرّس فقط. الإصدار: U05 v1.0 · تاريخ المحتوى: 12 أكتوبر 2026. تقديرات الوقت إرشادات مبدئية للتخطيط في مسار ذاتي الوتيرة، وليست فترات انتظار. أمثلة الكود مُختبَرة على Python 3.13 (راجع تقرير الجودة QA الخاص بـ U05). صياغة رسائل الخطأ قد تختلف قليلًا بين إصدارات Python.
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | تصحيح الأخطاء والاختبار والتحقق |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U05 — حل المشكلات والتفكير الحاسوبي |
| رقم الدرس | L19 |
| المهارات | الاختبار؛ تصحيح الأخطاء؛ التحقق |
| المستوى | مبتدئ |
| الوقت المتوقع | حوالي ساعتين (مبدئي) |
| المتطلبات السابقة | L17–L18 (التفكيك؛ والكود الوصفي؛ وبيانات lines لشهر ديسمبر في Cedar Lane والدالة daily_paid_sales). وL16 في U04 (أنواع الأخطاء، وraise، وassert). |
تفصيل الوقت (مبدئي): المفهوم والمثال المحلول 35 دقيقة · التدريب الموجَّه 15 دقيقة · التدريب المستقل 15 دقيقة · معمل تصحيح الأخطاء (اختبار الفهم) 25 دقيقة · الذكاء الاصطناعي في التطبيق والتحقق 10 دقائق · مهمة العمل 15 دقيقة · التحدي القصير 5 دقائق.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تفرّق بين أخطاء الصياغة وأخطاء وقت التشغيل والأخطاء المنطقية، وأن تصمّم اختبارات وفحوصات تتحقق من النتائج بمقارنتها بأمثلة محلولة يدويًا. وتغطي الاختبارات المدخلات العادية، والحدّية، والفارغة، وغير الصالحة.
هدف خريطة D.World (بنصّه): Separate syntax, runtime, and logic errors and use tests/checks to validate results.
3. لماذا يهمّك هذا؟
أخطر نتيجة هي النتيجة التي تبدو صحيحة:
- رقم إيرادات أسبوعية أعلى من الصحيح بحوالي 4% لأن الاستردادات حُسبت ضمنه؛
- علامة "مبيعات منخفضة" تظهر على يوم عادي بسبب استخدام
<=بدلًا من<.
لا أحد من الخطأين يوقف البرنامج، وكلاهما قد يقود إلى قرار خاطئ.
في U04 تعرّفت على رسائل الخطأ والاختبارات السريعة. وهذا الدرس يحوّل ذلك إلى منهج:
- صنّف المشكلة؛
- صمّم الاختبارات قبل أن تثق في النتائج؛
- أضف فحوصات تؤكد أن الأرقام تتفق مع حسابات مستقلة.
المبدأ الأساسي: النتيجة التي تبدو صحيحة قد تكون خاطئة مع ذلك.
4. المفهوم
ثلاثة أنواع من الأخطاء
| النوع | التعريف | متى تكتشفه | مثال |
|---|---|---|---|
| خطأ صياغة (Syntax error) | الكود لا يمكن تحليله (parse): فهو يخالف قواعد لغة Python | قبل أن يعمل أي شيء | نسيان : بعد for … يعطي SyntaxError: expected ':' (بصياغة Python 3.13) |
| خطأ وقت التشغيل (Runtime error) | الكود صحيح الصياغة لكنه يفشل أثناء التنفيذ (استثناء exception) | أثناء التشغيل؛ ويتوقف البرنامج عند ذلك السطر | KeyError: 'quantity'؛ وZeroDivisionError؛ وTypeError عند جمع نص مع رقم |
| خطأ منطقي (Logic error) | الكود يعمل حتى النهاية لكنه يعطي إجابة خاطئة | فقط عندما تقارنه بنتيجة متوقعة | حساب البنود المستردّة ضمن الإيرادات؛ أو استخدام <= بينما القاعدة تقول "أقل من" |
أخطاء الصياغة وأخطاء وقت التشغيل تُعلن عن نفسها. أما الأخطاء المنطقية فتبقى صامتة، ولهذا نحتاج إلى الاختبارات.
الاختبارات: المتوقع مقابل الفعلي
الاختبار (test) مُدخل محدد له مخرج متوقع محسوب بشكل مستقل (يدويًا، من القاعدة)، ويُقارن بـ المخرج الفعلي للكود. ودليل توثيق Python الخاص بالإبلاغ عن الأخطاء يطلب الشيء نفسه: "what you expected to happen and what did happen" (ما الذي توقعت حدوثه وما الذي حدث فعلًا).
| نوع الاختبار | الغرض | مثال للمبيعات اليومية |
|---|---|---|
| عادي (Normal) | البيانات المعتادة تعمل | تاريخان، وكل البنود مدفوعة ← مجاميع معروفة |
| حدّي (Boundary) | قيم عند حد القاعدة بالضبط | يوم عند 50% من المتوسط بالضبط (والقاعدة تقول "أقل من") |
| فارغ (Empty) | لا يوجد شيء للمعالجة | [] ← {} (لا أيام) |
| استبعاد (Exclusion) | عناصر يجب تجاهلها | البنود المستردّة لا تُحسب |
| غير صالح / غير متوقع (Invalid / unexpected) | بيانات سيئة أو ناقصة | بند بلا qty ← خطأ واضح، وليس مجموعًا خاطئًا |
اجعل بيانات الاختبار صغيرة جدًا، بحيث تستطيع حسابها يدويًا في دقيقة.
دالة مساعدة بسيطة للاختبار
لا تحتاج إلى أي حزمة اختبار. دالة صغيرة تطبع PASS (نجح) أو FAIL (فشل):
def check(name, actual, expected):
"""Print PASS if actual equals expected, otherwise FAIL with both values."""
if actual == expected:
print("PASS", name)
else:
print("FAIL", name, "| expected:", expected, "| got:", actual)
check("two plus two", 2 + 2, 4)
check("deliberate failure", 2 + 2, 5)
PASS two plus two
FAIL deliberate failure | expected: 5 | got: 4
(استخدم L16 في U04 جملة assert للاختبارات السريعة. ويذكر المرجع الرسمي للغة Python أن جمل assert تُتخطّى عندما يعمل Python بخيار التحسين -O. استخدمها لفحوصات أثناء التطوير، لا كوسيلة الحماية الوحيدة في تقرير حقيقي.)
الفحوصات: هل تتسق النتيجة مع نفسها؟
الفحص (check؛ ويسمى أحيانًا المطابقة reconciliation أو فحص المعقولية sanity check) يقارن النتيجة بحساب آخر مستقل:
- المجاميع متطابقة: مجموع المجاميع اليومية يساوي الإجمالي المدفوع المحسوب مباشرة من البنود.
- لا شيء مستحيل: لا توجد مبيعات يومية سالبة، ولا يوجد يوم غير موجود في البيانات.
- الأعداد متفقة: عدد الأيام في المخرج يساوي عدد التواريخ المختلفة التي فيها بنود مدفوعة.
إذا فشل فحص، توقّف وابحث قبل أن تعرض أي شيء.
روتين تصحيح الأخطاء (من U04، والآن مع الاختبارات)
- أعِد إنتاج المشكلة بأصغر مُدخل يُظهرها.
- صنّف: صياغة، أم وقت تشغيل، أم منطقي؟
- حدّد المكان:
- في أخطاء الصياغة ووقت التشغيل، استخدم السطر المذكور في الرسالة؛
- في الأخطاء المنطقية، تتبّع الكود الوصفي (L18) واعثر على النقطة التي تبتعد فيها القيم عن توقعك.
- أصلِح السبب (L16 في U04).
- أعِد تشغيل كل الاختبارات، وليس الاختبار الذي فشل فقط.
5. مثال محلول
المهمة: اختبر الدالة daily_paid_sales من L18 قبل أن تثق في مخرجاتها.
الخطوة 1: بيانات اختبار محلولة يدويًا (صغيرة جدًا، ومصطنعة):
| الاختبار | البنود المُدخلة | المخرج المتوقع |
|---|---|---|
| T1 عادي | d1: 2 × 10.0 مدفوع؛ d1: 1 × 5.0 مدفوع؛ d2: 1 × 8.0 مدفوع | {"d1": 25.0, "d2": 8.0} |
| T2 استبعاد | d1: 1 × 10.0 مستردّ؛ d1: 1 × 4.0 مدفوع | {"d1": 4.0} |
| T3 فارغ | (لا بنود) | {} |
الخطوة 2: شغّل الاختبارات (Run):
def check(name, actual, expected):
if actual == expected:
print("PASS", name)
else:
print("FAIL", name, "| expected:", expected, "| got:", actual)
def daily_paid_sales(lines):
"""Return a dictionary of paid sales per date (qty * price, paid lines only)."""
daily_totals = {}
for line in lines:
if line["status"] == "paid":
value = line["qty"] * line["price"]
daily_totals[line["date"]] = daily_totals.get(line["date"], 0.0) + value
return daily_totals
t1 = [
{"date": "d1", "qty": 2, "price": 10.0, "status": "paid"},
{"date": "d1", "qty": 1, "price": 5.0, "status": "paid"},
{"date": "d2", "qty": 1, "price": 8.0, "status": "paid"},
]
t2 = [
{"date": "d1", "qty": 1, "price": 10.0, "status": "refunded"},
{"date": "d1", "qty": 1, "price": 4.0, "status": "paid"},
]
check("T1 normal", daily_paid_sales(t1), {"d1": 25.0, "d2": 8.0})
check("T2 refunded excluded", daily_paid_sales(t2), {"d1": 4.0})
check("T3 empty", daily_paid_sales([]), {})
PASS T1 normal
PASS T2 refunded excluded
PASS T3 empty
الخطوة 3: فحص مطابقة على الأسبوع الحقيقي. يجب أن يساوي مجموع المجاميع اليومية الإجمالي المدفوع المحسوب بشكل مستقل، مباشرة من البنود. (الصق قائمة lines من L18 والدالتين السابقتين أولًا.)
daily = daily_paid_sales(lines)
sum_of_days = sum(daily.values())
direct_total = 0.0
for line in lines:
if line["status"] == "paid":
direct_total = direct_total + line["qty"] * line["price"]
check("week reconciles", sum_of_days, direct_total)
check("week matches hand total", direct_total, 336.0)
PASS week reconciles
PASS week matches hand total
sum(...) دالة مدمجة في Python تجمع الأرقام الموجودة في مجموعة، وهي هنا قيم القاموس. والفحص الثاني يقارن بالإجمالي المحسوب يدويًا في L18 (336.0). ولا نثق في الأرقام اليومية إلا بعد أن تنجح هذه الفحوصات.
6. شرح بصري
┌──────────────┐ can't parse ──► SYNTAX error (fix grammar)
CODE ───► │ Python reads │
└──────┬───────┘
│ parses OK
┌──────▼───────┐ stops with error ──► RUNTIME error (read last line)
│ Python runs │
└──────┬───────┘
│ finishes
┌──────▼──────────────────────┐
│ actual == expected (by hand)?│── no ──► LOGIC error (trace, fix cause)
└──────┬──────────────────────┘
│ yes, for normal, boundary, empty, exclusion, invalid tests + checks
▼
result can be trusted for this purpose
وصف الرسم: مخطط من ثلاث مراحل:
- يقرأ Python الكود. إذا لم يستطع تحليله، فهذا خطأ صياغة: أصلِح قواعد الكتابة.
- يشغّل Python الكود. إذا توقف بخطأ، فهذا خطأ وقت تشغيل: اقرأ السطر الأخير من الرسالة.
- ينتهي البرنامج، ويُقارن مخرجه الفعلي بالمخرج المتوقع المحسوب يدويًا. إذا اختلفا، فهذا خطأ منطقي: تتبّع الكود وأصلِح السبب.
ولا يمكن الوثوق بالنتيجة لغرضها إلا عندما تنجح كل الاختبارات: العادية والحدّية والفارغة والاستبعاد وغير الصالحة، ومعها الفحوصات.
7. تدريب موجَّه
اختبر قاعدة العلامات من L18. القاعدة (افتراض مصطنع): ضع علامة LOW على اليوم إذا كانت مبيعاته المدفوعة أقل من 50% من متوسط المبيعات المدفوعة اليومية، وHIGH إذا كانت أعلى من 150%.
- احسب يدويًا ثلاث حالات اختبار صغيرة جدًا، باستخدام المجاميع اليومية بدلًا من البنود:
- عادية: {a: 5, b: 15, c: 40}. المتوسط 20 ← الحدّان 10 و30. ما الذي توضع عليه علامة؟
- حدّية: {a: 10, b: 30, c: 20}. المتوسط 20 ← هل توضع علامة على
a(10 بالضبط)؟ وعلىb(30 بالضبط)؟ - يوم واحد: {a: 50}. ماذا يجب أن يحدث؟
- اكتب كل حالة في صف: المُدخل ← العلامات المتوقعة.
- (تلميح: "أقل من" و"أعلى من" مقارنتان صارمتان.) اكتب مقارنة Python لـ LOW ولـ HIGH بحيث تطابق القاعدة بالضبط.
8. تدريب مستقل
اكتب خطة اختبار للدالة daily_paid_sales تغطي الأنواع الخمسة كلها المذكورة في القسم 4 (العادي، وما يشبه الحدّي، والفارغ، والاستبعاد، وغير الصالح).
- لكل اختبار، اذكر: الاسم، والمُدخل الصغير، والمخرج المتوقع (يدويًا)، وسبب الاختبار.
- في الحالة غير الصالحة (بند بلا
"qty")، قرّر ما السلوك الصحيح: خطأ واضح أم تخطٍّ صامت. وبرّر اختيارك في جملتين، مع التفكير فيما تحتاجه الأعمال. - شغّل اختباراتك على دالة L18 باستخدام الدالة المساعدة
check، وسجّل PASS/FAIL.
لا تُعرض هنا إجابة نموذجية.
9. اختبار الفهم — معمل تصحيح الأخطاء
الجزء A — صنّف واختر.
A1. برنامج لا يبدأ، والرسالة تنتهي بـ SyntaxError: expected ':'. ما نوع هذا الخطأ؟
- A) خطأ منطقي
- B) خطأ وقت التشغيل
- C) خطأ صياغة
- D) ليس خطأً
A2. تقرير أسبوعي يطبع 348.0 دولار. والإجمالي المحسوب يدويًا 336.0 دولار. ولا توجد رسالة خطأ. ما نوع هذا الخطأ؟
- A) خطأ منطقي
- B) خطأ صياغة
- C) خطأ وقت التشغيل
- D) فرق تقريب، ولذلك يمكن تجاهله
A3. برنامج يعالج ثلاثة بنود، ثم يتوقف برسالة KeyError: 'quantity'. ما نوع هذا الخطأ؟
- A) خطأ صياغة
- B) خطأ منطقي
- C) ليس خطأً، لأن البنود الثلاثة الأولى عولجت
- D) خطأ وقت التشغيل
A4. أي اختبار هو الأرجح أن يكشف استخدام <= حيث تقول القاعدة "أقل من 50% من المتوسط"؟
- A) يوم مبيعاته أقل من الحد بكثير
- B) يوم مبيعاته عند الحد بالضبط
- C) يوم مبيعاته أعلى من الحد بكثير
- D) أسبوع لا توجد فيه مبيعات على الإطلاق
A5. لماذا لا تكفي عبارة "البرنامج طبع رقمًا" للثقة في نتيجة الإيرادات؟
- A) الطباعة تقرّب الأرقام دائمًا.
- B) Python لا يستطيع جمع الأرقام العشرية بشكل صحيح.
- C) الخطأ المنطقي قد ينتج رقمًا معقولًا دون أي رسالة؛ ولا تكشفه إلا المقارنة بقيمة متوقعة مستقلة.
- D) يجب عرض الأرقام دائمًا في رسم بياني.
A6. أي فحص يؤكد على أفضل وجه أن حساب المبيعات اليومية لم يُضِع أي مبيعات ولم يكررها؟
- A) التأكد من أن الكود يتبع PEP 8
- B) التأكد من أن المخرج فيه يوم واحد على الأقل
- C) تشغيل البرنامج مرتين
- D) التأكد من أن مجموع المجاميع اليومية يساوي الإجمالي المدفوع المحسوب مباشرة من البنود
الجزء B — معمل تصحيح الأخطاء (Run). لكل برنامج:
- شغّله (والصق قائمة
linesمن L18 أولًا عند الحاجة)؛ - صنّف الخطأ (صياغة / وقت تشغيل / منطقي)؛
- اذكر السبب في جملة واحدة؛
- أصلِحه بأصغر تغيير ممكن؛
- اعرض اختبارًا أو فحصًا واحدًا ينجح الآن وكان سيكشف المشكلة.
المعمل 1
total = 0.0
for line in lines
if line["status"] == "paid":
total = total + line["qty"] * line["price"]
print(total)
المعمل 2
total = 0.0
for line in lines:
if line["status"] == "paid":
total = total + line["quantity"] * line["price"]
print(total)
المعمل 3 (الإجمالي المدفوع الأسبوعي المتوقع: 336.0)
daily_totals = {}
for line in lines:
value = line["qty"] * line["price"]
daily_totals[line["date"]] = daily_totals.get(line["date"], 0.0) + value
print(daily_totals["2026-12-02"], sum(daily_totals.values()))
المعمل 4 (القاعدة: LOW إذا كانت أقل من 50% من المتوسط)
daily = {"2026-12-01": 44.0, "2026-12-02": 24.0, "2026-12-03": 56.0,
"2026-12-04": 120.0, "2026-12-05": 40.0, "2026-12-06": 8.0,
"2026-12-07": 44.0}
average = sum(daily.values()) / len(daily)
for date, value in daily.items():
if value <= 0.5 * average:
print("LOW", date, value)
10. الذكاء الاصطناعي في التطبيق
اطلب من الذكاء الاصطناعي أن يتخيّل حالات فشل محتملة، ثم اكتب فحوصات تكشفها.
- الطلب (كود مصطنع فقط):
"Here is a beginner Python function that calculates paid sales per day from order lines (code below). List 8 realistic ways the function or its input data could produce a wrong or misleading result. Examples: refunds, duplicates, missing fields, wrong types, dates in different formats. For each, give a tiny test input and the expected correct behaviour. Do not rewrite the function. """ (paste daily_paid_sales from Section 5) """
وبالعربية: "هذه دالة Python كتبها مبتدئ تحسب المبيعات المدفوعة لكل يوم من بنود الطلبات (الكود بالأسفل). اذكر 8 طرق واقعية قد تجعل الدالة أو بياناتها المُدخلة تنتج نتيجة خاطئة أو مضلِّلة. أمثلة: الاستردادات، والتكرار، والحقول الناقصة، والأنواع الخاطئة، والتواريخ بصيغ مختلفة. ولكل منها، أعطِ مُدخل اختبار صغيرًا جدًا والسلوك الصحيح المتوقع. لا تُعِد كتابة الدالة. """ (الصق daily_paid_sales من القسم 5) """"
- صنّف حالات الفشل التي ذكرها الذكاء الاصطناعي في ثلاث مجموعات:
- تعالجها الدالة بالفعل؛
- لا تعالجها، وهي مهمة لمتجر Cedar Lane؛
- لا علاقة لها بهذه البيانات.
- لـ ثلاث حالات على الأقل من الحالات المهمة، اكتب الاختبار بنفسك باستخدام الدالة المساعدة
check. واحسب النتيجة المتوقعة يدويًا من قاعدة الأعمال، وليس من الذكاء الاصطناعي. - شغّل الاختبارات على دالة L18 وعلى برنامج المعمل 3، الذي يحسب البنود المستردّة. وسجّل أي الاختبارات تكشف خطأ المعمل 3.
- في أي حالة "بند مكرر"، لاحظ أن الدالة لا تستطيع وحدها أن تفرّق بين عملية شراء حقيقية متكررة وبند تكرر بالخطأ في الملف المُصدَّر. وسجّل ذلك كـ سؤال عن جودة البيانات لصاحب المتجر، لا كإصلاح في الكود.
11. التحقق من مخرجات الذكاء الاصطناعي
- شغّل كل اختبار مقترح. فكرة الاختبار التي لم تُشغَّل ليست دليلًا.
- القيم المتوقعة تأتي من القاعدة، وتحسبها أنت. وإذا اختلفت القيمة المتوقعة التي ذكرها الذكاء الاصطناعي، فأعِد المراجعة يدويًا قبل أن تقبل أيًّا منهما.
- تأكد من الصلة: استبعد حالات الفشل التي لا يمكن أن تحدث مع مصدر بياناتك، لكن اكتب السبب.
- انتبه لـ "الإصلاحات" التي لم تطلبها. المهمة هي العثور على حالات الفشل وكتابة الفحوصات، لا ترك الذكاء الاصطناعي يعيد كتابة الدالة.
- البيانات مقابل الكود: بعض المشكلات، مثل الملفات المُصدَّرة المكررة أو صيغ التواريخ المختلطة، هي مشكلات جودة بيانات (L10 في U03). قرّر فيها مع صاحب البيانات بدلًا من إخفائها داخل الكود.
- الخصوصية: بنود مصطنعة فقط؛ ولا تلصق أبدًا ملفات طلبات حقيقية مُصدَّرة.
12. منظور الأعمال
تحقّق من حساب الإيرادات بمقارنته بأمثلة محلولة يدويًا. قبل أن يدخل رقم الإيرادات في تقرير أو قرار:
- احسب يدويًا حالة صغيرة جدًا تغطي كل قاعدة (المدفوع، والمستردّ، وعدة بنود في يوم واحد)، وتأكد أن الكود يطابقها.
- طابق المجاميع بطريقتين: حسب اليوم، ومباشرة من البنود.
- قارن بمرجع موثوق إذا وُجد، مثل رقم الشهر الماضي المتفق عليه بعد إعادة حسابه بالكود الجديد.
- سجّل الفحوصات بجوار النتيجة: "تم التحقق: 5 اختبارات PASS؛ والإجمالي الأسبوعي متطابق (336.0)."
القدرة على أن توضّح كيف روجع الرقم هي ما يكسبك ثقة صاحب القرار.
13. مهمة عمل — حزمة اختبارات لدالة العلامات
متجر Cedar Lane الخيالي. كتب زميل هذه الدالة لقاعدة العلامات في L18 (Run):
def flag_unusual_days(daily, low_share=0.5, high_share=1.5):
"""Return a dictionary date -> "LOW" or "HIGH" for unusual days."""
average = sum(daily.values()) / len(daily)
flags = {}
for date, value in daily.items():
if value < low_share * average:
flags[date] = "LOW"
elif value > high_share * average:
flags[date] = "HIGH"
return flags
- اكتب حزمة اختبارات (test pack) فيها ستة اختبارات على الأقل باستخدام
check:- حالة عادية؛
- الحدّين كليهما (50% بالضبط و150% بالضبط)؛
- حالة لا توجد فيها أيام غير معتادة؛
- أسبوع Cedar Lane الحقيقي من L18؛
- مُدخلًا فارغًا.
- احسب كل نتيجة متوقعة يدويًا أولًا.
- شغّل الاختبارات. ولأي فشل، صنّف الخطأ وقرّر السلوك الصحيح. مثلًا: ماذا يجب أن يحدث عندما لا توجد أيام على الإطلاق؟ ثم أصلِح السبب وأعِد تشغيل كل الاختبارات.
- اكتب ملاحظة تحقق من 3 أسطر لصاحب المتجر: ما الذي اختُبر، وما الذي أُصلح، والنتائج.
14. تحدٍّ قصير
خصم الكميات في متجر Cedar Lane الخيالي (قاعدة L14 في U04: 100 وحدة أو أكثر ← 10%؛ ومن 50 إلى 99 ← 5%؛ وفي غير ذلك 0%). يقول زميل إن هذه النسخة "مُختبَرة بالفعل":
def bulk_discount_rate(quantity):
if quantity >= 100:
return 0.10
elif quantity > 50:
return 0.05
else:
return 0.0
- صمّم خمسة اختبارات، منها كل الحدود المهمة، مع نسب خصم متوقعة محسوبة من القاعدة.
- شغّلها واعثر على الخطأ. صنّفه وأصلِحه.
- اشرح في جملة واحدة لماذا نجحت كل اختبارات الزميل، وهي الكميات 10 و75 و150.
سلّم إجابتك قبل الحصول على التعليقات. لا يوجد حل هنا.
15. المصادر
- مطلوب (حوالي 10 دقائق): PEP 8 – Style Guide for Python Code: القسم "A Foolish Consistency is the Hobgoblin of Little Minds" وقسم "Comments". ولاحظ: "Comments that contradict the code are worse than no comments." (التعليقات التي تتعارض مع الكود أسوأ من عدم وجود تعليقات). والكود المقروء أسهل في التحقق. https://peps.python.org/pep-0008/ (فُتح وروجع في 12 أكتوبر 2026.)
- مطلوب (حوالي 10 دقائق): The Python Tutorial، الفصل 8، "Errors and Exceptions"، القسمان 8.1–8.2. https://docs.python.org/3/tutorial/errors.html (فُتح وروجع في 12 أكتوبر 2026.)
- موصى به: توثيق Python، صفحة Dealing with Bugs. https://docs.python.org/3/bugs.html (فُتحت وروجعت في 12 أكتوبر 2026.)
- للتعمّق (اختياري): The Python Language Reference، "The
assertstatement" (القسم 7.3)، بما في ذلك ما يحدث مع الخيار-O. https://docs.python.org/3/reference/simple_stmts.html (فُتح وروجع في 12 أكتوبر 2026.)
16. شخصية تتابعها / قدوة
منظور المجتمع: القائمون على صيانة Python (دون شخص بعينه). خريطة D.World تذكر مجموعة، وليس فردًا.
جرّب هذا: اقرأ صفحة توثيق Python بعنوان Dealing with Bugs (https://docs.python.org/3/bugs.html). وهي تطلب من المُبلِّغين أن "describe the problem in detail, including what you expected to happen and what did happen" (يصفوا المشكلة بالتفصيل، بما في ذلك ما توقعوا حدوثه وما حدث فعلًا)، وأن يذكروا معلومات الإصدار. اكتب "بلاغ خطأ" قصيرًا لبرنامج واحد من برامج المعمل في الجزء B بهذه الصيغة:
- عنوان من أقل من عشر كلمات؛
- ما الذي توقعته؛
- ما الذي حدث؛
- إصدار Python لديك.
وهذه بالضبط عادة مقارنة المتوقع بالفعلي التي يعلّمها هذا الدرس.
17. المصطلحات
| المصطلح | معناه في هذا الدرس |
|---|---|
| خطأ صياغة (Syntax error) | كود لا يمكن تحليله لأنه يخالف قواعد لغة Python |
| خطأ وقت التشغيل (Runtime error) | كود صحيح الصياغة يفشل أثناء التنفيذ (استثناء) |
| خطأ منطقي (Logic error) | كود يعمل لكنه يعطي نتيجة خاطئة |
| الاختبار (Test) | مُدخل محدد له مخرج متوقع محسوب بشكل مستقل، ويُقارن بالمخرج الفعلي |
| المتوقع / الفعلي (Expected / actual) | ما يجب أن تكون عليه النتيجة (يدويًا، من القاعدة) / ما أنتجه الكود |
| اختبار عادي / حدّي / فارغ / استبعاد / غير صالح | أنواع الاختبارات: بيانات معتادة / عند حد القاعدة بالضبط / بلا بيانات / عناصر يجب تجاهلها / بيانات سيئة أو ناقصة |
| الفحص (المطابقة) (Check / reconciliation) | مقارنة النتيجة بحساب مستقل للشيء نفسه |
| حزمة الاختبارات (Test pack) | مجموعة اختبارات تُحفظ معًا وتُعاد بعد كل تغيير |
| الارتداد (Regression) | إصلاح يكسر شيئًا كان يعمل من قبل؛ ويُكتشف بإعادة تشغيل كل الاختبارات |
sum() |
دالة مدمجة تجمع الأرقام الموجودة في مجموعة |
18. تأمّل
أي خطأ من أخطاء المعمل كان الأرجح أن يفوتك لولا الاختبار أو الفحص؟ وما الذي ستفعله دائمًا من الآن قبل أن تعرض أي رقم، حتى لو كان وقتك ضيقًا؟
19. الخطوة التالية
أصبحت الآن قادرًا على تفكيك سؤال (L17)، والتخطيط لإجراء (L18)، واختبار النتيجة والتحقق منها (L19). وفي L20 — مشروع الأساسيات المصغّر، ستجمع كل ذلك معًا. فبدءًا من سؤال أعمال عن قائمة معاملات بيع بالتجزئة، ستُنتج إجابة Python متحققًا منها وتوصية مبنية على الأدلة.
20. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| الجزء A (A1–A6) | تصنيف الأخطاء؛ واختيار الاختبارات والفحوصات | 5 إجابات صحيحة أو أكثر من 6 |
| معمل تصحيح الأخطاء، الجزء B (المعامل 1–4) | التصنيف، والعثور على الأسباب، والإصلاح، وإثبات الإصلاح باختبار أو فحص | معايير L19-KCB؛ والمعامل الأربعة مصنّفة كلها بشكل صحيح، والمعملان 3–4 أُصلحا مع اختبار ناجح |
| الذكاء الاصطناعي في التطبيق (حالات الفشل ← فحوصات) | تحويل أفكار الذكاء الاصطناعي إلى اختبارات قابلة للتشغيل بقيم متوقعة مستقلة | معايير L19-AI |
| التدريب الموجَّه والمستقل، وحزمة اختبارات مهمة العمل، والتحدي القصير | تصميم اختبارات عادية وحدّية وفارغة واستبعاد وغير صالحة؛ والتحقق بمقارنة النتائج المحسوبة يدويًا | معايير L19-GP وL19-IP وL19-WT وL19-MC |
المراجع
- van Rossum, G., Warsaw, B., & Coghlan, A. PEP 8 – Style Guide for Python Code. https://peps.python.org/pep-0008/ (فُتح وروجع في 12 أكتوبر 2026). يدعم: القسم "A Foolish Consistency is the Hobgoblin of Little Minds"؛ و"code is read much more often than it is written"؛ و"Comments that contradict the code are worse than no comments."
- Python Software Foundation. The Python Tutorial، الفصل 8. https://docs.python.org/3/tutorial/errors.html (فُتح وروجع في 12 أكتوبر 2026). يدعم: أخطاء الصياغة مقابل الاستثناءات؛ وأن السطر الأخير من الرسالة يوضّح ما حدث.
- Python Software Foundation. Dealing with Bugs. https://docs.python.org/3/bugs.html (فُتحت وروجعت في 12 أكتوبر 2026). يدعم: "describe the problem in detail, including what you expected to happen and what did happen"؛ وعنوانًا قصيرًا من "fewer than ten words".
- Python Software Foundation. The Python Language Reference، القسم 7.3 "The
assertstatement". https://docs.python.org/3/reference/simple_stmts.html (فُتح وروجع في 12 أكتوبر 2026). يدعم: أن جمل assert لا تُنفَّذ عند طلب التحسين (-O). - D.World Curriculum Map v1.0 (صف L19) وCurriculum Bible v1.0 (معيار دمج الذكاء الاصطناعي: "Run it, inspect assumptions, add tests and compare with expected behavior"). وثائق داخلية.
L20 · Foundations Mini Project: Business Question to Python AnswerL20 · مشروع الأساسيات المصغّر: من سؤال الأعمال إلى إجابة Python Freeمجاني
L20 — Foundations Mini Project: Business Question to Python Answer
Learner file. Model solutions are in a separate instructor-only file. Version: U05 v1.0 · Content date: 12 October 2026. Time estimates are provisional planning guides for a self-paced path, not waiting periods. Code examples were tested with Python 3.13 (see the U05 QA report).
1. Lesson Identity
| Field | Value |
|---|---|
| Title | Foundations Mini Project: Business Question to Python Answer |
| Stage | Stage 1 — Foundations |
| Unit | U05 — Problem Solving & Computational Thinking |
| Lesson ID | L20 |
| Skills | Integrated foundation skills |
| Difficulty | Beginner (integrative) |
| Estimated time | About 2 hours 30 minutes (provisional) |
| Prerequisites | L17–L19, and the skills they build on: U02 (gross profit, refund rate), U03 (AI verification, privacy), U04 (lists, dictionaries, loops, functions). |
Time breakdown (provisional): concept and worked example, 25 min · guided practice (project parts a–d), 25 min · independent practice (parts e–h), 50 min · knowledge check, 10 min · AI in Practice and Verification, 10 min · workplace task (part i), 15 min · mini challenge, 15 min.
2. Learning Objective
By the end of this lesson, you will be able to complete a small end-to-end problem: frame a business question, decompose it, write pseudocode, implement and test it in Python, and recommend one action grounded in the evidence. Along the way, you will document how AI was used and verified.
D.World map objective (verbatim): Complete a small end-to-end problem using business framing, Python logic, AI assistance, and verification.
3. Why It Matters
Each Stage 1 skill is useful on its own, but data work happens end to end. Someone asks a business question; you clarify it, calculate carefully, check your numbers and give a recommendation that someone can act on.
The US occupational description for Data Scientists (ONET) lists tasks such as "Identify business problems or management objectives that can be addressed through data analysis" and "Recommend data-driven solutions to key stakeholders". This mini project practises that chain at a beginner scale. It is a learning exercise, not a claim about job readiness. Key principle: evidence → decision → recommendation.*
4. Concept
The 10-part project format
Every D.World Foundations mini project, and the U05 exit assessment, uses these parts:
| Part | Content | Skill from |
|---|---|---|
| a | Business question and decision owner | L17 |
| b | Measurable success indicator: how the owner will know the decision worked | U02 L08 |
| c | Known facts vs assumptions, plus constraints, unknowns and estimates | L17 |
| d | Decomposition into sub-questions, each with a measure | L17 |
| e | Algorithm / pseudocode | L18 |
| f | Runnable Python solution, standard Python only | U04 |
| g | At least 3 test cases, including an edge case | L19 |
| h | Independent expected results and an expected-vs-actual comparison | L19 |
| i | Interpretation, limits and one recommendation | L17, U02 |
| j | AI-use and verification note, even if no AI was used | U03 |
From evidence to a recommendation
A good recommendation has five elements:
- Action: one specific thing the decision owner can do.
- Evidence: the verified numbers that support it.
- Limits: what the data cannot tell you, and the assumptions that would change the answer.
- Owner: the person or role who decides. AI is never the decision owner.
- Next check: how to see whether the action worked (the success indicator).
Choose the measure that matches the goal. If the goal is profit, rank by gross profit, not revenue. The two can point to different answers.
D.World mini-project rubric
The rubric is shown here so you know what "good" looks like. It is not a model answer.
| # | Criterion | 2 — Meets | 1 — Partly | 0 — Not yet |
|---|---|---|---|---|
| P1 | Framing (a–b) | Decision, owner and a measurable success indicator are clear | One element vague | Missing |
| P2 | Facts vs assumptions (c) | Correctly labelled; assumptions are not later treated as facts | Some mislabelled | Missing or confused |
| P3 | Decomposition and pseudocode (d–e) | Sub-questions with measures; pseudocode complete and traceable | Gaps or unnecessary steps | Missing |
| P4 | Python and tests (f–h) | Code runs; 3 or more tests including an edge case; expected values worked out independently; all compared | Fewer tests, or expectations not independent | Code does not run, or no tests |
| P5 | Recommendation (i) | One action tied to verified evidence, with limits and owner | Action vague, or limits missing | Not supported by evidence |
| P6 | AI-use note (j) | Specific: used / checked / accepted / rejected | Vague | Missing |
5. Worked Example
A compact walk-through of the format using familiar data: Cedar Lane's order lines from U03 L11 / U04 L15 (synthetic).
- a. Question and owner: "Which product should we feature in next week's newsletter?" Owner: the store owner.
- b. Success indicator: paid revenue from the featured product next week, compared with this week.
- c. Facts and assumptions:
- Fact: 7 order lines this week, one of them refunded.
- Assumption A1: featuring the product that already sells most will lift it further. This is untested and could be wrong; featuring a weaker product might add more.
- Assumption A2: one week is representative.
- Constraint: standard Python only; no customer data.
- d. Sub-questions:
- Q1: what is paid revenue per product?
- Q2: what share of paid revenue is each product?
- Q3: are any products affected by refunds?
- e. Pseudocode:
text
INPUT lines
SET revenue TO empty mapping
FOR EACH line IN lines
IF line.status = "paid" THEN ADD line.qty × line.price TO revenue[line.product]
END FOR
OUTPUT revenue, and each product's share of the total
- f. Python (Run):
def paid_revenue_by_product(lines):
"""Return paid revenue per product (qty * price, paid lines only)."""
revenue = {}
for line in lines:
if line["status"] == "paid":
revenue[line["product"]] = revenue.get(line["product"], 0.0) + line["qty"] * line["price"]
return revenue
lines = [
{"product": "Notebook", "qty": 2, "price": 12.0, "status": "paid"},
{"product": "Pen set", "qty": 1, "price": 8.0, "status": "paid"},
{"product": "Notebook", "qty": 1, "price": 12.0, "status": "paid"},
{"product": "Planner", "qty": 1, "price": 20.0, "status": "refunded"},
{"product": "Notebook", "qty": 1, "price": 12.0, "status": "paid"},
{"product": "Notebook", "qty": 4, "price": 12.0, "status": "paid"},
{"product": "Planner", "qty": 1, "price": 20.0, "status": "paid"},
]
revenue = paid_revenue_by_product(lines)
total = sum(revenue.values())
for product, value in revenue.items():
print(product, value, round(value / total * 100, 1))
print("check:", total == 124.0)
Notebook 96.0 77.4
Pen set 8.0 6.5
Planner 20.0 16.1
check: True
- g–h. Tests:
- Normal: matches the hand totals (96 / 8 / 20; total 124 from U03).
- Exclusion: the refunded Planner is not counted (Planner 20, not 40).
- Edge: an empty list gives
{}.
All three were run and pass. - i. Interpretation and recommendation: - Evidence: Notebooks bring 77.4% of paid revenue this week. - Action: feature Notebooks only if the goal is to protect the main revenue line. If the goal is to grow a weaker product, the evidence does not settle it (A1 is untested). - Recommendation: feature Notebooks next week, and measure the success indicator. - Limits: one week of data; no profit data; newsletter effect unknown. - j. AI-use note: "No AI used. Verified by hand totals, an exclusion test and an empty-list test."
6. Visual Explanation
QUESTION + OWNER ─► SUCCESS INDICATOR ─► FACTS | ASSUMPTIONS ─► SUB-QUESTIONS
│
RECOMMENDATION ◄─ INTERPRET + LIMITS ◄─ TESTS (expected vs actual) ◄─ PYTHON ◄─ PSEUDOCODE
│
owner decides ─► measure success indicator next period
Alt text: A loop. It starts with the question and its owner, then the success indicator, then facts separated from assumptions, then sub-questions, then pseudocode and Python. The Python output is checked by tests comparing expected and actual results. Next comes interpretation with limits, and then a recommendation. The owner makes the decision, and the success indicator is measured in the next period.
7. Guided Practice — Project Parts a–d
Fictional business: Lumen Coffee Cart (synthetic data). The owner says: "From next month, the cart only has space for three products. Which one product should I stop selling?"
Menu (price and unit cost, USD):
menu = {
"Espresso": {"price": 3.0, "unit_cost": 0.8},
"Latte": {"price": 4.5, "unit_cost": 1.5},
"Muffin": {"price": 3.5, "unit_cost": 1.75},
"Tea": {"price": 2.5, "unit_cost": 0.5},
}
Sales for the last two weeks (one line per product, week and status):
sales = [
{"week": 1, "product": "Espresso", "qty": 20, "status": "paid"},
{"week": 1, "product": "Latte", "qty": 15, "status": "paid"},
{"week": 1, "product": "Muffin", "qty": 8, "status": "paid"},
{"week": 1, "product": "Muffin", "qty": 3, "status": "refunded"},
{"week": 1, "product": "Tea", "qty": 9, "status": "paid"},
{"week": 1, "product": "Latte", "qty": 2, "status": "refunded"},
{"week": 2, "product": "Espresso", "qty": 22, "status": "paid"},
{"week": 2, "product": "Latte", "qty": 17, "status": "paid"},
{"week": 2, "product": "Muffin", "qty": 6, "status": "paid"},
{"week": 2, "product": "Muffin", "qty": 4, "status": "refunded"},
{"week": 2, "product": "Tea", "qty": 9, "status": "paid"},
]
Complete parts a–d:
- a. Write the question precisely and name the decision owner.
- b. Propose a measurable success indicator. (Hint: what should not get much worse after a product is dropped?)
- c. List at least three facts and three assumptions. (Hint: what happens to refunded items' costs? Do some customers buy two products together? We don't have order-level data.)
- d. Write at least four sub-questions, each with a measure. (Hint: units, revenue, gross profit, refunds.)
8. Independent Practice — Project Parts e–h
Continue the Lumen project:
- e. Write pseudocode for a procedure that outputs, per product: - paid units; - refunded units; - paid revenue; - gross profit (paid units × (price − unit cost)); - refund rate (refunded units ÷ (paid + refunded units)).
- f. Implement it in Python as one or more functions. Use only U04 skills.
- g. Write at least three tests with the
checkhelper from L19: - one normal case; - one exclusion case (refunds must not count as paid); - one edge case (a product with no sales lines at all, or an empty sales list). - h. Calculate the expected results by hand for the full two-week data and for your tests, before running. Record a table: expected → actual → PASS/FAIL.
No model answer is shown here.
9. Knowledge Check — Project Rubric
Part A — Choose the best answer.
A1. The goal is to keep profit as high as possible. Which measure should be used to rank products for removal? - A) Number of refunds only - B) Revenue - C) Gross profit - D) Units sold
A2. Which statement is a well-formed recommendation? - A) "The data shows interesting patterns." - B) "Stop selling product X next month. It had the lowest gross profit over two weeks (verified with tests). Limits: two weeks only, no order-level data. Owner to confirm; track weekly gross profit for four weeks." - C) "AI recommends stopping product X." - D) "Product X is bad."
A3. Your tests all pass, but your expected values were copied from the program's own output. What is the problem? - A) The expected values are not independent, so the tests cannot catch a logic error. - B) There is no problem. - C) Tests should always fail at least once. - D) Python tests must use a testing library.
A4. Who owns the final decision in this project? - A) The AI tool that suggested it - B) The analyst, because they wrote the code - C) Whoever ran the code last - D) The business owner (the decision owner), informed by the analysis
Part B — Self-assessment. Score your own project (parts a–h so far) against the rubric P1–P4 in Section 4. For each criterion, write one sentence of evidence: point to the specific part of your work that justifies the score.
10. AI in Practice
Use AI for brainstorming, debugging or documentation, and write a verification note.
You may use an AI assistant for at most two of these:
- Brainstorming: "List assumptions someone might make when deciding which café product to stop selling, using only weekly sales by product." Compare with your part c.
- Debugging: paste your own synthetic code and the error or wrong output. Ask for an explanation and a minimal fix with a test (U04 L16).
- Documentation: "Improve the wording of this docstring without changing its meaning." Then check that it still matches the code.
Then write your AI-use and verification note (part j), with four parts: 1. Used for: what you asked AI to do. 2. Checked: how you checked each output (tests, hand calculation, comparison with your own plan). 3. Accepted / rejected: what you kept and what you rejected, with reasons. 4. My judgment: which decisions remained yours, especially the recommendation.
If you used no AI, write "No AI used", followed by how you verified your work.
11. AI Verification
- Brainstormed assumptions: keep only those relevant to your data; label them; never let them become facts.
- Debugging help: accept a fix only after re-running all your tests (L19), not just the failing one.
- Documentation help: the docstring must still describe exactly what the code does (PEP 8: "Comments that contradict the code are worse than no comments.").
- Recommendations from AI: do not accept them. AI may suggest options, but the recommendation must come from your verified evidence, and the owner decides.
- Privacy: synthetic data only. Never paste real sales, customer or supplier data.
12. Business Lens
Analyse a simple retail transaction list and recommend one action from the evidence. In a small business:
- the decision is often binary or a short list, such as keep or drop, or feature A or B;
- the right measure follows from the goal (profit → gross profit);
- refunds and quality issues are part of the evidence, not noise;
- a limited data window (two weeks) means the recommendation should include a next check;
- the strongest recommendation is specific, verified and honest about limits.
13. Workplace Task — Project Part i: Recommendation Memo
Write a 120–200-word memo to the Lumen Coffee Cart owner containing:
- One recommended action (which product to stop selling, or a justified alternative).
- The verified evidence: at least two numbers from your tested output.
- Two limits or assumptions that could change the recommendation.
- The success indicator and when to check it.
- A closing line making clear the owner decides.
Attach your AI-use note (part j).
14. Mini Challenge
Sensitivity check. Your main analysis assumed that refunded items have no cost. Now assume each refunded item still cost its unit cost (for example, a muffin was thrown away).
- Update your pseudocode and code so that gross profit = paid units × price − (paid + refunded units) × unit cost.
- Re-run your tests (update the expected values by hand first).
- Does your recommendation change? Write two sentences on what this tells you about the strength of your evidence.
Submit before feedback. No solution is provided here.
15. Resources
- Required: the D.World mini-project rubric (Section 4 of this lesson).
- Required (about 10 min): ONET OnLine, Data Scientists summary (US). Read the tasks list, especially "Identify business problems or management objectives that can be addressed through data analysis" and "Recommend data-driven solutions to key stakeholders". https://www.onetonline.org/link/summary/15-2051.00 (Opened and checked 12 Oct 2026; site updated 6 Oct 2026.)*
- Recommended (about 10 min): AWS CAF Business Perspective, Data science, the recommendations on business value and measurable outcomes. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-science.html (Opened and checked 12 Oct 2026; historical-reference notice.)
16. Person to Follow / Role Model
Instructor / reviewer lens (D.World map: "D.World faculty / reviewer"). This is not a named person and not a biography. It describes how a reviewer will read your project.
A reviewer will typically ask: 1. "Can I see who decides, and what success looks like?" 2. "Which statements are facts and which are assumptions?" 3. "If I re-run your code and your tests, do I get the same numbers?" 4. "Does the recommendation follow from the verified evidence, and are the limits honest?" 5. "What did AI do, and how did you check it?"
Try this: before you submit, swap roles. Read your own project as the reviewer would and answer these five questions in writing.
17. Glossary
| Term | Meaning in this lesson |
|---|---|
| Mini project | A small end-to-end task from business question to verified recommendation |
| Decision owner | The person or role who decides; never an AI tool |
| Success indicator | A measurable sign that the decision worked |
| Gross profit (per product) | Paid units × (price − unit cost) (U02) |
| Refund rate | Refunded units ÷ (paid + refunded units) |
| Recommendation | One specific action, with evidence, limits, owner and next check |
| Sensitivity check | Re-running an analysis with a changed assumption to see if the conclusion holds |
| AI-use note | What AI was used for, how it was checked, what was accepted or rejected, and what stayed human judgment |
| Evidence → decision → recommendation | The chain from verified numbers to an owner's choice |
18. Reflection
Look back across Stage 1 (U01–U05). Which skill made the biggest difference in this project: framing, business metrics, AI verification, Python or testing? Which one do you most need to practise before Stage 2?
19. Next Step
U05 finishes with the U05 Exit Assessment, a new business problem solved from question to verified Python answer, using the same 10-part format. This completes the Foundations stage. The following stage of the D.World curriculum builds on these habits with larger datasets and more specialised tools.
20. Assessment Evidence
| Evidence | What it shows | How it is judged |
|---|---|---|
| Part A (A1–A4) | Chooses the right measure; recognises a well-formed recommendation, independent tests and decision ownership | 3 or more of 4 correct; A4 must be correct |
| Part B self-assessment | Judges own work against the rubric with evidence | Rubric L20-KCB |
| Project parts a–h (guided and independent practice) | Integrated framing, decomposition, pseudocode, Python and tests | Project rubric P1–P4 (L20-GP, L20-IP) |
| Part i memo and part j AI-use note | Evidence-based recommendation; transparent AI use | Project rubric P5–P6 (L20-WT, L20-AI) |
| Mini challenge (sensitivity) | Tests the strength of the conclusion | Rubric L20-MC |
References
- ONET OnLine. 15-2051.00 – Data Scientists* (summary; US). https://www.onetonline.org/link/summary/15-2051.00 (opened and checked 12 Oct 2026; site updated 6 Oct 2026). Supports: the tasks "Identify business problems or management objectives that can be addressed through data analysis" and "Recommend data-driven solutions to key stakeholders".
- Amazon Web Services. AWS CAF Business Perspective — Data science. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-science.html (opened and checked 12 Oct 2026; historical-reference notice). Supports: defining business value; measurable performance metric.
- van Rossum, G., Warsaw, B., & Coghlan, A. PEP 8. https://peps.python.org/pep-0008/ (opened and checked 12 Oct 2026). Supports: "Comments that contradict the code are worse than no comments."
- The 10-part project format and the mini-project rubric are D.World teaching tools.
- D.World Curriculum Map v1.0 (L20 row) and Curriculum Bible v1.0. Internal.
L20 — مشروع الأساسيات المصغّر: من سؤال الأعمال إلى إجابة Python
ملف المتعلّم. الحلول النموذجية في ملف منفصل خاص بالمدرّس فقط. الإصدار: U05 v1.0 · تاريخ المحتوى: 12 أكتوبر 2026. تقديرات الوقت إرشادات مبدئية للتخطيط في مسار ذاتي الوتيرة، وليست فترات انتظار. أمثلة الكود مُختبَرة على Python 3.13 (راجع تقرير الجودة QA الخاص بـ U05).
1. بطاقة الدرس
| البند | القيمة |
|---|---|
| العنوان | مشروع الأساسيات المصغّر: من سؤال الأعمال إلى إجابة Python |
| المرحلة | المرحلة 1 — الأساسيات |
| الوحدة | U05 — حل المشكلات والتفكير الحاسوبي |
| رقم الدرس | L20 |
| المهارات | مهارات الأساسيات مجتمعة |
| المستوى | مبتدئ (يجمع المهارات) |
| الوقت المتوقع | حوالي ساعتين و30 دقيقة (مبدئي) |
| المتطلبات السابقة | L17–L19، والمهارات التي تبني عليها: U02 (مجمل الربح، ومعدل الاسترداد)، وU03 (التحقق من مخرجات الذكاء الاصطناعي، والخصوصية)، وU04 (القوائم، والقواميس، والحلقات التكرارية، والدوال). |
تفصيل الوقت (مبدئي): المفهوم والمثال المحلول 25 دقيقة · التدريب الموجَّه (أجزاء المشروع a–d) 25 دقيقة · التدريب المستقل (الأجزاء e–h) 50 دقيقة · اختبار الفهم 10 دقائق · الذكاء الاصطناعي في التطبيق والتحقق 10 دقائق · مهمة العمل (الجزء i) 15 دقيقة · التحدي القصير 15 دقيقة.
2. هدف التعلّم
في نهاية هذا الدرس ستكون قادرًا على أن تُنجز مشكلة صغيرة من أولها إلى آخرها: تصيغ سؤال الأعمال، وتفكّكه، وتكتب الكود الوصفي، وتنفّذه وتختبره في Python، ثم توصي بإجراء واحد مبني على الأدلة. وخلال ذلك ستوثّق كيف استُخدم الذكاء الاصطناعي وكيف تحققت من مخرجاته.
هدف خريطة D.World (بنصّه): Complete a small end-to-end problem using business framing, Python logic, AI assistance, and verification.
3. لماذا يهمّك هذا؟
كل مهارة من مهارات المرحلة 1 مفيدة وحدها، لكن العمل على البيانات يحدث من البداية إلى النهاية. يطرح شخص ما سؤال أعمال؛ فتوضّحه أنت، وتحسب بعناية، وتراجع أرقامك، وتقدّم توصية يستطيع أحد أن يتصرف بناءً عليها.
الوصف الوظيفي الأمريكي لعلماء البيانات (O*NET) يذكر مهام مثل "Identify business problems or management objectives that can be addressed through data analysis" (تحديد مشكلات الأعمال أو أهداف الإدارة التي يمكن معالجتها بتحليل البيانات) و"Recommend data-driven solutions to key stakeholders" (التوصية بحلول مبنية على البيانات لأصحاب المصلحة الرئيسيين). وهذا المشروع المصغّر يدرّبك على هذه السلسلة بمستوى المبتدئين. وهو تمرين تعليمي، وليس ادعاءً بالجاهزية للعمل. المبدأ الأساسي: الأدلة ← القرار ← التوصية.
4. المفهوم
صيغة المشروع ذات الأجزاء العشرة
كل مشروع مصغّر في مرحلة الأساسيات في D.World، وكذلك تقييم نهاية الوحدة U05، يستخدم هذه الأجزاء:
| الجزء | المحتوى | المهارة من |
|---|---|---|
| a | سؤال الأعمال وصاحب القرار | L17 |
| b | مؤشر نجاح قابل للقياس: كيف سيعرف صاحب القرار أن القرار نجح | L08 في U02 |
| c | الحقائق المعلومة مقابل الافتراضات، بالإضافة إلى القيود والمجهولات والتقديرات | L17 |
| d | التفكيك إلى أسئلة فرعية، لكل منها مقياس | L17 |
| e | الخوارزمية / الكود الوصفي | L18 |
| f | حل Python قابل للتشغيل، بـ Python القياسي فقط | U04 |
| g | 3 حالات اختبار على الأقل، منها حالة طرفية | L19 |
| h | نتائج متوقعة مستقلة ومقارنة بين المتوقع والفعلي | L19 |
| i | التفسير، والحدود، وتوصية واحدة | L17، وU02 |
| j | ملاحظة استخدام الذكاء الاصطناعي والتحقق، حتى لو لم يُستخدم الذكاء الاصطناعي | U03 |
من الأدلة إلى التوصية
التوصية الجيدة لها خمسة عناصر:
- الإجراء: شيء واحد محدد يستطيع صاحب القرار أن يفعله.
- الدليل: الأرقام المتحقَّق منها التي تدعمه.
- الحدود: ما لا تستطيع البيانات أن تخبرك به، والافتراضات التي لو تغيّرت لتغيّرت الإجابة.
- صاحب القرار: الشخص أو الدور الذي يقرر. الذكاء الاصطناعي ليس صاحب القرار أبدًا.
- الفحص التالي: كيف ترى هل نجح الإجراء (مؤشر النجاح).
اختر المقياس الذي يطابق الهدف. إذا كان الهدف هو الربح، فرتّب حسب مجمل الربح، لا حسب الإيرادات. فقد يشير المقياسان إلى إجابتين مختلفتين.
معايير تقييم المشروع المصغّر في D.World
نعرض المعايير هنا لتعرف كيف يبدو العمل "الجيد". وهي ليست إجابة نموذجية.
| # | المعيار | 2 — يحقق المطلوب | 1 — يحققه جزئيًا | 0 — لم يحققه بعد |
|---|---|---|---|---|
| P1 | الصياغة (a–b) | القرار وصاحبه ومؤشر نجاح قابل للقياس، كلها واضحة | عنصر واحد مبهم | غير موجود |
| P2 | الحقائق مقابل الافتراضات (c) | مصنّفة بشكل صحيح؛ ولا تُعامَل الافتراضات لاحقًا كحقائق | بعضها مصنّف خطأً | غير موجود أو مختلط |
| P3 | التفكيك والكود الوصفي (d–e) | أسئلة فرعية لها مقاييس؛ وكود وصفي كامل يمكن تتبّعه | ثغرات أو خطوات غير ضرورية | غير موجود |
| P4 | Python والاختبارات (f–h) | الكود يعمل؛ و3 اختبارات أو أكثر منها حالة طرفية؛ والقيم المتوقعة محسوبة بشكل مستقل؛ وكلها قورنت | اختبارات أقل، أو القيم المتوقعة ليست مستقلة | الكود لا يعمل، أو لا توجد اختبارات |
| P5 | التوصية (i) | إجراء واحد مرتبط بأدلة متحقَّق منها، مع الحدود وصاحب القرار | الإجراء مبهم، أو الحدود غير مذكورة | لا تدعمها الأدلة |
| P6 | ملاحظة استخدام الذكاء الاصطناعي (j) | محددة: ما استُخدم / ما روجع / ما قُبل / ما رُفض | مبهمة | غير موجودة |
5. مثال محلول
عرض مختصر للصيغة باستخدام بيانات مألوفة: بنود طلبات Cedar Lane من L11 في U03 / L15 في U04 (بيانات مصطنعة).
- a. السؤال وصاحب القرار: "أي منتج نعرضه بشكل مميز في النشرة البريدية الأسبوع القادم؟" صاحب القرار: صاحب المتجر.
- b. مؤشر النجاح: الإيرادات المدفوعة من المنتج المميز في الأسبوع القادم، مقارنةً بهذا الأسبوع.
- c. الحقائق والافتراضات:
- حقيقة: 7 بنود طلبات هذا الأسبوع، أحدها مستردّ.
- الافتراض A1: عرض المنتج الأكثر مبيعًا بشكل مميز سيرفع مبيعاته أكثر. وهذا افتراض لم يُختبر وقد يكون خاطئًا؛ فربما يضيف عرض منتج أضعف أكثر.
- الافتراض A2: أسبوع واحد يمثّل الوضع المعتاد.
- قيد: Python القياسي فقط؛ ولا بيانات عملاء.
- d. الأسئلة الفرعية:
- Q1: ما الإيرادات المدفوعة لكل منتج؟
- Q2: ما حصة كل منتج من الإيرادات المدفوعة؟
- Q3: هل تأثرت أي منتجات بالاستردادات؟
- e. الكود الوصفي:
INPUT lines
SET revenue TO empty mapping
FOR EACH line IN lines
IF line.status = "paid" THEN ADD line.qty × line.price TO revenue[line.product]
END FOR
OUTPUT revenue, and each product's share of the total
- f. Python (Run):
def paid_revenue_by_product(lines):
"""Return paid revenue per product (qty * price, paid lines only)."""
revenue = {}
for line in lines:
if line["status"] == "paid":
revenue[line["product"]] = revenue.get(line["product"], 0.0) + line["qty"] * line["price"]
return revenue
lines = [
{"product": "Notebook", "qty": 2, "price": 12.0, "status": "paid"},
{"product": "Pen set", "qty": 1, "price": 8.0, "status": "paid"},
{"product": "Notebook", "qty": 1, "price": 12.0, "status": "paid"},
{"product": "Planner", "qty": 1, "price": 20.0, "status": "refunded"},
{"product": "Notebook", "qty": 1, "price": 12.0, "status": "paid"},
{"product": "Notebook", "qty": 4, "price": 12.0, "status": "paid"},
{"product": "Planner", "qty": 1, "price": 20.0, "status": "paid"},
]
revenue = paid_revenue_by_product(lines)
total = sum(revenue.values())
for product, value in revenue.items():
print(product, value, round(value / total * 100, 1))
print("check:", total == 124.0)
Notebook 96.0 77.4
Pen set 8.0 6.5
Planner 20.0 16.1
check: True
- g–h. الاختبارات:
- عادي: يطابق المجاميع اليدوية (96 / 8 / 20؛ والإجمالي 124 من U03).
- استبعاد: الأجندة المستردّة لا تُحسب (Planner تساوي 20، وليس 40).
- طرفي: القائمة الفارغة تعطي
{}.
شُغّلت الاختبارات الثلاثة كلها ونجحت.
- i. التفسير والتوصية:
- الدليل: الكشاكيل (Notebooks) تجلب 77.4% من الإيرادات المدفوعة هذا الأسبوع.
- الإجراء: اعرض الكشاكيل بشكل مميز فقط إذا كان الهدف هو حماية مصدر الإيرادات الرئيسي. أما إذا كان الهدف هو تنمية منتج أضعف، فالأدلة لا تحسم الأمر (A1 لم يُختبر).
- التوصية: اعرض الكشاكيل بشكل مميز الأسبوع القادم، وقِس مؤشر النجاح.
- الحدود: بيانات أسبوع واحد؛ ولا بيانات عن الربح؛ وأثر النشرة البريدية غير معروف.
- j. ملاحظة استخدام الذكاء الاصطناعي: "No AI used. Verified by hand totals, an exclusion test and an empty-list test." (لم أستخدم الذكاء الاصطناعي. تحققت بالمجاميع اليدوية، واختبار استبعاد، واختبار قائمة فارغة.)
6. شرح بصري
QUESTION + OWNER ─► SUCCESS INDICATOR ─► FACTS | ASSUMPTIONS ─► SUB-QUESTIONS
│
RECOMMENDATION ◄─ INTERPRET + LIMITS ◄─ TESTS (expected vs actual) ◄─ PYTHON ◄─ PSEUDOCODE
│
owner decides ─► measure success indicator next period
وصف الرسم: حلقة. تبدأ بالسؤال وصاحبه، ثم مؤشر النجاح، ثم الحقائق مفصولة عن الافتراضات، ثم الأسئلة الفرعية، ثم الكود الوصفي وPython. وتُراجَع مخرجات Python باختبارات تقارن النتائج المتوقعة بالفعلية. ويأتي بعد ذلك التفسير مع الحدود، ثم التوصية. ويتخذ صاحب القرار قراره، ويُقاس مؤشر النجاح في الفترة التالية.
7. تدريب موجَّه — أجزاء المشروع a–d
نشاط تجاري خيالي: Lumen Coffee Cart (عربة قهوة، بيانات مصطنعة). يقول صاحب العربة: "من الشهر القادم، لن تتسع العربة إلا لثلاثة منتجات. أي منتج واحد يجب أن أتوقف عن بيعه؟"
قائمة المنتجات (السعر وتكلفة الوحدة، بالدولار):
menu = {
"Espresso": {"price": 3.0, "unit_cost": 0.8},
"Latte": {"price": 4.5, "unit_cost": 1.5},
"Muffin": {"price": 3.5, "unit_cost": 1.75},
"Tea": {"price": 2.5, "unit_cost": 0.5},
}
مبيعات آخر أسبوعين (بند واحد لكل منتج وأسبوع وحالة):
sales = [
{"week": 1, "product": "Espresso", "qty": 20, "status": "paid"},
{"week": 1, "product": "Latte", "qty": 15, "status": "paid"},
{"week": 1, "product": "Muffin", "qty": 8, "status": "paid"},
{"week": 1, "product": "Muffin", "qty": 3, "status": "refunded"},
{"week": 1, "product": "Tea", "qty": 9, "status": "paid"},
{"week": 1, "product": "Latte", "qty": 2, "status": "refunded"},
{"week": 2, "product": "Espresso", "qty": 22, "status": "paid"},
{"week": 2, "product": "Latte", "qty": 17, "status": "paid"},
{"week": 2, "product": "Muffin", "qty": 6, "status": "paid"},
{"week": 2, "product": "Muffin", "qty": 4, "status": "refunded"},
{"week": 2, "product": "Tea", "qty": 9, "status": "paid"},
]
أكمل الأجزاء a–d:
- a. اكتب السؤال بدقة، وحدّد صاحب القرار.
- b. اقترح مؤشر نجاح قابلًا للقياس. (تلميح: ما الذي يجب ألا يسوء كثيرًا بعد إيقاف منتج؟)
- c. اكتب ثلاث حقائق وثلاثة افتراضات على الأقل. (تلميح: ماذا يحدث لتكاليف المنتجات المستردّة؟ هل يشتري بعض العملاء منتجين معًا؟ ليست لدينا بيانات على مستوى الطلب.)
- d. اكتب أربعة أسئلة فرعية على الأقل، لكل منها مقياس. (تلميح: الوحدات، والإيرادات، ومجمل الربح، والاستردادات.)
8. تدريب مستقل — أجزاء المشروع e–h
أكمل مشروع Lumen:
- e. اكتب كودًا وصفيًا لإجراء يُخرج لكل منتج:
- الوحدات المدفوعة؛
- الوحدات المستردّة؛
- الإيرادات المدفوعة؛
- مجمل الربح (الوحدات المدفوعة × (السعر − تكلفة الوحدة))؛
- معدل الاسترداد (الوحدات المستردّة ÷ (الوحدات المدفوعة + المستردّة)).
- f. نفّذه في Python بدالة واحدة أو أكثر. واستخدم مهارات U04 فقط.
- g. اكتب ثلاثة اختبارات على الأقل باستخدام الدالة المساعدة
checkمن L19:- حالة عادية واحدة؛
- حالة استبعاد واحدة (يجب ألا تُحسب الاستردادات كمدفوعة)؛
- حالة طرفية واحدة (منتج ليس له أي بنود مبيعات على الإطلاق، أو قائمة مبيعات فارغة).
- h. احسب النتائج المتوقعة يدويًا لبيانات الأسبوعين كاملة ولاختباراتك، قبل التشغيل. وسجّل جدولًا: المتوقع ← الفعلي ← PASS/FAIL.
لا تُعرض هنا إجابة نموذجية.
9. اختبار الفهم — معايير تقييم المشروع
الجزء A — اختر أفضل إجابة.
A1. الهدف هو إبقاء الربح أعلى ما يمكن. أي مقياس يجب استخدامه لترتيب المنتجات المرشحة للإيقاف؟
- A) عدد الاستردادات فقط
- B) الإيرادات
- C) مجمل الربح
- D) الوحدات المباعة
A2. أي عبارة تمثّل توصية مكتملة الصياغة؟
- A) "البيانات تُظهر أنماطًا مثيرة للاهتمام."
- B) "توقّف عن بيع المنتج X الشهر القادم. كان له أقل مجمل ربح خلال أسبوعين (متحقَّق منه بالاختبارات). الحدود: أسبوعان فقط، ولا بيانات على مستوى الطلب. يؤكد صاحب العربة القرار؛ ويُتابَع مجمل الربح الأسبوعي لمدة أربعة أسابيع."
- C) "الذكاء الاصطناعي يوصي بإيقاف المنتج X."
- D) "المنتج X سيئ."
A3. كل اختباراتك ناجحة، لكن القيم المتوقعة نُسخت من مخرجات البرنامج نفسه. ما المشكلة؟
- A) القيم المتوقعة ليست مستقلة، ولذلك لا تستطيع الاختبارات أن تكشف الخطأ المنطقي.
- B) لا توجد مشكلة.
- C) يجب أن تفشل الاختبارات مرة واحدة على الأقل.
- D) اختبارات Python يجب أن تستخدم مكتبة اختبار.
A4. من يملك القرار النهائي في هذا المشروع؟
- A) أداة الذكاء الاصطناعي التي اقترحته
- B) المحلل، لأنه كتب الكود
- C) آخر شخص شغّل الكود
- D) صاحب النشاط (صاحب القرار)، مستعينًا بالتحليل
الجزء B — تقييم ذاتي. قيّم مشروعك (الأجزاء a–h حتى الآن) وفق المعايير P1–P4 في القسم 4. ولكل معيار، اكتب جملة واحدة من الأدلة: أشِر إلى الجزء المحدد من عملك الذي يبرر الدرجة.
10. الذكاء الاصطناعي في التطبيق
استخدم الذكاء الاصطناعي في العصف الذهني، أو تصحيح الأخطاء، أو التوثيق، واكتب ملاحظة تحقق.
يمكنك أن تستخدم مساعد ذكاء اصطناعي في اثنين على الأكثر مما يلي:
- العصف الذهني: "List assumptions someone might make when deciding which café product to stop selling, using only weekly sales by product." (اذكر الافتراضات التي قد يضعها شخص عند تقرير أي منتج في مقهى يتوقف عن بيعه، باستخدام المبيعات الأسبوعية لكل منتج فقط.) وقارنها بالجزء c الخاص بك.
- تصحيح الأخطاء: الصق كودك المصطنع أنت مع الخطأ أو المخرج الخاطئ. واطلب شرحًا وأصغر إصلاح ممكن مع اختبار (L16 في U04).
- التوثيق: "Improve the wording of this docstring without changing its meaning." (حسّن صياغة نص التوثيق هذا دون تغيير معناه.) ثم تأكد أنه ما زال يطابق الكود.
بعد ذلك اكتب ملاحظة استخدام الذكاء الاصطناعي والتحقق (الجزء j)، من أربعة أجزاء:
- استُخدم في: ما الذي طلبته من الذكاء الاصطناعي.
- ما روجع: كيف راجعت كل مخرج (الاختبارات، والحساب اليدوي، والمقارنة بخطتك).
- ما قُبل / ما رُفض: ما الذي احتفظت به وما الذي رفضته، مع الأسباب.
- حكمي الشخصي: أي القرارات بقيت قراراتك أنت، وخاصة التوصية.
إذا لم تستخدم الذكاء الاصطناعي، فاكتب "No AI used" (لم أستخدم الذكاء الاصطناعي)، ثم اذكر كيف تحققت من عملك.
11. التحقق من مخرجات الذكاء الاصطناعي
- الافتراضات الناتجة عن العصف الذهني: احتفظ فقط بما يتعلق ببياناتك أنت؛ وصنّفها؛ ولا تسمح لها أبدًا بأن تتحول إلى حقائق.
- المساعدة في تصحيح الأخطاء: لا تقبل إصلاحًا إلا بعد إعادة تشغيل كل اختباراتك (L19)، وليس الاختبار الذي فشل فقط.
- المساعدة في التوثيق: يجب أن يظل نص التوثيق يصف بدقة ما يفعله الكود (PEP 8: "Comments that contradict the code are worse than no comments.").
- التوصيات القادمة من الذكاء الاصطناعي: لا تقبلها. قد يقترح الذكاء الاصطناعي خيارات، لكن التوصية يجب أن تأتي من أدلتك المتحقَّق منها، وصاحب القرار هو من يقرر.
- الخصوصية: بيانات مصطنعة فقط. لا تلصق أبدًا بيانات حقيقية عن المبيعات أو العملاء أو الموردين.
12. منظور الأعمال
حلّل قائمة معاملات بسيطة لبيع بالتجزئة، وأوصِ بإجراء واحد بناءً على الأدلة. في النشاط التجاري الصغير:
- يكون القرار غالبًا ثنائيًا أو قائمة قصيرة، مثل: نُبقي أم نوقف، أو نعرض A أم B؛
- يأتي المقياس الصحيح من الهدف (الربح ← مجمل الربح)؛
- الاستردادات ومشكلات الجودة جزء من الأدلة، وليست تشويشًا؛
- نافذة البيانات المحدودة (أسبوعان) تعني أن التوصية يجب أن تتضمن فحصًا تاليًا؛
- أقوى توصية هي التوصية المحددة، والمتحقَّق منها، والصريحة بشأن حدودها.
13. مهمة عمل — الجزء i من المشروع: مذكرة التوصية
اكتب مذكرة من 120 إلى 200 كلمة لصاحب Lumen Coffee Cart تحتوي على:
- إجراء موصى به واحد (أي منتج يتوقف عن بيعه، أو بديل له مبرراته).
- الأدلة المتحقَّق منها: رقمان على الأقل من مخرجاتك المُختبَرة.
- حدّان أو افتراضان قد يغيّران التوصية.
- مؤشر النجاح ومتى يُراجَع.
- سطرًا ختاميًا يوضح أن صاحب العربة هو من يقرر.
أرفق ملاحظة استخدام الذكاء الاصطناعي (الجزء j).
14. تحدٍّ قصير
فحص الحساسية (Sensitivity check). افترض تحليلك الأساسي أن المنتجات المستردّة ليست لها تكلفة. افترض الآن أن كل منتج مستردّ ما زالت تكلفته قائمة (مثلًا: المافن رُمي).
- حدّث الكود الوصفي والكود بحيث يكون مجمل الربح = الوحدات المدفوعة × السعر − (الوحدات المدفوعة + المستردّة) × تكلفة الوحدة.
- أعِد تشغيل اختباراتك (حدّث القيم المتوقعة يدويًا أولًا).
- هل تتغير توصيتك؟ اكتب جملتين عمّا يخبرك به هذا عن قوة أدلتك.
سلّم إجابتك قبل الحصول على التعليقات. لا يوجد حل هنا.
15. المصادر
- مطلوب: معايير تقييم المشروع المصغّر في D.World (القسم 4 من هذا الدرس).
- مطلوب (حوالي 10 دقائق): O*NET OnLine، ملخص Data Scientists (الولايات المتحدة). اقرأ قائمة المهام، وخاصة "Identify business problems or management objectives that can be addressed through data analysis" و"Recommend data-driven solutions to key stakeholders". https://www.onetonline.org/link/summary/15-2051.00 (فُتح وروجع في 12 أكتوبر 2026؛ وحُدّث الموقع في 6 أكتوبر 2026.)
- موصى به (حوالي 10 دقائق): AWS CAF Business Perspective، صفحة Data science، والتوصيات الخاصة بقيمة الأعمال والنتائج القابلة للقياس. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-science.html (فُتحت وروجعت في 12 أكتوبر 2026؛ وعليها تنبيه بأنها للرجوع التاريخي.)
16. شخصية تتابعها / قدوة
منظور المدرّس / المراجع (خريطة D.World: "D.World faculty / reviewer"). هذا ليس شخصًا بعينه وليس سيرة ذاتية. بل يصف كيف سيقرأ المراجع مشروعك.
عادةً سيسأل المراجع:
- "هل أستطيع أن أرى من يقرر، وكيف يبدو النجاح؟"
- "أي العبارات حقائق وأيها افتراضات؟"
- "إذا أعدت تشغيل كودك واختباراتك، هل أحصل على الأرقام نفسها؟"
- "هل تنبع التوصية من الأدلة المتحقَّق منها، وهل الحدود مذكورة بصدق؟"
- "ماذا فعل الذكاء الاصطناعي، وكيف راجعته؟"
جرّب هذا: قبل أن تسلّم، بدّل الأدوار. اقرأ مشروعك كما سيقرؤه المراجع، وأجب كتابةً عن هذه الأسئلة الخمسة.
17. المصطلحات
| المصطلح | معناه في هذا الدرس |
|---|---|
| المشروع المصغّر (Mini project) | مهمة صغيرة من البداية إلى النهاية، من سؤال الأعمال إلى توصية متحقَّق منها |
| صاحب القرار (Decision owner) | الشخص أو الدور الذي يقرر؛ ولا يكون أداة ذكاء اصطناعي أبدًا |
| مؤشر النجاح (Success indicator) | علامة قابلة للقياس على أن القرار نجح |
| مجمل الربح (لكل منتج) (Gross profit) | الوحدات المدفوعة × (السعر − تكلفة الوحدة) (U02) |
| معدل الاسترداد (Refund rate) | الوحدات المستردّة ÷ (الوحدات المدفوعة + المستردّة) |
| التوصية (Recommendation) | إجراء واحد محدد، مع الأدلة والحدود وصاحب القرار والفحص التالي |
| فحص الحساسية (Sensitivity check) | إعادة التحليل بافتراض مختلف لمعرفة هل يصمد الاستنتاج |
| ملاحظة استخدام الذكاء الاصطناعي (AI-use note) | فيمَ استُخدم الذكاء الاصطناعي، وكيف روجع، وما الذي قُبل أو رُفض، وما الذي بقي حكمًا بشريًا |
| الأدلة ← القرار ← التوصية | السلسلة التي تبدأ بالأرقام المتحقَّق منها وتنتهي باختيار صاحب القرار |
18. تأمّل
انظر إلى المرحلة 1 كلها (U01–U05). أي مهارة صنعت الفرق الأكبر في هذا المشروع: الصياغة، أم مقاييس الأعمال، أم التحقق من مخرجات الذكاء الاصطناعي، أم Python، أم الاختبار؟ وأيها تحتاج أكثر إلى التدرب عليها قبل المرحلة 2؟
19. الخطوة التالية
تنتهي U05 بـ تقييم نهاية الوحدة U05، وهو مشكلة أعمال جديدة تحلّها من السؤال حتى إجابة Python متحقَّق منها، باستخدام صيغة الأجزاء العشرة نفسها. وبهذا تكتمل مرحلة الأساسيات. والمرحلة التالية من منهج D.World تبني على هذه العادات باستخدام مجموعات بيانات أكبر وأدوات أكثر تخصصًا.
20. أدلة التقييم
| الدليل | ماذا يُظهر | كيف يُقيَّم |
|---|---|---|
| الجزء A (A1–A4) | اختيار المقياس الصحيح؛ والتعرّف على التوصية المكتملة، والاختبارات المستقلة، وملكية القرار | 3 إجابات صحيحة أو أكثر من 4؛ ويجب أن تكون A4 صحيحة |
| التقييم الذاتي، الجزء B | الحكم على العمل الشخصي وفق المعايير مع الأدلة | معايير L20-KCB |
| أجزاء المشروع a–h (التدريب الموجَّه والمستقل) | الصياغة والتفكيك والكود الوصفي وPython والاختبارات مجتمعة | معايير المشروع P1–P4 (L20-GP وL20-IP) |
| مذكرة الجزء i وملاحظة استخدام الذكاء الاصطناعي في الجزء j | توصية مبنية على الأدلة؛ واستخدام شفاف للذكاء الاصطناعي | معايير المشروع P5–P6 (L20-WT وL20-AI) |
| التحدي القصير (الحساسية) | اختبار قوة الاستنتاج | معايير L20-MC |
المراجع
- O*NET OnLine. 15-2051.00 – Data Scientists (ملخص؛ الولايات المتحدة). https://www.onetonline.org/link/summary/15-2051.00 (فُتح وروجع في 12 أكتوبر 2026؛ وحُدّث الموقع في 6 أكتوبر 2026). يدعم: المهمتين "Identify business problems or management objectives that can be addressed through data analysis" و"Recommend data-driven solutions to key stakeholders".
- Amazon Web Services. AWS CAF Business Perspective — Data science. https://docs.aws.amazon.com/whitepapers/latest/aws-caf-business-perspective/data-science.html (فُتحت وروجعت في 12 أكتوبر 2026؛ وعليها تنبيه بأنها للرجوع التاريخي). يدعم: تعريف قيمة الأعمال؛ ومقياس أداء قابل للقياس.
- van Rossum, G., Warsaw, B., & Coghlan, A. PEP 8. https://peps.python.org/pep-0008/ (فُتح وروجع في 12 أكتوبر 2026). يدعم: "Comments that contradict the code are worse than no comments."
- صيغة المشروع ذات الأجزاء العشرة ومعايير تقييم المشروع المصغّر أدوات تعليمية من D.World.
- D.World Curriculum Map v1.0 (صف L20) وCurriculum Bible v1.0. وثائق داخلية.
U05 Exit Assessment — Problem Solving & Computational Thinkingتقييم نهاية الوحدة U05 — حل المشكلات والتفكير الحاسوبي Freeمجاني
U05 Exit Assessment — Problem Solving & Computational Thinking
Learner-facing instructions and rubric. The reference solution, expected results and marking notes are in the instructor-only file (05). Version: U05 v1.0 · 12 October 2026.
Unit exit criterion (D.World map): Solve a small business problem from question to verified Python answer.
Estimated time: 75–90 minutes (provisional; self-paced, not a time limit).
Format:
- one Python script (.py);
- one written report of 400–700 words, following the 10-part format from L20. Tables, pseudocode and code do not count toward the word limit.
You need: Python 3, standard library only. No packages, accounts or internet connection are required.
Allowed: - your notes from U01–U05; - the Python Tutorial; - an AI assistant only for brainstorming, debugging or documentation, declared in part j.
AI must not choose your recommendation.
The case (fictional business, synthetic data)
Pine Street Books is a fictional small bookshop, open Monday to Saturday. The manager writes:
"I can afford one extra staff member on one weekday each week. I want them on the day that is usually busiest for sales. Which weekday should it be?"
Days the shop was open (two weeks):
open_days = [
{"date": "2026-11-02", "weekday": "Mon"}, {"date": "2026-11-03", "weekday": "Tue"},
{"date": "2026-11-04", "weekday": "Wed"}, {"date": "2026-11-05", "weekday": "Thu"},
{"date": "2026-11-06", "weekday": "Fri"}, {"date": "2026-11-07", "weekday": "Sat"},
{"date": "2026-11-09", "weekday": "Mon"}, {"date": "2026-11-10", "weekday": "Tue"},
{"date": "2026-11-11", "weekday": "Wed"}, {"date": "2026-11-12", "weekday": "Thu"},
{"date": "2026-11-13", "weekday": "Fri"}, {"date": "2026-11-14", "weekday": "Sat"},
]
Sales lines (two weeks):
sales = [
{"date": "2026-11-02", "qty": 4, "price": 15.0, "status": "paid"},
{"date": "2026-11-03", "qty": 3, "price": 15.0, "status": "paid"},
{"date": "2026-11-04", "qty": 2, "price": 25.0, "status": "paid"},
{"date": "2026-11-05", "qty": 4, "price": 20.0, "status": "paid"},
{"date": "2026-11-05", "qty": 2, "price": 25.0, "status": "paid"},
{"date": "2026-11-06", "qty": 6, "price": 15.0, "status": "paid"},
{"date": "2026-11-07", "qty": 6, "price": 20.0, "status": "paid"},
{"date": "2026-11-09", "qty": 2, "price": 20.0, "status": "paid"},
{"date": "2026-11-09", "qty": 1, "price": 15.0, "status": "paid"},
{"date": "2026-11-10", "qty": 2, "price": 25.0, "status": "paid"},
{"date": "2026-11-11", "qty": 2, "price": 20.0, "status": "paid"},
{"date": "2026-11-12", "qty": 2, "price": 20.0, "status": "refunded"},
{"date": "2026-11-13", "qty": 4, "price": 25.0, "status": "paid"},
{"date": "2026-11-14", "qty": 3, "price": 25.0, "status": "paid"},
{"date": "2026-11-14", "qty": 2, "price": 15.0, "status": "paid"},
]
Definitions: - Paid sales for a date = the sum of qty × price over that date's paid lines. - A day the shop was open with no paid sales counts as 0.
What to submit (10-part format)
| Part | Required content |
|---|---|
| a | The business question in your own precise words, and the decision owner |
| b | A measurable success indicator for the staffing decision |
| c | Facts vs assumptions: at least 3 of each, plus constraints and unknowns |
| d | Decomposition: at least 3 sub-questions, each with a measure |
| e | Pseudocode for your procedure, using L18 conventions, traced on at least two dates |
| f | A runnable Python solution: at least one function, using standard Python only. It must use open_days correctly, so that open days with no paid sales count as 0 |
| g | At least three tests using the L19 check helper (or assert). Include: one normal case, one edge case (e.g., an open day with only refunded sales, an empty sales list, or a tie), and one exclusion case (refunds) |
| h | Independent expected results, worked out by hand before running. You need expected results for your tests and for the full two-week data, then an expected → actual → PASS/FAIL table |
| i | Interpretation, limits and one recommendation for the manager, with evidence, two limits, the owner and a next check |
| j | AI-use and verification note: what AI was used for, what you checked, what you accepted or rejected, what remained your judgment. If none, write "No AI used" and how you verified your work |
Rubric (each criterion 0–2)
| # | Criterion | 2 — Meets | 1 — Partly | 0 — Not yet |
|---|---|---|---|---|
| C1 | Framing (a–c) | Precise question; named decision owner; measurable success indicator; facts and assumptions correctly separated | One element vague or mislabelled | Missing, or assumptions presented as facts |
| C2 | Decomposition and pseudocode (d–e) | Sub-questions with measures; complete, unambiguous pseudocode, traced on two or more dates | Gaps, unnecessary steps, or no trace | Missing |
| C3 | Python correctness (f) | Runs; correct weekday averages for the full data, including the open day with no paid sales | Runs, but one calculation or rule is wrong | Does not run, or is mostly wrong |
| C4 | Tests and independent verification (g–h) | At least 3 tests, including edge and exclusion; expected values independent of the code; full-data comparison shown | Fewer tests, or a required test type missing, or expectations not clearly independent | No tests, or expected values copied from output |
| C5 | Recommendation (i) | One action that follows from verified evidence, with two honest limits, the owner and a next check | Action vague, or limits or next check missing | Not supported by evidence, or the decision is given to AI |
| C6 | AI-use and verification note (j) | Specific and complete | Vague | Missing |
Gate conditions (all must be met to pass)
- G1 — Verified answer: the weekday recommended in part i matches the correct calculation from the data (averaged over all open days for each weekday).
- G2 — Independent tests: part h shows hand-worked expected results for at least three tests and for the full data, compared with actual output.
- G3 — Human decision ownership and honesty: a person or role is named as the decision owner; assumptions are not stated as facts; the AI-use note is present.
Result
- PASS: a total of 9 or more out of 12, no criterion scored 0, all gates met.
- REVISE: anything else. Feedback names the criteria to improve, and one resubmission is allowed.
Why this threshold? It requires solid overall performance (75%) while allowing minor weaknesses. The gates protect what matters most at the end of Stage 1: a verified answer, independent tests, and human ownership of the decision. The threshold is an instructional design choice, not statistically validated, and should be reviewed after learner pilot data.
This assessment checks understanding of U05 and Stage 1 concepts. It is not a certification and makes no claim about job readiness.
تقييم نهاية الوحدة U05 — حل المشكلات والتفكير الحاسوبي
تعليمات ومعايير تقييم موجّهة للمتعلّم. الحل المرجعي والنتائج المتوقعة وملاحظات التصحيح موجودة في ملف المدرّس فقط (05). الإصدار: U05 v1.0 · 12 أكتوبر 2026.
معيار إنهاء الوحدة (خريطة D.World): حُلّ مشكلة أعمال صغيرة من السؤال حتى إجابة Python متحقَّق منها.
الوقت المتوقع: من 75 إلى 90 دقيقة (مبدئي؛ ذاتي الوتيرة، وليس حدًا زمنيًا).
الشكل:
- سكربت Python واحد (
.py)؛ - تقرير مكتوب واحد من 400 إلى 700 كلمة، يتبع صيغة الأجزاء العشرة من L20. والجداول والكود الوصفي والكود لا تُحسب ضمن عدد الكلمات.
ما تحتاجه: Python 3، بالمكتبة القياسية فقط. لا تحتاج إلى حزم أو حسابات أو اتصال بالإنترنت.
المسموح:
- ملاحظاتك من U01 إلى U05؛
- The Python Tutorial؛
- مساعد ذكاء اصطناعي فقط للعصف الذهني، أو تصحيح الأخطاء، أو التوثيق، مع التصريح بذلك في الجزء j.
يجب ألا يختار الذكاء الاصطناعي توصيتك.
الحالة (نشاط خيالي، بيانات مصطنعة)
Pine Street Books مكتبة صغيرة خيالية، تفتح من الإثنين إلى السبت. يكتب المدير:
"أستطيع تحمّل تكلفة موظف إضافي واحد في يوم عمل واحد كل أسبوع. أريده في اليوم الذي يكون عادةً الأكثر ازدحامًا في المبيعات. أي يوم من أيام الأسبوع يجب أن يكون؟"
الأيام التي فتحت فيها المكتبة (أسبوعان):
open_days = [
{"date": "2026-11-02", "weekday": "Mon"}, {"date": "2026-11-03", "weekday": "Tue"},
{"date": "2026-11-04", "weekday": "Wed"}, {"date": "2026-11-05", "weekday": "Thu"},
{"date": "2026-11-06", "weekday": "Fri"}, {"date": "2026-11-07", "weekday": "Sat"},
{"date": "2026-11-09", "weekday": "Mon"}, {"date": "2026-11-10", "weekday": "Tue"},
{"date": "2026-11-11", "weekday": "Wed"}, {"date": "2026-11-12", "weekday": "Thu"},
{"date": "2026-11-13", "weekday": "Fri"}, {"date": "2026-11-14", "weekday": "Sat"},
]
بنود المبيعات (أسبوعان):
sales = [
{"date": "2026-11-02", "qty": 4, "price": 15.0, "status": "paid"},
{"date": "2026-11-03", "qty": 3, "price": 15.0, "status": "paid"},
{"date": "2026-11-04", "qty": 2, "price": 25.0, "status": "paid"},
{"date": "2026-11-05", "qty": 4, "price": 20.0, "status": "paid"},
{"date": "2026-11-05", "qty": 2, "price": 25.0, "status": "paid"},
{"date": "2026-11-06", "qty": 6, "price": 15.0, "status": "paid"},
{"date": "2026-11-07", "qty": 6, "price": 20.0, "status": "paid"},
{"date": "2026-11-09", "qty": 2, "price": 20.0, "status": "paid"},
{"date": "2026-11-09", "qty": 1, "price": 15.0, "status": "paid"},
{"date": "2026-11-10", "qty": 2, "price": 25.0, "status": "paid"},
{"date": "2026-11-11", "qty": 2, "price": 20.0, "status": "paid"},
{"date": "2026-11-12", "qty": 2, "price": 20.0, "status": "refunded"},
{"date": "2026-11-13", "qty": 4, "price": 25.0, "status": "paid"},
{"date": "2026-11-14", "qty": 3, "price": 25.0, "status": "paid"},
{"date": "2026-11-14", "qty": 2, "price": 15.0, "status": "paid"},
]
التعريفات:
- المبيعات المدفوعة لتاريخ ما = مجموع qty × price لبنود ذلك التاريخ المدفوعة.
- اليوم الذي فتحت فيه المكتبة أبوابها ولم تكن فيه مبيعات مدفوعة يُحسب 0.
ما الذي تسلّمه؟ (صيغة الأجزاء العشرة)
| الجزء | المحتوى المطلوب |
|---|---|
| a | سؤال الأعمال بكلماتك الدقيقة أنت، وصاحب القرار |
| b | مؤشر نجاح قابل للقياس لقرار التوظيف |
| c | الحقائق مقابل الافتراضات: 3 على الأقل من كل منهما، بالإضافة إلى القيود والمجهولات |
| d | التفكيك: 3 أسئلة فرعية على الأقل، لكل منها مقياس |
| e | كود وصفي لإجرائك، باستخدام اصطلاحات L18، مع تتبّعه على تاريخين على الأقل |
| f | حل Python قابل للتشغيل: دالة واحدة على الأقل، بـ Python القياسي فقط. ويجب أن يستخدم open_days بشكل صحيح، بحيث تُحسب أيام الفتح التي ليس فيها مبيعات مدفوعة 0 |
| g | ثلاثة اختبارات على الأقل باستخدام الدالة المساعدة check من L19 (أو assert). وتشمل: حالة عادية واحدة، وحالة طرفية واحدة (مثل يوم فتح ليس فيه إلا مبيعات مستردّة، أو قائمة مبيعات فارغة، أو تساوٍ)، وحالة استبعاد واحدة (الاستردادات) |
| h | نتائج متوقعة مستقلة، محسوبة يدويًا قبل التشغيل. وتحتاج إلى نتائج متوقعة لاختباراتك ولبيانات الأسبوعين كاملة، ثم جدول المتوقع ← الفعلي ← PASS/FAIL |
| i | التفسير، والحدود، وتوصية واحدة للمدير، مع الأدلة، وحدّين، وصاحب القرار، وفحص تالٍ |
| j | ملاحظة استخدام الذكاء الاصطناعي والتحقق: فيمَ استُخدم الذكاء الاصطناعي، وما الذي راجعته، وما الذي قبلته أو رفضته، وما الذي بقي حكمك أنت. وإذا لم تستخدمه، فاكتب "No AI used" (لم أستخدم الذكاء الاصطناعي) وكيف تحققت من عملك |
معايير التقييم (كل معيار من 0 إلى 2)
| # | المعيار | 2 — يحقق المطلوب | 1 — يحققه جزئيًا | 0 — لم يحققه بعد |
|---|---|---|---|---|
| C1 | الصياغة (a–c) | سؤال دقيق؛ وصاحب قرار محدد بالاسم أو الدور؛ ومؤشر نجاح قابل للقياس؛ والحقائق والافتراضات مفصولة بشكل صحيح | عنصر واحد مبهم أو مصنّف خطأً | غير موجود، أو الافتراضات معروضة كحقائق |
| C2 | التفكيك والكود الوصفي (d–e) | أسئلة فرعية لها مقاييس؛ وكود وصفي كامل وواضح، متتبَّع على تاريخين أو أكثر | ثغرات، أو خطوات غير ضرورية، أو لا يوجد تتبّع | غير موجود |
| C3 | صحة كود Python (f) | يعمل؛ ومتوسطات أيام الأسبوع صحيحة للبيانات كاملة، بما في ذلك يوم الفتح الذي ليس فيه مبيعات مدفوعة | يعمل، لكن حسابًا واحدًا أو قاعدة واحدة خاطئة | لا يعمل، أو معظمه خاطئ |
| C4 | الاختبارات والتحقق المستقل (g–h) | 3 اختبارات على الأقل، منها الطرفي والاستبعاد؛ والقيم المتوقعة مستقلة عن الكود؛ والمقارنة على البيانات كاملة معروضة | اختبارات أقل، أو نوع اختبار مطلوب ناقص، أو القيم المتوقعة ليست مستقلة بوضوح | لا توجد اختبارات، أو القيم المتوقعة منسوخة من المخرجات |
| C5 | التوصية (i) | إجراء واحد ينبع من أدلة متحقَّق منها، مع حدّين مذكورين بصدق، وصاحب القرار، وفحص تالٍ | الإجراء مبهم، أو الحدود أو الفحص التالي غير مذكورة | لا تدعمها الأدلة، أو تُرك القرار للذكاء الاصطناعي |
| C6 | ملاحظة استخدام الذكاء الاصطناعي والتحقق (j) | محددة وكاملة | مبهمة | غير موجودة |
شروط أساسية (يجب تحقيقها كلها للنجاح)
- G1 — إجابة متحقَّق منها: يوم الأسبوع الموصى به في الجزء i يطابق الحساب الصحيح من البيانات (المتوسط محسوب على كل أيام الفتح لكل يوم من أيام الأسبوع).
- G2 — اختبارات مستقلة: يعرض الجزء h نتائج متوقعة محسوبة يدويًا لثلاثة اختبارات على الأقل وللبيانات كاملة، مقارنةً بالمخرجات الفعلية.
- G3 — ملكية بشرية للقرار وأمانة: يُذكر شخص أو دور بوصفه صاحب القرار؛ ولا تُعرض الافتراضات على أنها حقائق؛ وملاحظة استخدام الذكاء الاصطناعي موجودة.
النتيجة
- PASS (ناجح): مجموع 9 أو أكثر من 12، ولا يوجد معيار حصل على 0، وكل الشروط الأساسية متحققة.
- REVISE (يحتاج تعديلًا): أي نتيجة أخرى. تحدد الملاحظات المعايير التي تحتاج إلى تحسين؛ ويُسمح بإعادة التسليم مرة واحدة.
لماذا هذا الحد؟ لأنه يتطلب أداءً قويًا في المجمل (75%) مع السماح بنقاط ضعف صغيرة. والشروط الأساسية تحمي أهم ما في نهاية المرحلة 1: إجابة متحقَّق منها، واختبارات مستقلة، وملكية بشرية للقرار. هذا الحد حكم تصميمي، وليس مُثبتًا إحصائيًا، ويجب مراجعته بعد توفر بيانات التجربة مع المتعلّمين.
هذا التقييم يقيس فهمك لمفاهيم U05 والمرحلة 1. وهو ليس شهادة معتمدة، ولا يدّعي أي شيء عن جاهزيتك للعمل.
Keep goingاستمر
Finish each unit's exit check before you move on. Your certificate lists the checks you passed.
أنهِ تقييم نهاية كل وحدة قبل أن تنتقل. شهادتك تعرض التقييمات التي اجتزتها.