0Pricing
Mojo Academy · Lektion

Int, Float und Bool

Arbeiten Sie mit numerischen und booleschen Typen von Mojo.

Int, Float und Bool ist eine kostenlose Mojo Academy-Lektion auf CoddyKit. Dies ist Lektion 2 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Mojo Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Mojo Academy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

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 = 42

Math 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.99

Int 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.0

Float 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 = True

Comparisons 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 >= 18

Pick 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. 🎯

Häufig gestellte Fragen

Ist die Lektion „Int, Float und Bool“ kostenlos?

Ja — der vollständige Text von „Int, Float und Bool“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Mojo Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Mojo Academy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Int, Float und Bool“?

Arbeiten Sie mit numerischen und booleschen Typen von Mojo. Du übst Mojo Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Mojo Academy zu starten?

Keine Vorkenntnisse erforderlich. Mojo Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 2 von 4.

Wie lange dauert die Lektion „Int, Float und Bool“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Mojo Academy-Lektion Code schreiben und ausführen?

Ja. Jede Mojo Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Werte mit var deklarieren
  2. Int, Float und Bool
  3. Strings und Text
  4. Hilfreiche Typannotationen
← Zurück zu Mojo Academy