Every Python script can print output with print(). Unlike JavaScript console.log or Java System.out.println, Python's built-in needs no import—it is always available.
Minimal program
print("Hello, World")
print writes to stdout and adds a newline by default. Pass end="" to suppress the trailing newline when needed.
Script vs REPL
# script.py
print("Hello, World")
# REPL: python3
# >>> print("Hello, World")
The playground runs scripts like python3 your_file.py. The REPL is great for quick experiments locally—similar to browser DevTools for JS.
Important interview questions and answers
- Q: What prints text in Python?
A:print()sends objects to stdout; web frameworks use different logging in the Django track. - Q: Is an entry point required?
A: Nomainrequired—top-level statements run on import or script execution; idiomatic projects useif __name__ == "__main__":.
Self-check
- Which built-in function prints to stdout?
- What does
end=""change in print?
Tip: Use if __name__ == "__main__": in real projects so modules can be imported without side effects.
Interview prep
- What prints text?
print()writes to stdout; addend=""to suppress the trailing newline.- Entry point required?
No
mainrequired—idiomatic projects useif __name__ == "__main__":for script-only code.