# Economics 101 Presentation Generator This project automates the creation of PowerPoint presentations for Economics 101, focusing on both macro and microeconomics topics. Utilizing the `python-pptx` library, this script generates presentations with predefined slides tailored for advanced economic studies. ## Getting Started Follow these instructions to set up your project environment and run the presentation generation script. ### Prerequisites - Python 3.6 or higher - pip and venv ### Setting Up a Virtual Environment Creating a virtual environment is essential for managing project-specific dependencies. 1. **Navigate to Your Project Directory:** ```bash cd path/to/your/project ``` 2. **Create the Virtual Environment:** ```bash python3 -m venv env ``` 3. **Activate the Environment:** ```bash source env/bin/activate ``` ### Installing Dependencies After activating the virtual environment, install the required packages specified in `requirements.txt`. ```bash pip install -r requirements.txt ``` Example `requirements.txt` content: ``` python-pptx==x.x.x ``` ### Running the Script Make the script executable: ```bash chmod u+x Economics_101_Presentation.py ``` Run the script: ```bash ./Economics_101_Presentation.py ``` Or: ```bash python3 Economics_101_Presentation.py ``` ### Presentation Structure The script generates a PowerPoint presentation including slides on: - Introduction to Economics - Macroeconomics Overview - Microeconomics Overview - Fundamental Concepts - Macroeconomic Indicators - Microeconomic Analysis - Monetary Policy - Fiscal Policy - International Trade - Conclusion ### Customizing the Presentation To customize slide content and layout, modify the `PresentationCreator` class in your script: ```python #!/usr/bin/env python3 from pptx import Presentation from pptx.util import Inches, Pt from pptx.enum.shapes import MSO_SHAPE from pptx.enum.chart import XL_CHART_TYPE from pptx.chart.data import CategoryChartData from pptx.dml.color import RGBColor class PresentationCreator: """ A class to create PowerPoint presentations with predefined slide templates. Attributes: prs (Presentation): A python-pptx Presentation object. title (str): The title of the presentation. """ def __init__(self, title="Presentation"): """ Initializes the PresentationCreator with a title for the presentation. Args: title (str): The title of the presentation. """ self.prs = Presentation() self.title = title def add_section_header_slide(self, title): """ Adds a section header slide with a given title. Args: title (str): The title of the section. """ layout = self.prs.slide_layouts[1] # Use Title and Content layout slide = self.prs.slides.add_slide(layout) slide.shapes.title.text = title # Set a subtitle or a short description in the content placeholder if needed def add_two_content_slide(self, title, left_content, right_content): """ Adds a slide with a title and two content sections side by side. Args: title (str): The title of the slide. left_content (str): The content for the left section. right_content (str): The content for the right section. """ layout = self.prs.slide_layouts[1] # Reuse Title and Content layout slide = self.prs.slides.add_slide(layout) slide.shapes.title.text = title slide.placeholders[1].text = left_content # Placeholder for left content # Note: For a true side-by-side layout, consider adding a textbox or customizing the layout def add_comparison_slide(self, title, content): """ Adds a slide designed for comparisons. Note: This example simplifies to a single content area for demonstration. Args: title (str): The title of the slide. content (str): The content for comparison. """ layout = self.prs.slide_layouts[1] # Simplified use of Title and Content layout slide = self.prs.slides.add_slide(layout) slide.shapes.title.text = title slide.placeholders[1].text = content # Placeholder for comparison content def add_chart_slide(self, title, data): """ Adds a slide with a chart based on provided data. Args: title (str): The title of the slide. data (dict): The data for the chart, including categories and series. """ slide_layout = self.prs.slide_layouts[5] # Use Title Only layout for more chart space slide = self.prs.slides.add_slide(slide_layout) slide.shapes.title.text = title chart_data = CategoryChartData() chart_data.categories = data["categories"] for name, values in data["series"].items(): chart_data.add_series(name, values) x, y, cx, cy = Inches(2), Inches(1.5), Inches(6), Inches(4.5) chart = slide.shapes.add_chart( XL_CHART_TYPE.COLUMN_CLUSTERED, x, y, cx, cy, chart_data ).chart # Chart style and colors can be customized further def save_presentation(self, filename="presentation.pptx"): """ Saves the presentation to a file. Args: filename (str): The filename or path to save the presentation. """ self.prs.save(filename) # Example usage if __name__ == "__main__": creator = PresentationCreator("Economics 101 Presentation") # Adding slides creator.add_section_header_slide("Introduction to Economic Theories") creator.add_two_content_slide("Supply and Demand", "Supply Side Analysis", "Demand Side Analysis") creator.add_comparison_slide("Economic Models", "Comparative Analysis") # Chart data example for economic indicators chart_data_example = { "categories": ['2015', '2016', '2017', '2018', '2019'], "series": { "GDP Growth": (2.5, 2.9, 2.3, 3.1, 2.2), "Inflation Rate": (1.5, 1.8, 2.1, 1.9, 1.6), } } creator.add_chart_slide("Economic Indicators Over Time", chart_data_example) # Saving the presentation creator.save_presentation("./Economics_101_Presentation.pptx") ``` ## Project Structure - `src/`: Source code - `docs/`: Documentation - `tests/`: Test scripts and data - `data/`: Data files - `env/`: Virtual environment (excluded from version control) ## Deactivating the Virtual Environment ```bash deactivate ``` Ensure to replace `path/to/your/project` with your actual project path and adjust the `requirements.txt` as necessary for your dependencies.