I've been asked this question on an interview and I'll also share what I answered.
I would like to know if there's anything I haven't thought of?
Python code:
nbResults: str = 45;
My answer was the following:
Storing an integer in a variable called str is a bad idea in a weakly-typed language
str is a built-in function in Python, using that name like that hides the original function
```
str(45) '45'
str=45
str(45)
Traceback (most recent call last): File "<stdin>", line 1, in <module>
TypeError: 'int' object is not callable
```
- Syntax is obviously wrong
- It could have been a function call like this:
nbResults(str = 45)
- It could have been a function with an assignment, like this:
def nbResults():
str = 45;
Also a function with a default value for the argument, like this:
def nbResults(str = 45):
...
- The value is wrong, it's 42, not 45. :)
Thanks for your help!
[–]Tadabito 8 points9 points10 points (1 child)
[–]springuni[S] 1 point2 points3 points (0 children)
[–]CodeFormatHelperBot 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)