Int وFloat وBool
تعامَل مع أنواع Mojo العددية والمنطقية
Int وFloat وBool درس مجاني في Mojo Academy على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Mojo Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Mojo Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Values Have Types
Every value belongs to a type that says what it is and what you can do with it. Three core types start you off.
Int for Whole Numbers
An Int holds whole numbers like counts and indexes, with no fractional part at all.
var count = 42Math with Int
Ints support the usual arithmetic. Add, subtract, and multiply them just as you would expect on whole numbers.
var apples = 3 + 4
print(apples)Float for Decimals
A Float stores numbers with a decimal point, perfect for measurements, prices, and anything fractional.
var price = 9.99Int and Float Differ
10 is an Int but 10.0 is a Float. The decimal point is what makes a literal a Float instead of an Int.
var whole = 10
var fraction = 10.0Float Division
Dividing with / gives a Float result so fractions are not lost. That keeps precision when numbers do not divide evenly.
var half = 5 / 2
print(half)Bool Is True or False
A Bool holds just one of two values: True or False. It answers yes-or-no questions in your logic.
var is_ready = TrueComparisons Make Bools
Comparing values produces a Bool. The expression 3 > 2 evaluates to True, while 1 == 2 is False.
var bigger = 3 > 2
print(bigger)Bools Drive Decisions
Bools feed your if-statements later. Storing a comparison in a clearly named Bool makes branching code read well.
var is_adult = age >= 18Pick the Right Number Type
Use Int when fractions cannot exist, like a head count. Reach for Float when a value can have a decimal.
Three Tools, Many Programs
Int, Float, and Bool already cover counting, measuring, and deciding. Most logic you write leans on these core types.
Quick Check
You write the literal 10.0 instead of 10 in your Mojo code. What type is that value?
Recap
Int counts, Float measures with decimals, and Bool holds True or False. Comparisons produce Bools that steer your logic. 🎯
الأسئلة الشائعة
هل درس «Int وFloat وBool» مجاني؟
نعم — نص درس «Int وFloat وBool» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Mojo Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Mojo Academy 4 دروس في المجموع.
ماذا ستتعلم في «Int وFloat وBool»؟
تعامَل مع أنواع Mojo العددية والمنطقية تتمرن على Mojo Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Mojo Academy؟
لا تُشترط خبرة سابقة. Mojo Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.
كم من الوقت يستغرق درس «Int وFloat وBool»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Mojo Academy هذا؟
نعم. كل درس في Mojo Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- التصريح بالقيم باستخدام var
- Int وFloat وBool
- السلاسل والنصوص
- تعليقات الأنواع المفيدة