- 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: Tricky Python Questions
This hard Python quiz is full of snippets that look simple but behave in surprising ways. It covers equal dict keys, operator precedence, nan, empty iterables, class scope and other traps interviewers love to ask about.
Domanda di esempio
Domanda 1 di 10What does this print?
d = {True: "a", 1: "b", 1.0: "c"}
print(d)
Mostra la risposta
C. {True: 'c'} True == 1 == 1.0 and they have the same hash, so all three are the same key. The first key object (True) is kept, while each later assignment replaces the value, ending with 'c'.
Cosa copre questo quiz
- Dict keys that are equal, like
True,1and1.0 - Operator precedence with
**and unary minus - When a generator expression reads its names
nan,all([])and other edge cases- Changing a dict while looping over it, and class body scope
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.