Programming · 9 min read · Updated

Python for Beginners: What to Learn in Your First Week

A day-by-day plan for your first week of Python: setup, variables, strings, conditions, loops, lists, dictionaries and functions, with a small project.

Python for beginners: notebook Pen
Photo: Negative Space via Stocksnap (CC0)

Python is often the first programming language people learn, and for good reason. The syntax is short and readable, the error messages are helpful, and the same language is used for automation scripts, data work, web back ends and teaching. But “learn Python” is a vague goal. Beginners open a 40-hour video course, watch for three days and then stall.

This guide to Python for beginners gives you something smaller and more concrete: a plan for your first seven days. Each day has one topic, a few lines of example code with the exact output, and a tiny task. Spend about an hour a day. By the end of the week you will have written a working program of your own, which is worth more than any number of videos watched.

Every topic below links to the matching lesson in our free Python track, where you will find longer explanations, quizzes and exercises.

Before you start: what you need

  • A laptop or desktop computer. Windows, macOS or Linux all work. A phone is fine for reading but not for practising.
  • Python 3, a recent version (3.12 or newer). Python 2 is long dead; ignore any tutorial that uses print "hello" without brackets.
  • A code editor. VS Code with Microsoft’s Python extension is a good choice, but Python’s own IDLE editor is fine for week one.
  • A notebook (paper or digital) where you write down errors you met and how you fixed them.

Day 1: Install Python and run your first program

On Windows, the official documentation now recommends the Python Install Manager, available from python.org or the Microsoft Store. After installing it, typing python in a terminal starts the latest version. On macOS, use the installer from python.org; on most Linux systems Python 3 is already installed as python3.

Create a file called hello.py, type the code below, save it and run it from the terminal with python hello.py (or python3 hello.py on macOS and Linux).

print("Vanakkam, Python!")
print("2 + 3 =", 2 + 3)
Output
Vanakkam, Python!
2 + 3 = 5

Also try the interactive shell (the >>> prompt you get by typing python alone). It is a calculator that understands code, and it is the fastest way to test a small idea. Read Python Introduction for the details.

Tip: Today’s task: print your name, your city and the result of 365 × 24 (hours in a year) on three separate lines.

Day 2: Variables, data types and f-strings

A variable is a name that points to a value. Python works out the type from the value, so you do not declare it. The four types you will meet first are int (whole numbers), float (decimals), str (text) and bool (True or False).

name = "Kavya"
city = "Puducherry"
age = 21
height_m = 1.62
is_student = True

print(f"{name} from {city} is {age} years old.")
print(type(age), type(height_m), type(is_student))
print(f"Next year {name} will be {age + 1}.")
Output
Kavya from Puducherry is 21 years old.
<class 'int'> <class 'float'> <class 'bool'>
Next year Kavya will be 22.

The f before the quotes makes an f-string: anything inside {} is evaluated and inserted. It is the modern, readable way to build text, so learn it from day one. See Python Syntax and Variables and Python Data Types.

Watch out: Python is case-sensitive and uses indentation as syntax. Name and name are different variables, and a stray space at the start of a line causes an IndentationError.

Day 3: Strings and operators

Text is everywhere: names, messages, file contents. Python strings come with many useful methods. Combine them with arithmetic operators and you can already write useful little scripts.

dish = "  masala dosa  "
clean = dish.strip()
print(clean.title())
print(clean.upper())
print(len(clean))
print(clean.replace("masala", "ghee roast"))

