Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Function print() | First Acquaintance with Dart
Introduction to Dart
course content

Conteúdo do Curso

Introduction to Dart

Introduction to Dart

1. First Acquaintance with Dart
2. Variables and Data Types
3. Conditional Statements
4. List and String
5. Loops

bookFunction print()

Let's take a detailed look at how to use the print() function:

Print with Text

dart

main

copy
123
void main() { print("Text you want to output"); }

After starting, the program prints information to the console from the parentheses of the print() function. If we want to output the text to the console, we must write it inside the quotation marks.

dart

main

copy
1234
void main() { print('Hi, Codefinity!'); print("I want know more"); }

Rules

The text can be written in single quotation marks:

The text also can be written in double quotation marks:

The main rule when using the print() function is that it's important for the quotation marks surrounding the text to match on both sides. For example, if we use single quotes to print text ('like this'), we must close them with single quotes as well. This allows Python to correctly recognize it as text to be printed, rather than a variable name or instruction. If the quotation marks do not match, or if they are absent altogether, it can lead to a runtime error in the program.

Print with Numbers

Working with numbers is different from working with text. Suppose you want to display numbers. Since we work with number values, you don't need to use quotes (" " or ' ').

dart

main

copy
123
void main() { print(2); }

We will consider working with numbers and mathematical operations in detail in Chapter 5.

Find the line of code with the error.

Find the line of code with the error.

Selecione a resposta correta

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 3
some-alt