Day 1: Python Basics (15-Minute Tutorial)

by admin

Day 1: Python Basics (15-Minute Tutorial)

1. Overview of Python

  • Python is a high-level, interpreted programming language known for its readability and simplicity.
  • It’s widely used in various domains, including web development, data analysis, artificial intelligence, and more.

2. Setting Up Your Environment

  • Install Python: Download and install the latest version of Python from python.org.
  • Choose an IDE: You can use any code editor, but popular options include:
    • Jupyter Notebook: Ideal for data analysis and visualization.
    • VS Code: A versatile code editor with excellent support for Python.
    • PyCharm: A powerful IDE specifically for Python development.

3. Basic Syntax and Data Types

  • Variables: Used to store data.
    python
    name = "John" # String
    age = 30 # Integer
    height = 5.9 # Float
    is_student = True # Boolean
  • Data Types: Common data types in Python include:
    • Strings (str)
    • Integers (int)
    • Floats (float)
    • Booleans (bool)

4. Control Flow

  • If/Else Statements: Allow you to execute code based on conditions.
    python
    if age > 18:
    print("You are an adult.")
    else:
    print("You are a minor.")
  • Loops: Used to execute a block of code multiple times.
    • For Loop:
      python
      for i in range(5):
      print(i)
    • While Loop:
      python
      count = 0
      while count < 5:
      print(count)
      count += 1

5. Functions

  • Functions are blocks of reusable code.
    python
    def greet(name):
    return f"Hello, {name}!"
    print(greet(“Alice”))

6. Input/Output

  • Input: Get user input using input().
    python
    user_name = input("Enter your name: ")
    print(greet(user_name))
  • Output: Print statements display results on the console.

7. Practice Exercise (5 minutes)

  • Write a function that takes a number as input and returns whether it is even or odd.
  • Use the input function to get a number from the user and print the result.

Next Steps

For your next session, we’ll dive into more Python concepts, such as data structures and libraries commonly used in data analysis and AI.

Leave a Comment