- Esecutori
-
Impara
Impara Python Esempi eseguibili, NumPy, pandas e altro Impara l'IA / Machine LearningReti neurali, ML e LLM da zero Impara C e C++ Puntatori, memoria, STL e C++ moderno Impara C#Fondamenti, OOP, LINQ, async ed esercizi .NET Impara MatplotlibGrafici a linee, barre, dispersione e torta con visualizzatori Impara RustOwnership, trait, gestione degli errori e thread Impara GoSlice, interfacce, goroutine e canali Algoritmi Python Ricerca, ordinamento, ricorsione e visualizzazioni O(n) Algoritmi C e C++ Confronta le implementazioni in C e C++ Programmazione per bambini Impara a programmare giocando!
- QuizNuovo
- SfideNuovo
- Per docentiNuovo
- Aggiornamenti
- Offrimi un caffè
Quiz Python: Type Hints
This Python quiz checks how well you understand type hints, from int | None and list[str] to Callable, Literal and NamedTuple. It also tests the most common misunderstanding of all - that Python checks your hints when the code runs.
Domanda di esempio
Domanda 1 di 10What does this print?
def add(a: int, b: int) -> int:
return a + b
print(add("4", "2"))
Mostra la risposta
C. 42 Python does not check type hints when the code runs. The two strings are simply joined with +, giving 42. A static checker like mypy would flag this call before you run it.
Cosa copre questo quiz
- Hints are not enforced at run time
int | None,list[str]anddict[str, int]Callable,LiteralandNamedTuple__annotations__and static checkers like mypy- Hints and
isinstance()
Domande frequenti
Serve un account?
No. Chiunque può giocare. Accedi per salvare XP, serie, badge e cronologia.
Quale versione di Python?
Python 3.12. Ogni domanda sull'output è stata verificata eseguendo il codice.
Posso rifarlo?
Sì. Il tuo miglior punteggio resta salvato, e domande e risposte vengono mescolate ogni volta.