Python Programming Basics
Python is a popular, high-level, interpreted programming language known for its simplicity and
readability. It is widely used in web development, data science, automation, artificial intelligence,
and more.
1. Setting Up Python
To start coding in Python, you need to install:
- Python (from python.org)
- A code editor like VS Code or PyCharm
To verify installation, type `python --version` or `python3 --version` in your terminal.
2. Your First Python Program
Here is a simple Python program that prints "Hello, World!":
```python
print("Hello, World!")
```
To run:
1. Save as hello.py
2. Run: `python hello.py` or `python3 hello.py`
3. Variables and Data Types
Python supports various data types:
- int: Integer numbers
- float: Floating point numbers
- str: Text
- bool: true/false
- list, tuple, dict: Collections
Example:
```python
age = 25
price = 19.99
name = "John"
is_python_fun = True
```
4. Control Flow
Python supports if-else, for loops, and while loops.
Example (if-else):
```python
number = 10
if number > 0:
print("Positive number")
else:
print("Negative number")
```