Day 1: Introduction to Python
Hello everyone! Welcome to Day 1 of our 100 Days to Learn Python journey! Today, we will start by understanding what Python is, its importance, and how to get started.
What is Python?
- Python is a popular, high-level programming language that was created by Guido van Rossum and first released in 1991. It’s designed to be easy to read and simple to write, making it perfect for both beginners and advanced programmers. Python allows developers to focus on solving problems rather than worrying about the complex syntax often found in other programming languages.
Why Learn Python?
1. High demand: Many companies need Python programmers.
2. Versatile: You can use Python for web development, data analysis, machine learning, game development, automation, and more.
3. Great community: There are many resources, forums, and libraries available online.
Who Built Python?
- Python was created by Guido van Rossum in the late 1980s and released in 1991. He named it after the British comedy show “Monty Python’s Flying Circus” which he enjoyed watching. This is why Python has such a fun and approachable feel to it.
Setting Up Python
To start coding in Python, you need to install python on your computer. Here’s how:
1. Visit the Python website: Search for "Python" in your browser to find the official website "https://www.python.org/".
2. Download Python: Choose the latest version suitable for your operating system (Windows, Mac, or Linux).
3. Install Python: Open the downloaded file and follow the instructions to install it.
Choosing an IDE
An Integrated Development Environment (IDE) helps you write and run your Python code easily. Here are some popular IDEs you can use:
1. Visual Studio Code: A powerful and flexible editor for coding.
2. PyCharm: A popular IDE specifically for Python.
3. Jupyter Notebook: Useful for data science and quick coding tests.
You can download these IDEs from their official websites by searching their names in your browser.
Writing Your First Python Program in Different IDEs
Here’s how you can run your first Python program using three different IDEs: Visual Studio Code, PyCharm, and Jupyter Notebook:
1. Running `hello_world.py` in Visual Studio Code (VS Code)
1.Create a Project Folder: Before you begin, create a folder called `python_work` on your system where you will save your projects. Use lowercase letters and underscores for spaces in the folder name.
2.Open Visual Studio Code: Open VS Code and install the Python extension if you haven’t already. This will help VS Code recognize Python code and provide features like code completion and running Python files.
3.Create a New File: In the `python_work` folder, create a new file and name it `hello_world.py`. You can do this by clicking `File > New File` and then `File > Save As`, naming it `hello_world.py`.
4.Write Your Code: Type the following line of code into the file:
print("Hello, Python world!")
5. Run the Program:
- Open the terminal in VS Code by going to `Terminal > New Terminal`.
- In the terminal, type the following command to run your Python file:
hello_world.py
- You should see the output:
Hello, Python world!
Optional: You can also press the play button (`Run Python File`) in the top right of the VS Code window to run the file directly.
2. Running `hello_world.py` in PyCharm
1. Create a Project Folder: As with VS Code, create a folder called `python_work` for all your Python projects.
2. Open PyCharm: Launch PyCharm, and select “New Project.” Choose the `python_work` folder as your project directory. Ensure you have the right Python interpreter selected(PyCharm should detect it automatically if Python is installed).
python_work
folder within PyCharm, right-click the folder and select New > Python File
. Name the file hello_world.py
.4. Write Your Code: Enter the following line of code in your new Python file:
print("Hello, Python world!")
5. Run the Program:
- Right-click the `hello_world.py` file and select `Run 'hello_world'`.
- You should see the output in the console at the bottom of the PyCharm window:
3. Running `hello_world.py` in Jupyter Notebook
1. Install Jupyter Notebook: If you don’t have Jupyter Notebook installed, you can install it using the following command in your terminal:
pip install notebook
2. Create a Project Folder: Create a folder named `python_work` where you will save your projects.
3. Launch Jupyter Notebook: Open your terminal, navigate to the `python_work` folder, and type the following command:
jupyter notebook
This will open Jupyter in your web browser.
4. Create a New Notebook: In Jupyter, click on `New` in the top-right corner and select `Python 3 (ipykernel)`.
5. Write Your Code: In the first cell, enter the following code:
print("Hello, Python world!")
6. Run the Program:
- Click the `Run` button or press `Shift + Enter` to run the code.
- You should see the output directly below the cell:
Hello, Python world!
Thank you for being a part of this journey to learn Python in 100 days! Your interest and desire to learn are very important. I hope you find the tutorials and tips helpful as you move forward. Please share your thoughts, questions, or experiences in the comments below. Let’s learn and grow together!
Happy coding!
Comments
Post a Comment