Python - Standard Library UsageWhy does os.path.join('folder', '/file.txt') ignore the first argument and return '/file.txt'?ABecause '/file.txt' is an absolute path, resetting the joinBBecause os.path.join only joins relative pathsCBecause the first argument must be absoluteDBecause join concatenates strings without separatorCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand absolute path behavior in os.path.joinIf any argument is absolute, all previous parts are discarded and join starts from that argument.Step 2: Apply to given exampleSince '/file.txt' starts with '/', it is absolute, so 'folder' is ignored.Final Answer:Because '/file.txt' is an absolute path, resetting the join -> Option AQuick Check:Absolute path resets join parts [OK]Quick Trick: Absolute path in join resets previous parts [OK]Common Mistakes:MISTAKESThinking join always concatenatesIgnoring absolute path rules
Master "Standard Library Usage" in Python9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Python Quizzes Constructors and Object Initialization - Self reference - Quiz 13medium Context Managers - Handling multiple resources - Quiz 15hard Context Managers - Handling multiple resources - Quiz 3easy Encapsulation and Data Protection - Public attributes - Quiz 7medium Exception Handling Fundamentals - Multiple exception handling - Quiz 10hard File Handling Fundamentals - Appending data to files - Quiz 1easy Methods and Behavior Definition - Instance methods - Quiz 12easy Polymorphism and Dynamic Behavior - Method overriding behavior - Quiz 8hard Structured Data Files - Why structured data formats are used - Quiz 5medium Structured Data Files - Formatting structured data - Quiz 4medium