Table of Contents

Basic Syntax
| Title | Python | Dart |
|---|---|---|
| entry point | top-level statements | void main() |
| indentation | significant (spaces) | curly braces {} |
| statement end | newline | semicolon optional (but usually added) |
| type system | dynamic (PEP 526 annotations optional) | static + inference + null-safety |
| constants | convention: UPPER_CASE | final (run-time once) or const (compile-time) |
Basic Code in Python
print("Hello, world!")
Basic Code in Dart
void main() {
print('Hello, World!');
}
Print Function
| Feature | Python | Dart |
|---|---|---|
| plain text | print("hi") | print('hi'); |
| several items | print("Name:", name, "Age:", age) | print('Name: $name Age: $age'); |
| string interpolation | f"My score is {s}" | 'My score is $s' |
| multi-line | """line1\nline2""" | '''line1\nline2'''; |
| raw (no escapes) | r"C:\path" | r'C:\path'; |
