Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Basic Math Operations | First Acquaintance with Dart
Introduction to Dart

bookBasic Math Operations

You already know how to use the print() function to display text. It can also be used to output numbers and perform mathematical calculations. Use print() whenever you want to display data. Do not use quotes (" " or ' '), since this time you’re evaluating a mathematical expression.

main.dart

main.dart

copy
12345
void main() { print('Two'); // String print('2'); // String print(2); // Number }
Note
Study More

In Dart, if a number is written in quotes ("123"), it is treated as text (a string) rather than an actual number. This means you can't perform math operations like addition or multiplication on it.

Almost no program can do without mathematical calculations, so Dart supports the following mathematical operations:

main.dart

main.dart

copy
1234567
void main() { print(1+2); // Adding numbers print(9-3); // Subtracting numbers print(4/2); // Division of numbers print(4*2); // Multiplication of numbers print(5%2); // Get the remainder from the whole division of 5 by 2 }

You can also write mathematical expressions. The order of operations follows standard math rules, so 2 + 2 * 2 = 6 because multiplication is performed before addition.

main.dart

main.dart

copy
123
void main() { print(2+2*2); }
Note
Note

The same rule applies to brackets, expressions inside parentheses are calculated first, just like in regular mathematics.

question mark

Select the correct numbers multiplication.

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 5

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Awesome!

Completion rate improved to 4.55

bookBasic Math Operations

Свайпніть щоб показати меню

You already know how to use the print() function to display text. It can also be used to output numbers and perform mathematical calculations. Use print() whenever you want to display data. Do not use quotes (" " or ' '), since this time you’re evaluating a mathematical expression.

main.dart

main.dart

copy
12345
void main() { print('Two'); // String print('2'); // String print(2); // Number }
Note
Study More

In Dart, if a number is written in quotes ("123"), it is treated as text (a string) rather than an actual number. This means you can't perform math operations like addition or multiplication on it.

Almost no program can do without mathematical calculations, so Dart supports the following mathematical operations:

main.dart

main.dart

copy
1234567
void main() { print(1+2); // Adding numbers print(9-3); // Subtracting numbers print(4/2); // Division of numbers print(4*2); // Multiplication of numbers print(5%2); // Get the remainder from the whole division of 5 by 2 }

You can also write mathematical expressions. The order of operations follows standard math rules, so 2 + 2 * 2 = 6 because multiplication is performed before addition.

main.dart

main.dart

copy
123
void main() { print(2+2*2); }
Note
Note

The same rule applies to brackets, expressions inside parentheses are calculated first, just like in regular mathematics.

question mark

Select the correct numbers multiplication.

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 5
some-alt