Search

Exploring Python(Windows)

This is for the documents leaving history for studying python referred to the book called “Do it 점프 투 파이썬
 Disclaimer
This post is a personal study note created while learning the topic discussed. Some information may be inaccurate or incomplete. If you notice any errors or have suggestions, I’d sincerely appreciate your feedback.
In this post, let's take a quick hands-on look at Python. Instead of starting with complex theories, we'll write a few simple pieces of code to get a feel for what Python is like.
First, open the Start menu and search for Python 3.13. When you see the app, go ahead and run it.
(It doesn't have to be version 3.13, just find the version of Python you installed.) You can simply search for "python" as well.)
Then this is the screen you will watch.
Python 3.13.5 (tags/v3.13.5:6cb20a2, Jun 11 2025, 16:15:46) [MSC v.1943 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.
Bash
복사
Python is called an interpreted language because it runs code line by line, immediately showing the result for each command.
This input-output cycle repeats continuously, allowing you to interact with the language in real time.
The window you see is called the Python interactive interpreter.
An interpreter is an environment that reads and executes code as you type it, without needing to compile the entire program in advance.
This interactive interpreter is also known as the Python shell. In the shell, you can write a command and see the result instantly, making it ideal for learning, testing, and experimentation.
The three angle brackets (>>>) you see are called the prompt, which is where you enter your commands.
>>> 1 + 1 2 >>>
Python
복사
When you enter the command 1 + 1, you'll immediately see the output 2. This input-output interaction feels like a conversation, which is why it's called an interactive interpreter.
To exit the interactive interpreter, press [Ctrl+Z] followed by [Enter] (on Unix-based systems, use [Ctrl+D]). Alternatively, you can exit by using the built-in functions quit() or exit().
>>> quit()
Bash
복사
>>> exit()
Bash
복사
You can also exit using the sys module, but for now, just keep in mind that such a method exists, we'll learn more about modules later.
>>> import sys >>> sys.exit()
Bash
복사
So far, we’ve done a simple exercise on how to enter commands and check the results.
Now, we’ll take a look at some basic examples in Python. Don’t worry if you don’t fully understand the code, it’s completely normal since we haven’t learned everything yet.
Just take a light look at it without any pressure.

Arithmetic operations

Basic arithmetic operations can be performed using the symbols +, -, *, and /, just like we do with a calculator.
>>> 1 + 2 3 >>> 3 / 2.4 1.25 >>> 3 * 9 27
Bash
복사
I'm not sure if a typical calculator includes these symbols, but in Python, there are two symbols used for division. The / symbol is used to get the quotient after division, as we saw earlier. To get the remainder after division, you use the % symbol.
>>> 5 % 2 1
Bash
복사

Assigning numbers to variables and performing calculations

>>> a = 1 >>> b = 2 >>> a + b 3
Bash
복사
What is variable?!
In my opinion, the concept of variables in computers is not much different from that in mathematics. A variable can be defined as a memory space used to store data. To make an analogy with everyday life, a variable is like a box for storing items. Just as we can take something out of the box and replace it with something else at any time, we can change the value stored in a variable whenever we want.
In Python, when you assign a value to a variable, an object suitable for that value is automatically created, and the variable refers to that object. Thanks to this, programmers don’t need to explicitly specify memory size or data types, allowing flexible use without wasting space.
On the other hand, in most statically typed languages like C or Java, you must specify the data type when declaring a variable, and the memory size allocated depends on that type. For example, just as it would be inefficient to store a single piece of chocolate in a refrigerator-sized box, in these languages you need to carefully choose variable types to use memory efficiently.
To sum up, Python does not require you to specify a type when declaring a variable; the type and memory size are automatically determined when a value is assigned. In contrast, most other languages require explicit type declarations, which leads to fixed memory sizes and more detailed management.

Conditional statement if

In programming, conditional statements are used very frequently and play a crucial role.
Even something as simple as a login feature requires checking whether the user’s entered ID and password are correct.
So, we need to write code that says, “If the entered ID and password are correct,” and this is exactly when we use a conditional statement.
>>> a = 3 >>> if a > 1: ... print("a is greater than 1.") ... a is greater than 1.
Bash
복사
The example above means that if a is greater than 1, the sentence "a is greater than 1." will be printed. Since a is 3, which is greater than 1, the message "a is greater than 1." will be displayed.
In the interpreter window, the ... that appears instead of the prompt (>>>) indicates that the current line of code has not finished and is still being continued.
After writing if a > 1:, the next line must be indented using either four spaces or the [Tab] key.
Then you can write print("a is greater than 1."). The rules of indentation will be explained in more detail in Chapter 03: Control Statements. The same indentation rule applies to the upcoming for and while loop examples as well.

Loop statement for

Let’s say you need to write a small and simple program that prints the numbers from 1 to 100. If you haven’t learned about loops yet, you’d probably write the code like this…
print(1) print(2) print(3) print(4) print(5) . . . print(98) print(99) print(100)
Python
복사
What a painful task this would be... If you were told to write code that prints numbers from 1 to 100,000 at work, you'd definitely be in for a long night of overtime.
That's why we have the loop that will save you from working late... the for loop!
>>> for i in range(1,100001): ... print(i) ... 1 2 3 4 5 . . . 100000
Bash
복사
In the example above, i is the variable that gets assigned a new value each time the loop runs. In other words, as the loop iterates, i becomes 1, 2, 3, 4, ... all the way up to 100000.
The range(start, end) function defines the range over which the loop should run. You may notice in the example code that it says 100001—this is because the end value is not included in the range. So if you want the loop to go up to 100000, you need to set the end value to 100000 + 1, which is 100001.
The range() function can also be used with a step value like this: range(start, step, end). However, since this post is only giving a simple overview, we’ll cover that in more detail in a future post focused on loops.

Loop statement while

Among loops, besides the for loop, there is also the while loop. Actually, when you want to repeat code, either one can be used depending on the situation. Personally, I decide whether to use a for loop or a while loop based on whether I know the exact range of repetition or do not know it.
So, when do you know the exact range, and when don’t you? As in the example above, you know the exact range when there is a clear boundary, like “print numbers from 1 to 100.” On the other hand, you don’t know the exact range when you have to wait for a user’s input or some other condition that cannot be predetermined.
# Example that repeatedly asks for user input until the word "exit" is entered user_input = "" while user_input != "exit": user_input = input("Please enter something (type 'exit' to quit): ") print(f"You entered: {user_input}") print("Program terminated.")
Python
복사

function

A function is a way to group specific code into a single feature. You might not fully understand what that means yet.
When writing code, there are often situations where you need to write the same code repeatedly.
Let’s understand this by looking at an example.
We need to write code that combines a name with the phrase "Hello! Nice to meet you." But there are three people we need to greet. John, Jain, and Doe.
So, we would probably write the code like this…
print("Hello, John! nice to meet you") print("Hello, Jain! nice to meet you") print("Hello, Doe! nice to meet you")
Python
복사
Ah… isn’t it already annoying? The code looks simple now because it’s very short, but if you had to write 1,000 lines of code repeatedly, you’d have to write those 1,000 lines every time you use that functionality.
That would be truly dreadful, wouldn’t it?
That’s why programmers need to be efficient… In other words, we bundle repetitive code into a function so that we can reuse it easily.
def greet(name): print("Hello, " + name + "! nice to meet you") greet("John") greet("Jain") greet("Doe")
Python
복사
By bundling repetitive code into a function called greet(), you can simply call the greet() function whenever you want to use that functionality later!