print(17 / 5)   # true division
print(17 // 5)  # floor division
print(17 % 5)   # remainder
print(2 ** 10)  # power
Output
Masala Dosa
MASALA DOSA
11
ghee roast dosa
3.4
3
2
1024

Notice that / always gives a float, while // gives the whole-number part. Remember also that strings are immutable: methods like upper() return a new string and leave the original unchanged. Practise with Python Strings and Python Operators.

Day 4: Conditions

Programs become interesting when they make decisions. Python uses if, elif and else, a colon at the end of each line, and indentation (four spaces is the convention) to mark the block.

marks = 78

if marks >= 90:
    grade = "A+"
elif marks >= 75:
    grade = "A"
elif marks >= 50:
    grade = "B"
else:
    grade = "Needs improvement"

print(f"Marks: {marks}, Grade: {grade}")
Output
Marks: 78, Grade: A

Python checks each condition from the top and stops at the first one that is true, so the order matters. Also learn and, or and not today. The lesson Python Conditions covers comparison chains and the shorter one-line form.

Day 5: Loops

Loops let the computer do repetitive work. A for loop goes through each item of a sequence; range() generates numbers for you. A while loop repeats as long as a condition stays true.

for n in range(1, 6):
    print(f"7 x {n} = {7 * n}")

savings = 0
month = 0
while savings < 5000:
    savings += 1200
    month += 1
print(f"Reached {savings} in {month} months")
Output
7 x 1 = 7
7 x 2 = 14
7 x 3 = 21
7 x 4 = 28
7 x 5 = 35
Reached 6000 in 5 months

Note that range(1, 6) stops before 6. Off-by-one mistakes like this are normal; print the values when unsure. Learn break and continue in Python Loops.

Day 6: Lists and dictionaries

Real data comes in groups. A list keeps items in order; a dictionary stores values under keys, like a small lookup table. Between them they cover most beginner needs.

cities = ["Chennai", "Madurai", "Coimbatore"]
cities.append("Puducherry")
print(cities)
print(cities[0], cities[-1])

prices = {"idli": 30, "vada": 25, "pongal": 50}
prices["coffee"] = 20
for item, price in prices.items():
    print(f"{item:<8} Rs {price}")
print("Total:", sum(prices.values()))
Output
['Chennai', 'Madurai', 'Coimbatore', 'Puducherry']
Chennai Puducherry
idli     Rs 30
vada     Rs 25
pongal   Rs 50
coffee   Rs 20
Total: 125

Indexes start at 0, and -1 means the last item. The :<8 inside the f-string pads the text to eight characters so the prices line up. Dictionaries keep insertion order, which is why coffee appears last. Go deeper with Lists and Tuples and Dictionaries and Sets.

Day 7: Functions and a mini project

A function packages a piece of logic under a name so you can reuse it. Use def, give the inputs (parameters) names, and return the result. Today, combine everything from the week into one small program: a bill calculator for a tiffin shop.

MENU = {"idli": 30, "dosa": 60, "pongal": 50, "coffee": 20}


def line_total(item: str, qty: int) -> int:
    return MENU[item] * qty


def print_bill(order: dict[str, int], gst_rate: float = 0.05) -> None:
    subtotal = 0
    for item, qty in order.items():
        amount = line_total(item, qty)
        subtotal += amount
        print(f"{item.title():<8} x{qty}  {amount:>5}")
    gst = round(subtotal * gst_rate, 2)
    print(f"{'Subtotal':<12}{subtotal:>6}")
    print(f"{'GST':<12}{gst:>6}")
    print(f"{'Total':<12}{subtotal + gst:>6}")


print_bill({"idli": 2, "dosa": 1, "coffee": 2})
Output
Idli     x2     60
Dosa     x1     60
Coffee   x2     40
Subtotal       160
GST            8.0
Total        168.0

The gst_rate parameter has a default value, so you can call the function without it. The type hints (: str, -> int) are optional; Python does not enforce them, but they make the code easier to read.

The Python Functions lesson explains parameters, return values and scope.

Tip: Extend the project: add a check so that an item not on the menu prints a friendly message instead of crashing with a KeyError. Hint: use if item in MENU.

How to read an error message

You will see many errors this week. That is normal and useful: reading them calmly is one of the most valuable habits in Python for beginners. Python prints a traceback; read it from the bottom up. The last line names the error type and gives a short message, and the lines above point to the file and line number.

ErrorUsual causeFix
SyntaxErrorMissing colon, bracket or quoteCheck the line shown and the one just above it
IndentationErrorMixed or missing indentationUse four spaces consistently; let your editor insert them
NameErrorTypo in a variable name, or used before it was assignedCheck spelling and case
TypeErrorMixing types, e.g. adding text to a numberConvert with str(), int() or use an f-string
KeyError / IndexErrorKey not in the dictionary, or index past the end of a listCheck with in or len() first

Handling errors on purpose with try and except comes in Modules and Errors, which is a good topic for week two.

What to skip in week one

Many courses on Python for beginners try to cover everything at once, and beginners lose time on things that can wait. For now, skip these without guilt:

  • Classes and object-oriented programming. Useful later; confusing before you are comfortable with functions.
  • Frameworks such as Django or Flask, and data libraries such as pandas. They assume you already know the basics above.
  • Virtual environments and package management. You will need them as soon as you install third-party packages, but not for this week’s code.
  • Arguments online about which editor or which Python version is “best”. Any recent Python 3 and any decent editor will do.

Week two and beyond

After the first week, a sensible next step is to work with files (Python Files), then modules and error handling, then a slightly larger project: a to-do list saved to a text file, a marks report for a class, or a script that renames photos in a folder. Small, finished projects teach more than long tutorials.

If you are also interested in web development, read Python vs JavaScript to see how the two languages compare, and save your practice code with Git from day one using our Git basics guide.

Python for beginners: first-week checklist

  • Python 3 installed, and you can run a .py file from the terminal.
  • You can create variables and print them with f-strings.
  • You know the difference between /, // and %.
  • You can write an if / elif / else block with correct indentation.
  • You can loop over a list and over range().
  • You can add, read and loop over items in a dictionary.
  • You have written at least two functions of your own and one small program that uses them.

Frequently asked questions

Can I learn Python in one week?

You can learn the core basics in a week: variables, strings, conditions, loops, lists, dictionaries and functions. Becoming comfortable enough to build real projects takes longer and comes from regular practice on small programs.

Which Python version should a beginner install?

Install a current Python 3 release from python.org (3.12 or newer). On Windows, the official docs recommend the Python Install Manager. Avoid Python 2, which is no longer supported.

Do I need to be good at maths to learn Python?

No. Everyday programming needs basic arithmetic and logical thinking. Advanced maths matters only for specialised areas such as machine learning or scientific computing.

Which editor is best for learning Python?

Python’s built-in IDLE is enough for the first week. VS Code with Microsoft’s Python extension is a popular next step because it adds autocomplete, error highlighting and an integrated terminal.

What should I learn after the Python basics?

Learn file handling, modules and error handling with try and except, then build two or three small projects. After that, choose a direction such as web back ends, automation or data analysis and learn the tools for that area.

Further reading

Keep reading

All articles