2-Minute Crash Course on Python — Specially For AI Professionals

Raja Gupta
4 min readJun 25, 2024

If you are learning AI or Generative AI, it’s good to have a basic understanding of Python. You don’t need to be python expert, but without knowing ABCs of Python, you may struggle to understand few AI concepts.

Having this in mind, I have prepared a quick 2-minute crash course on Python, specially for AI professionals.

Image generated using Microsoft Copilot

Target Readers

Anyone who wants to have a quick understanding of Python and learn basic Python programming.

Specially, if you are working on AI and Generative AI, this crash course can be super helpful.

Note: If you are new to AI and Generative AI, I strongly recommend you to go through the blog series Generative AI for Beginners.

It will only take 90 minutes of your time. No perquisites. You will get a crystal-clear idea on AI and generative AI.

What is Python?

Python is a popular programming language known for its readability and versatility. It’s used for web development, data analysis, machine learning, automation, and much more.

Why Learning Python is so Important for AI Professionals?

Python is probably the most important programming language used in AI. Here are some of the reasons behind it.

Ease of Learning and Use

Python has a simple and readable syntax, making it accessible even for beginners. This ease of use allows AI professionals to focus more on solving problems and less on writing complex code.

Extensive Libraries and Frameworks

Python has a rich ecosystem of libraries and frameworks that are specifically designed for AI and machine learning. Some of the most popular ones include:

TensorFlow

Developed by Google, it’s widely used for deep learning.

PyTorch

Developed by Facebook, it’s popular for research and production in deep learning.

scikit-learn

Open-source machine learning library, which provides simple and efficient tools for data mining and data analysis.

Keras

Open-source, neural networks API written in Python. It is designed to be user-friendly, modular, and extensible, making it easy for developers to create deep learning models.

NumPy

Library for numerical computing, designed to handle large, multi-dimensional, as well as a collection of mathematical functions.

Strong Community Support

Python has a large and active community of developers. This means that there is a wealth of tutorials, forums, and resources available to help you learn and troubleshoot issues.

Install Python

Go to python.org and download the latest version of Python.

Setup Integrated Development Environment (IDE) for Python

We can use several IDE to write python code such as VSCode, PyCharm, or Jupyter Notebook. We can even write code on notebook and run using python command.

Run your first Python Hello World in less than 1 minute

  1. Create a file in your local directory (anywhere in your laptop) with name hello-world.py
  2. Copy paste below code and save.
print("Hello, World!")

3. Run the command:

python hello-world.py

4. You will get an output as shown below

PIP

PIP is a package manager for Python packages. If you have Python version 3.4 or later, PIP is included by default.

PIP is used to install and manage software packages. These packages are collections of code written by others that you can use in your own projects to save time and add functionality. For example, if you need a library to help with data analysis or web development, you can easily install it using pip.

Python Package Index (PyPI)

The Python Package Index (PyPI) is a repository of software for the Python programming language. It’s available at https://pypi.org/

Python developers can upload and share their packages using this repository. When you use pip to install a package, it often fetches it from PyPI.

Jupyter Notebook

Jupyter Notebook is a tool in Python that allows you to write and run code, visualize results, and add explanations all in one place. It lets you write and run code in small chunks, making it easier to test and debug your code step-by-step.

We can use pip command to install Jupyter notebook.

Command to install the classic Jupyter Notebook:

pip install notebook

Command to run the notebook:

jupyter notebook

Basic Syntax

Printing to the Screen

The print function is used to display output.

print("Hello, World!")

Variables
Variables store data. You don’t need to declare the type explicitly.

name = "Alice"
age = 25
print(name, age)

Data Types
Common data types in Python include:
• Strings: Text data.
• Integers: Whole numbers.
• Floats: Decimal numbers.
• Booleans: True or False values.

text = "Hello"
number = 10
pi = 3.14
is_happy = True

Lists
Lists store multiple items in a single variable.

fruits = ["apple", "banana", "cherry"]
print(fruits)

Dictionaries
Dictionaries store data in key-value pairs.

person = {"name": "Alice", "age": 25}

print(person["name"])

Basic Arithmetic Operations

sum = 5 + 3
difference = 10–2
product = 4 * 2
quotient = 8 / 2

print(sum, difference, product, quotient)

Loops

for fruit in fruits:
print(fruit)

Conditionals
Use if, elif, and if to make decisions.

if age > 18:
print("Adult")
else:
print("Not an adult")

Functions
Functions are reusable blocks of code.

def greet(name):
return f"Hello, {name}!"
print(greet("Alice"))

Summary

Hopefully, this quick crash course will help you get basic understanding of Python. You are now equipped to do basic operations and programming in Python. As and when required, dive deep into individual topics.

Follow me for more such content on AI, SAP and beyond!

--

--

Raja Gupta

Author ◆ Blogger ◆ Solution Architect at SAP ◆ Demystifying Tech & Sharing Knowledge to Empower People