, ,

Why Learn Python First (Python for Beginners, Part 1)

Why Python is the language to start with, how it turns your text into working output, where it fits in real work, and the indentation trap that catches almost every beginner in week one.

Python for Beginners · Part 1 of 20

Most first languages make you write ten lines of ceremony before a single word shows up on screen. Python does not. Here is a complete program that runs on its own:

python
print('Hello, world!')
output
Hello, world!

One line, and it works. That is most of the argument for starting with Python already made. The rest of this part fills in the picture: what Python is, how it turns your text into something the computer does, where it earns a place in real work, and one small rule that trips up nearly everyone in their first week.

Start hereThis series is for someone learning to code from zero: a recent graduate, a career switcher, or an IT person who keeps hearing that a little scripting would make the job lighter. No programming background is assumed. Every new word gets a plain definition the first time it shows up, and every sample here runs on current Python 3 exactly as printed.

What Python actually is

Python is a programming language. A programming language is a set of rules for writing instructions precisely enough that a computer can carry them out with no guessing. You write those instructions as plain text in a file whose name ends in .py, which is how everyone, and your editor, knows it holds Python.

The text you write is called source code. On its own it is just words. Something has to read your source code and act on it, and that something is the interpreter, a program already sitting on your machine, or one you install in Part 2. You hand your file to the interpreter, it reads your instructions from top to bottom, and it does what they say. Think of the interpreter as a very literal assistant that follows each line in order and never fills in what you left out.

One point saves confusion later. Python the language and the interpreter that runs it are two different things. The language is the set of rules. The interpreter is the actual program on your computer that obeys those rules, and the common one is called CPython. When people say they are installing Python, they mean installing that interpreter. You will see the name CPython in an interview answer further down, so it helps to have met it here.

How Python runs your code

When you type python3 hello.py at a terminal, the interpreter opens your file, reads the first line, does it, reads the next line, does it, and carries on to the end. There is no separate build step you run first. That is why you saw output the moment you typed one line. You change the file, you run it again, you see the result. That short loop between writing and seeing is the single biggest reason Python is comfortable to learn on.

hello.py your source file Python interpreter reads top to bottom Hello, world! output on screen

Your source file goes to the interpreter, which reads it in order and produces output.

Your first real program, line by line

One line is a nice trick, but real programs keep track of information and combine it. Here is a slightly bigger program. Save it in a file called greet.py and run it, or paste it line by line at the prompt.

greet.py
name = 'Ada'
greeting = 'Hello, ' + name + '!'
print(greeting)
print('Your name has', len(name), 'letters.')
output
Hello, Ada!
Your name has 3 letters.

Four short lines, and each one introduces an idea you will use in every program from here on.

The first line, name = ‘Ada’, creates a variable. A variable is a label for a piece of information so you can refer to it later by name. Here the label name points at the text Ada. Text wrapped in quotes is called a string, the word programmers use for a run of characters. The second line builds a new string by joining pieces with the + sign and labels the result greeting. Joining strings this way is called concatenation.

The third line uses print, which is a function: a named action you can run. You put a value in the parentheses and print shows it on screen. The fourth line calls print again and also uses len, another function that counts how many characters a string holds. The name Ada has three characters, so len(name) works out to 3.

print ( ‘Hello’ ) function name the string argument

A function call: the name, then the value you pass it inside parentheses.

Now break it on purpose, because the errors you cause deliberately are the ones you recognize later. Drop the quotes around the text:

python prompt
>>> print(Hello)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'Hello' is not defined

Read the last line first, always. It says NameError: name ‘Hello’ is not defined. Without quotes, Python assumed Hello was a variable, went looking for one by that name, found nothing, and stopped. The fix is to put the quotes back so Python treats it as a string rather than a name. A NameError almost always means you used a word Python expected to be defined somewhere and it was not.

Where Python fits, and where it does not

Python is a general language, so the honest question is not whether it can do a job but whether it is the sensible pick. The table compares it with two languages beginners are often told to learn instead.

For a beginnerPythonJavaC
Lines to print a message1about 5about 6
Declare variable typesNo, inferred for youYes, every timeYes, every time
Compile before runningNoYesYes
First week frictionLowMediumHigh
Common usesAutomation, data, web, AIEnterprise apps, AndroidOperating systems, embedded

Notice the pattern. Python asks for less up front: no type declarations, no compile step, fewer lines for the same result. That is exactly what you want while you are still learning what a program even is.

Lines of code to print one message 1 Python 1 JavaScript 5 Java 6 C

Approximate lines to print a single message. Fewer lines means less to get wrong while learning.

Here is the opinion, and it runs against advice you will hear: you do not need to start with C to really understand computers, and you should not avoid Python because someone told you it is slow. For a first language, the thing that matters most is how quickly you can write something that works, see it run, and build the habit. Python wins that on every count. Raw speed of the language matters later, and rarely as much as people claim.

Python is still not the right tool everywhere, and pretending otherwise would not help you. When you need tight control over memory or timing measured in microseconds, reach for something lower level. Operating system kernels, game engines, high frequency trading systems and embedded firmware are written in C, C plus plus, Rust or Go for good reasons. You will almost certainly not begin your career in those places, and by the time you do, one language you know well is solid preparation for the next.

The indentation rule that trips up beginners

Most languages group code with braces or brackets. Python groups code with indentation, meaning the blank space at the start of a line. Lines that belong together share the same left margin. This keeps Python clean to read, and it means a stray space is not a style problem, it is an error. Here is a file with one accidental space on the second line:

