Welcome to lesson one of a complete Python course. This series takes you from a blank screen to real projects in sixteen parts, and it assumes nothing: not a computer science degree, not another language, not even a vague memory of school math. Each lesson is a self-contained class with one job, and the lessons stack. By the end of the track you will have written object-oriented programs, processed real data files, tested your code like a professional, trained a machine learning model, built a small neural network, and made your first call to a large language model. That sounds like a lot from where you are sitting right now, and that is exactly why the series moves one honest step at a time.
Here is how to get the most out of every part. Read the lesson once, slowly. Run every code block in the embedded playground, which executes real Python in your browser with nothing to install. Answer the checkpoint quizzes before moving on, because they catch the misunderstandings that quietly compound. Then practice the same topic in the free Learn Python Android app, which mirrors this syllabus with lessons, quizzes, and an offline playground, so the bus ride home becomes revision time. The card at the end of each lesson takes you straight to it.
What you will learn in Part 1
- What Python is, where it is used, and why it is the right first language
- How to install Python and run your very first script
- How print, comments, and the interactive prompt work
- What variables really are and how Python names values
- The core data types: integers, floats, strings, booleans, and None
- How to read input from a user and convert between types
Info
Who this is for
Complete beginners. If you have never written a line of code, you are exactly the reader this lesson was written for. If you already know another language, skim the early sections and slow down at dynamic typing and f-strings, which are where Python differs most.
1. Why Python, and why it is a great first language
Python is a general-purpose programming language created by Guido van Rossum and first released in 1991. Three decades later it sits at or near the top of every language popularity index, and not by accident. Python reads almost like English, which means the energy you spend as a beginner goes into learning programming ideas rather than fighting punctuation. The same language then scales with you: the syntax you learn this week is the syntax used to build YouTube-scale web services, automate boring office work, analyze scientific data, and train the AI models behind modern chatbots.
That last point matters for your motivation. Many languages are great for one niche. Python is the default language of data science, machine learning, and AI, a strong choice for web backends, and the standard tool for automation and scripting. Learning it is not a detour before the real thing; for most of the modern computing landscape, it is the real thing. The final three parts of this series walk you into scikit-learn, TensorFlow, and large language models using nothing but the Python you will build up along the way.
Python also has a stated philosophy, and you can read it later by typing import this into the interactive prompt. The lines that matter most for you now are simple ones: beautiful is better than ugly, readability counts, and there should be one obvious way to do it. Python enforces readability in an unusual way, by making indentation part of the grammar. Where other languages use curly braces to group code and indent only by convention, Python makes the indentation itself meaningful. You will meet this properly in Part 2; for now just know that the clean, aligned look of Python code is not a style choice, it is the language.
2. Installing Python and running your first program
You need two things: the Python interpreter, which is the program that runs your code, and a text editor to write code in. On Windows, download the installer from python.org and tick the box that says Add python.exe to PATH before clicking install; that single checkbox saves more beginner pain than anything else on the page. On macOS, the python.org installer or Homebrew both work. On most Linux distributions Python is already installed. Any version from 3.12 upward is perfect for this series. For an editor, Visual Studio Code is free, popular, and has an excellent Python extension; but honestly, any plain text editor works for week one.
From nothing to a running script in five steps
Download the latest 3.x installer for your system. On Windows, tick "Add python.exe to PATH" before installing. On macOS and Linux, the defaults are fine.
# After installing, open a terminal and check: python3 --version # Windows users may type: python --version # Expected output looks like: Python 3.14.0
If the version prints, Python is installed and reachable. If the command is not found, the PATH checkbox was missed; reinstalling with it ticked is the fastest fix.
python3 --version Python 3.14.0
Make a folder for this course, create a file named hello.py inside it, and type this single line. Type it rather than pasting; muscle memory is part of learning.
print("Hello, world!")
In the terminal, move into your folder with cd, then hand the file to the interpreter. The text appears immediately. That is a complete Python program.
cd path/to/your/folder python3 hello.py Hello, world!
Running python3 with no file opens an interactive session where each line runs as you press Enter. It is a calculator, a scratchpad, and the fastest way to test an idea. Type exit() to leave.
python3
>>> 2 + 3
5
>>> print("Hi from the REPL")
Hi from the REPL
>>> exit()
Take a second to appreciate what just happened when you ran the file. The python3 command started the interpreter, the interpreter opened hello.py, read it top to bottom, and executed each statement in order. There was no compile button, no project setup, no build step. This direct edit-and-run loop is one of the reasons Python is so pleasant to learn: the distance between an idea and seeing its result is a few seconds.
3. print, comments, and the habit of experimenting
The print function writes text to the screen, and it is more flexible than the single argument you used above. You can give it several values separated by commas and it prints them with spaces in between. You can change that separator with sep, and you can change what it puts at the end of the line with end. None of this is exam material; it is here so the code in later lessons never looks mysterious.
print("Hello, world!")
print("The answer is", 42)
print("2026", "06", "13", sep="-")
print("Loading", end="...")
print("done")
# Output:
# Hello, world!
# The answer is 42
# 2026-06-13
# Loading...done
The lines starting with a hash sign are comments. Python ignores everything from the # to the end of the line, which makes comments the place to explain why code does what it does. As a beginner, write more comments than feels necessary; explaining a line to an imaginary reader is the cheapest way to find out whether you actually understand it. You will notice the code in this series keeps comments short and purposeful, and that is the habit worth copying.
4. Variables: names for values
A variable is a name attached to a value. You create one with a single equals sign, which in programming means assignment, not mathematical equality. There is no separate declaration step and no type announcement; the moment you assign, the variable exists. You can later assign a new value to the same name, and the old value is simply forgotten. This will feel obvious within a week, but say it precisely once: the name points at the value, and assignment changes what the name points at.
age = 25
name = "Amina"
height_m = 1.68
is_student = True
age = age + 1 # rebinding: age now points at 26
print(name, "is", age, "years old")
# Amina is 26 years old
Names follow a few hard rules and one strong convention. A name may contain letters, digits, and underscores, may not start with a digit, and may not be one of Python's reserved keywords such as if, for, or class. Names are case sensitive, so Age and age are different variables, which is a classic source of beginner bugs. The convention is snake_case: lowercase words joined by underscores, like monthly_income or items_sold. Choose names that say what the value means; total_price beats tp every single time, and your future self is the person you are being kind to.
Checkpoint
Which of these is a valid Python variable name?
5. The core data types
Every value in Python has a type, and four types carry most beginner programs. Integers (int) are whole numbers of any size; Python handles numbers with hundreds of digits natively, which surprises people coming from other languages. Floats (float) are numbers with a decimal point, stored in the standard binary format used by virtually all languages, which is why 0.1 + 0.2 prints as 0.30000000000000004. That is not a Python bug, it is how computers represent decimals, and Part 12 of the app's math lessons digs deeper if you are curious.
Strings (str) are text, written between single or double quotes; both are fine, just be consistent. Booleans (bool) are the two truth values True and False, capitalized exactly like that, and they are what comparisons produce: 5 > 3 evaluates to True. Finally there is None, a special value meaning absence of a value, which you will mostly meet as the return value of functions that do not return anything. You can ask any value its type with the type function, and as a beginner you should, often, because half of all confusing errors are really type confusions.
population = 8_100_000_000 # underscores make big numbers readable
pi = 3.14159
city = "Colombo"
sunny = True
nothing = None
print(type(population)) # <class 'int'>
print(type(pi)) # <class 'float'>
print(type(city)) # <class 'str'>
print(type(sunny)) # <class 'bool'>
print(type(nothing)) # <class 'NoneType'>
print(7 / 2) # 3.5 true division always gives a float
print(7 // 2) # 3 floor division keeps integers
print(7 % 2) # 1 remainder (modulo)
print(2 ** 10) # 1024 exponentiation
Python is dynamically typed, which means the type lives with the value, not with the variable name. The same name can point at an integer now and a string a minute later. This makes the language quick to write and forgiving to learn, and it also means the discipline of keeping types straight lives in your head rather than in the compiler. Later in the series, Part 10 shows how type hints let you write the types down anyway, getting many of the benefits of strict languages without losing Python's ease. For now, just remember that type() is your friend whenever a value behaves strangely.
6. Strings and f-strings
You will format strings constantly, and modern Python has one clearly best way to do it: the f-string. Put the letter f before the opening quote, and anything inside curly braces is evaluated as Python and inserted into the text. You can put variables there, expressions, even format specifications that control decimal places and padding. Older tutorials show .format() calls and percent signs; you should be able to read those, but write f-strings.
name = "Amina"
score = 17
total = 20
print(f"{name} scored {score} out of {total}")
print(f"That is {score / total:.1%}") # percentage, 1 decimal
print(f"Next year she will be {25 + 1}") # any expression works
price = 1499.5
print(f"Price: Rs. {price:,.2f}") # thousands separator, 2 decimals
# Amina scored 17 out of 20
# That is 85.0%
# Next year she will be 26
# Price: Rs. 1,499.50
Checkpoint
What does print(f"{10 / 4:.1f}") output?
7. Reading input and converting types
Programs get interesting when they react to the user. The input function pauses, lets the user type a line, and hands that line back to you. The catch every beginner hits in week one: input always returns a string, even when the user types a number. If you want to do arithmetic with it, you must convert it with int() or float() first. Converting a string that does not look like a number raises an error called ValueError; Part 7 teaches you how to handle that gracefully, and until then we will simply trust the user.
Time to put the whole lesson together. The playground below is live: press Run and real Python executes in your browser. Because the playground cannot pause for keyboard input, we simulate input by assigning values directly, which is also exactly how you will test programs later in the series. Change the values, press Run again, and watch everything react. Breaking the code on purpose, then reading the error message, is some of the highest-value practice available to you this week.
If you changed birth_year to "2001" you saw a TypeError complaining that it cannot subtract a string from an integer. Read that message again slowly. Python errors name the exact problem and the exact line, and learning to read them calmly instead of panicking is a genuine superpower. Every professional you admire reads error messages for a living.
8. Practice and common stumbles
Before the recap, two pieces of homework. First, in the playground above, build a temperature converter: store a Celsius value in a variable and print it in Fahrenheit using the formula fahrenheit = celsius * 9 / 5 + 32, formatted to one decimal place with an f-string. Second, install Python on your own machine if you have not yet, and get hello.py running in a real terminal, because the muscle memory of the edit-and-run loop matters as much as any concept on this page. The same exercises, with more variations, are waiting in the Basics lesson of the Learn Python app.
! Common mistakes to avoid
-
✕Typing print("age") and wondering why it shows the word age instead of the number.
✓Quotes mean literal text. To show the value of a variable, leave the quotes off (print(age)) or use an f-string (print(f"{age}")).
-
✕Using = when you mean to compare two values.
✓A single = assigns. Comparison uses double equals, ==, which you will use heavily from Part 2 onward.
-
✕Doing math on input() results without converting them first.
✓input always returns a string. Wrap it: age = int(input("Age: ")). Strings and numbers never mix silently in Python.
-
✕Mixing up Age, age, and AGE and getting NameError.
✓Python names are case sensitive. Stick to snake_case everywhere and the problem disappears.
? Frequently asked questions
Do I need a powerful computer to learn Python? +
No. Python runs comfortably on modest laptops, and every example in this series also runs in the in-page playground, which needs only a browser. The heavier lessons near the end, like deep learning, offer free cloud options when your machine is not enough.
Python 2 or Python 3? +
Python 3, always. Python 2 reached end of life in 2020 and exists only in legacy systems. Everything in this series targets modern Python 3.12 and newer.
Should I memorize the syntax in this lesson? +
No. Memorization happens by use, not by effort. Run the examples, do the two exercises, take the quizzes in the app, and the syntax will be in your fingers by Part 3 without you noticing.
How long until I can build something real? +
Sooner than you think. By Part 5 you can write genuinely useful scripts, by Part 8 you can automate file work, and Part 13 onward has you doing the kind of data and AI work people get hired for. The only requirement is not skipping parts.
9. Recap and what comes next
You installed Python, ran a script, met the interactive prompt, and learned the atoms of the language: print and comments, variables and assignment, the core types int, float, str, bool, and None, f-strings for formatting, and input with type conversion. Everything else in Python is built from these atoms plus two ideas you meet next: making decisions and repeating work.
In Part 2, Python operators and decision making, your programs grow a brain: comparisons, boolean logic, if, elif, and else, and the modern match statement. You can browse the full sixteen-part syllabus on the series hub at any time, and every lesson in this track has a matching topic in the Learn Python app below, so your phone becomes a pocket classroom.
Pro tip
Open the interactive prompt right now and spend five unstructured minutes: do some arithmetic, make a variable, print an f-string, cause an error on purpose. Five playful minutes a day beats a two-hour cram on Sunday, every week of this course.
Practice on the go
Learn Python, the free Android app
Every topic in this series lives in the app too: bite-size lessons, runnable examples, quizzes, mini projects, and an offline Python playground that runs on your phone.
Comments
0No comments yet. Be the first to share your thoughts.