# Nakafa Framework: LLM URL: /en/subject/university/bachelor/ai-ds/ai-programming/python-step-1 Source: https://raw.githubusercontent.com/nakafaai/nakafa.com/refs/heads/main/packages/contents/subject/university/bachelor/ai-ds/ai-programming/python-step-1/en.mdx Output docs content for large language models. --- export const metadata = { title: "First Steps in Python", description: "Start your Python journey with interactive mode, scripts, and Jupyter. Build your first programs with variables, input/output, and practical exercises.", authors: [{ name: "Nabil Akbarazzima Fatih" }], date: "07/26/2025", subject: "AI Programming", }; ## Introduction to Python Python is a very popular and easy-to-learn programming language. Python is designed with a philosophy that prioritizes code readability, making it suitable for beginners who are new to programming. Why is Python the favorite choice of many programmers? Python has syntax similar to everyday English, making it easy to understand. Imagine reading a recipe written in clear and easy-to-follow language. Additionally, Python is very powerful for various purposes, from web development, data analysis, machine learning, to artificial intelligence. For more complete and in-depth information about Python, you can visit the [official Python documentation](https://docs.python.org). This documentation serves as the main reference source that is always updated with the latest Python features. ## Hello World Program The tradition in learning programming is to create the first program that displays the text "Hello World!". This is a simple way to ensure Python is installed correctly and you're ready for coding. The `print()` command is a built-in Python function used to display text or data to the screen. Whatever you write inside the parentheses will be displayed as output. ## Three Ways to Run Python Programs There are three main ways to run Python code, each with different uses depending on your needs. ### Interactive Mode Interactive mode allows you to write and run Python code directly in the terminal. This is very useful for testing simple code or quick experiments. Here's how to use interactive mode. First open a terminal or command prompt, then type `python` or `python3` and press Enter. You'll see the `>>>` prompt indicating Python is ready to receive commands. Next, write Python code and press Enter to execute it. >> print("Hello World!") Hello World! >>> 2 + 3 5 >>> name = "Alice" >>> print(f"Hello, {name}!") Hello, Alice! >>>` }]} /> ### Script Mode Script mode is a way to run saved Python files. This is suitable for more complex programs or programs you want to save for repeated use. The steps to run Python scripts are quite simple. First create a file with `.py` extension using a text editor, then write Python code inside the file and save it. After that, open a terminal and navigate to the folder where the file is saved, then run it with the command `python filename.py`. To run the file above: ### Jupyter Lab and Notebooks Jupyter is an interactive environment very popular for data science and learning. Imagine Jupyter like a digital notebook that can run code. Jupyter allows you to write code, see results immediately, and add explanations in one document. Jupyter has many advantages. You can run code per cell or section, output results are immediately visible below the code, you can add text explanations, images, and graphs, and it's ideal for experiments, data analysis, and learning. Using Jupyter is quite easy. First install Jupyter via pip: Second, run Jupyter Lab: Third, create a new notebook with `.ipynb` extension and write code in cells, then press Shift+Enter to execute. Example usage in Jupyter: ## Basic Python Syntax Let's learn some basic Python concepts that you'll use frequently. ### Variables and Data Types Python has several basic data types you need to understand. Variables in Python are like boxes that can store various types of data, and you can give labels or names to those boxes. print(type(age)) # print(type(height)) # print(type(is_student)) # print(type(fruits)) # print(type(person)) # ` }]} /> ### Input and Output User interaction is an important part of programming. Like a conversation, your program can ask users questions and provide answers or information. ### Basic Mathematical Operations Python supports various mathematical operations: ## Practical Exercises Let's try some simple exercises to practice what we've learned: ### Simple Calculator ### Temperature Conversion 100: print("This temperature is above water boiling point!")` }]} /> ### Student Profile