greet.py
print('Starting')
 print('done')

Run it and Python refuses:

terminal
  File "greet.py", line 2
    print('done')
    ^^^^^
IndentationError: unexpected indent

The message names the file and line, points at the offending line, and calls it an IndentationError: unexpected indent. Nothing was wrong with what the line said. It was simply pushed in from the margin for no reason. Delete the leading space so both lines start flush left, and it runs. Indentation only belongs inside blocks such as the bodies of if statements and loops, which arrive in Part 5.

Why this matters in your first jobOn a real team you will read far more code than you write, and consistent indentation is how both Python and your teammates see the structure of a program at a glance. Set your editor to insert four spaces when you press Tab, and never mix tabs and spaces in the same file. It is the cheapest habit that keeps you clear of a whole category of confusing errors before your first pull request.

A few commands come up constantly from the very first day. Keep them close.

CommandWhat it does
python3 –versionPrints the installed version, for example Python 3.14.6
python3Opens the interactive prompt where you type code one line at a time
python3 script.pyRuns the code saved in the file script.py
exit()Leaves the interactive prompt and returns to your shell
print(value)Shows the value on screen

The interactive prompt in that table, often called the REPL (short for read, evaluate, print, loop), is worth using early. It runs one line at a time and shows the result immediately, which makes it a fast way to test an idea before you commit it to a file.

Real interview questionFreshers get asked this constantly: is Python compiled or interpreted? A clean answer is that in day to day use you run Python source directly, so people call it interpreted. Underneath, the standard interpreter, CPython, first compiles your source into an intermediate form called bytecode and then executes that bytecode. So it does a bit of both, but there is no separate compile command you run by hand.
Try it yourselfCreate a file called day1.py. Store the name of your city in a variable, then print two lines: a sentence saying you are learning Python in that city, and a line reporting how many letters the city name has. Use print, the + sign for joining text, and len for the count. For a city named Pune your program should print exactly this:
expected output
I am learning Python in Pune.
Pune has 4 letters.
If your spacing or count is off, compare your file against the greet.py example above.

What a little Python already lets you do

Value comes fast, well before you finish this series. Here is a program of the kind you will write in your first weeks. It takes a line of text and reports how many words it holds. It uses one idea you have not met yet, split, which cuts a string into a list of pieces wherever there is a space.

words.py
sentence = 'python pays the rent'
words = sentence.split()
print('Word count:', len(words))
print('First word:', words[0])
output
Word count: 4
First word: python

The call sentence.split() hands back a list, which is Python holding several values in order. You met len already, and here it counts items in the list rather than characters in a string. The last line reaches for words[0], the first item, because Python starts counting positions at 0, not 1. Lists get a full part of their own later, so do not worry about the details yet.

What matters is the shape. Read something in, break it into parts, then count or pick out what you need. A script that scans a folder of log files and counts the lines with the word error in them is the same three steps with more text flowing through. With the small pieces from the next handful of parts you can rename hundreds of files at once, pull a single column out of a spreadsheet, check whether a website is reachable, or turn a messy export into a tidy report. None of that asks for a computer science degree. It asks for these basics put together in the right order.

Questions beginners actually ask

Do I need to be good at math? No. If you can handle everyday arithmetic you have enough to go a long way. Whole careers in web, automation and testing lean far more on clear thinking than on mathematics.

Python 2 or Python 3? Python 3, without exception. Python 2 reached the end of its life in 2020 and gets no more updates. The current line is Python 3.14, and everything you learn here targets Python 3.

Which editor should I use? Start with VS Code, or the small editor named IDLE that ships with Python itself. The choice matters much less than showing up to write code regularly, and you can switch tools later without losing anything.

How long until I can build something useful? With steady practice, a few weeks. A script that renames a folder full of files, or pulls numbers out of a spreadsheet, is well within reach once you finish the early parts of this series.

Is Python still worth learning now that AI can write code? Yes. Those tools produce code you still have to read, run, and fix when it is wrong, and they assume you understand the basics they build on. Knowing the language is what lets you tell good output from confident nonsense.

You now know what Python is, how it runs, where it belongs, and the one rule that causes most first week errors. Part 2 gets Python installed on your own machine and turns that single line into a file you run yourself. From Part 2 on we also build one small program together, a command line expense tracker, a little at a time, so by the end of the series you have a real project of your own to show. Bookmark the complete guide and follow along in order.

Python for Beginners · Part 1 of 20
Complete Guide  |  Next: Part 2

References

Python.org downloads and current release
What is new in Python 3.14 (official documentation)
Status of Python versions (Python developer guide)

About The Author


Discover more from Journal of Intelligent Infrastructure – By Dr Pranay Jha

Subscribe to get the latest posts sent to your email.

Leave a Reply

Your email address will not be published. Required fields are marked *

Architect’s Toolkit

About the Author

Dr. Pranay Jha is a Cloud and AI Consultant with 18+ years of experience in hybrid cloud, virtualization, and enterprise infrastructure transformation. He specializes in VMware technologies, multi-cloud strategy, and Generative AI solutions. He holds a PhD in Computer Applications with research focused on Cloud and AI, has published multiple research papers, and has been a VMware vExpert since 2016 and a VMUG Community Leader.

Discover more from Journal of Intelligent Infrastructure - By Dr Pranay Jha

Subscribe now to keep reading and get access to the full archive.

Continue reading