Hook
OpenAI is a company that develops AI technology and offers an API for developers to interact with its models.
More breakout videos from this creator.
from openai import OpenAI client = OpenAI(api_key="sk-proj-Fk01GSnLM-TrZ8v0wUTC9O9VT response = client.chat.completions.create( model="gpt-5.4-mini", messages=[ {"role": "user", "content": "Explain Python to me."} ] ) print(response.choices[0].message.content) Core concepts **Variables**: store values python age = 25 **Lists**: store multiple items python fruits = ["apple", "banana", "cherry"] **Functions**: reusable blocks of code python def greet(): print("Hello!") **Classes**: a way to model objects and behavior Important note Python is often used in two main versions: **Python 3**: the current standard, recommended **Python 2**: is old and no longer supported If you want, I can also explain Python in one of these ways: **As a complete beginner** **Compared with another language like JavaScript or C++** **With practical examples** **As a roadmap for learning Python** **Web development**: building websites and web apps **Data analysis**: working with spreadsheets, data, and statistics **Automation**: writing scripts to do repetitive tasks **AI / machine learning**: a major language for modern AI work **General programming**: small tools, games, desktop apps, and more Why people like it **Simple syntax**: Python code often looks close to plain English **Large community**: lots of tutorials and help available **Many libraries**: ready-made tools for almost anything **Cross-platform**: works on Windows, Mac, and Linux A tiny example python print("Hello, world!") This tells Python to display: Hello, world! Basic idea of how it works Python runs your code top to bottom. You can store values in variables, make decisions with `if`, repeat actions with loops. We can build in six lines of code. But like this: we have to run it every time when we want to ask a message. This is not very handy. So, we replace the hard coded text with an input. We create an empty list called messages. While true: msg = input("You: ") if msg.lower() in ("exit", "quit"): break messages.append({"role": "user", "content": msg}) response = client.chat.completions.create( model="gpt-5.4-mini", messages=messages ) reply = response.choices[0].message.content messages.append({"role": "assistant", "content": reply }) print(f"Bot: {reply}\n") And that's it. Your own ChatGPT bot running locally in under thirty lines of Python.