I just started my first computer science course in a long time and encountered some code that I didn't understand. I studied python over the summer but the function definitions were simpler. Here's the code:
def f1(thing: list) -> None:
thing = ['x', 1] + thing
if __name__ == '__main__':
phone = [9]
f1(phone)
print(phone)
My questions are:
- What does the term in brackets mean i. e. '(thing: list)', more specifically, why doesn't it just say '(thing)'.
- What does '-> None' mean?
- What is the purpose of the if statement's first line i. e. 'if __name__ == '__main__':'
- In class someone told me that the value of the variable 'phone' stays the same because the function definition doesn't return anything. I can't remember that being necessary for function definitions. Is that always the case?
Sorry if these questions seem a bit naive. I took the prerequisite course a long time ago and am reviewing the material in the first week of class.