Setting Up Python
- Installation:
- Windows: Download the installer from the official Python website and run it.
- macOS: Use Homebrew (
brew install python
) or download from the official website. - Linux: Use the package manager (
sudo apt-get install python3
for Debian-based systems orsudo yum install python3
for Red Hat-based systems).
- Verifying Installation:
- Open a terminal or command prompt.
- Type
python --version
orpython3 --version
to check the installed version.
- IDE and Text Editors:
- IDEs: PyCharm, Visual Studio Code, Spyder.
- Text Editors: Sublime Text, Atom, Notepad++.
Writing and Running Python Code
Hello, World!:
print("Hello, World!")
Save the file with a .py
extension (e.g., hello.py
).Run the script from the terminal: python hello.py
or python3 hello.py
.
Python Shell/REPL:
- Interactive Python shell allows executing Python commands line by line.
- Access it by typing
python
orpython3
in the terminal.