Skip to content

Commit aebd05a

Browse files
authored
Add hints for most of the basic challenges & improved basic-optional (#72)
1 parent 4eadc5c commit aebd05a

File tree

12 files changed

+19
-3
lines changed

12 files changed

+19
-3
lines changed

challenges/basic-dict/hints.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Check out [Dict](https://docs.python.org/3/library/typing.html#typing.Dict) or use the built-in `dict` function, the syntax for using `dict` for typing looks like this: `dict[KT, VT]`.

challenges/basic-final/hints.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Check out [Final](https://docs.python.org/3/library/typing.html#typing.Final).

challenges/basic-list/hints.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Check out [List](https://docs.python.org/3/library/typing.html#typing.List) or use the built-in `list` function, the syntax for using `list` for typing looks like this: `list[T]`.

challenges/basic-optional/hints.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- A union type can be created using the `|` operator, e.g: `X | Y`
2+
- `None` can be used for typing directly
3+
- Type hint doesn't simply make an argument "optional", that's the default value's job

challenges/basic-optional/question.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
TODO:
33
4-
foo can accept either an integer argument or no argument.
4+
foo can accept an integer argument, None or no argument at all.
55
"""
66

77

@@ -11,6 +11,7 @@ def foo(x):
1111

1212
## End of your code ##
1313
foo(10)
14+
foo(None)
1415
foo()
1516

1617
foo("10") # expect-type-error

challenges/basic-optional/solution.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ def foo(x: int | None = 0):
44

55
## End of your code ##
66
foo(10)
7+
foo(None)
78
foo()
89

910
foo("10") # expect-type-error

challenges/basic-parameter/hints.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The syntax for adding type hints to an argument is: `foo(x: T)`, replace `T` with the real type.

challenges/basic-return/hints.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The syntax for adding type hints to a return value is: `foo() -> T`, replace `T` with the real type.

challenges/basic-tuple/hints.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Check out [Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple).

challenges/basic-typealias/hints.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Check out [TypeAlias](https://docs.python.org/3/library/typing.html#typing.TypeAlias).

0 commit comments

Comments
 (0)