If you want to type hint a variable that can be either an integer or a float, you would use Union[int, _______].
- Any
- float
- number
- real
To type hint a variable that can be either an integer or a float, you would use 'Union[int, float]'. The 'Union' type hint allows specifying multiple acceptable types.
Loading...
Related Quiz
- In a banking application, you have an Account class. If you want to set a minimum balance for all accounts regardless of their type, where would you define this value?
- A Python script unexpectedly terminates, and upon investigation, you discover a circular import. What could be a probable solution?
- You are building a recommendation engine and have a set of products bought by User A and another set for User B. To recommend new products to User A based on User B's purchases, which set operation would you use considering you don't want to recommend products User A has already bought?
- If multiple base classes have methods with the same name, method resolution in a derived class follows the _______ rule.
- What keyword is used to stop the execution of the current iteration and proceed to the next in a loop?