Automation, Orchestration, and Scripting
A script runs port = input('Port: ') and the user types 8080. The script then evaluates port > 1024 and fails with a TypeError. What is the data type of port?
Show the answer
Correct answerD. String
input() always returns a string, so port holds '8080' and cannot be compared with an integer. Integer is tempting because the user typed digits, but the value is converted only when the script calls int().