Skip to content
!pip install pptx
!pip install presen
# Start coding here... 
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
np.random.seed(0)
x = np.random.rand(100, 1)
y = 2 + 3 * x + np.random.rand(100, 1)
plt.scatter(x, y)
plt.xlabel('x')
plt.ylabel('y')
plt.show()
X = np.hstack((np.ones((100, 1)), x))
beta = np.linalg.inv(X.T.dot(X)).dot(X.T).dot(y)
y_pred = X.dot(beta)
print(y_pred)
x = [["a","b"],["c","d"],["e,f"]]
print(x[0][1])
from pptx import Presentation
from pptx.util import Inches
from pptx.enum.chart import XL_CHART_TYPE

def create_presentation_with_chart(file_name):
    # Create a new presentation
    prs = Presentation()

    # Add a slide with a title and content
    slide_layout = prs.slide_layouts[1]  # 1 corresponds to the title and content layout
    slide = prs.slides.add_slide(slide_layout)
    title = slide.shapes.title
    title.text = "Example PowerPoint Presentation with Python"

    content_box = slide.placeholders[1]
    content_box.text = "This is an example PowerPoint presentation generated using Python."

    # Add a slide with a chart
    slide = prs.slides.add_slide(prs.slide_layouts[5])  # 5 corresponds to the title and chart layout

    chart_data = (
        ("Category 1", 10),
        ("Category 2", 20),
        ("Category 3", 15),
        ("Category 4", 25),
        ("Category 5", 30)
    )

    x, y = Inches(2), Inches(2)
    cx, cy = Inches(6), Inches(4.5)

    chart = slide.shapes.add_chart(
        XL_CHART_TYPE.COLUMN_CLUSTERED, x, y, cx, cy, chart_data
    ).chart

    chart.has_legend = True
    chart.legend.position = XL_LEGEND_POSITION.BOTTOM

    chart.chart_title.has_text_frame = True
    chart.chart_title.text_frame.text = "Example Chart"

    # Save the presentation to a file
    prs.save(file_name)

if __name__ == "__main__":
    presentation_file = "example_presentation_with_chart.pptx"
    create_presentation_with_chart(presentation_file)
    print(f"The presentation has been created and saved to {presentation_file}.")
pip install --upgrade pip
!pip install pptx