Skip to content

Python Basics: Values, Variables, print, Numbers and f-Strings (Runs in Your Browser)

NeedMyTools Academy

Sign in free to read the full lesson

Sign in or create a free account

Free forever. No card, no paywall.

Python is one of the easiest languages to read and one of the most useful to know: it runs data analysis, automation scripts, back ends and AI tools. This first lesson needs no installation. Each example below runs real Python 3.14 inside your browser through Pyodide, the standard Python interpreter compiled to WebAssembly, so you can change a line, press Run and see what Python prints. You will print text, numbers and Arabic, store values in variables, use the arithmetic operators, see why 0.1 + 0.2 is not exactly 0.3, and build clean output with f-strings, ending with a small VAT receipt.

Quick answer

In Python, print() shows values, and name = value stores a value in a variable with no type declaration. The basic types are str (text in quotes), int (whole numbers), float (decimals) and bool (True or False). Use + - * / for arithmetic, // for whole-number division, % for the remainder and ** for powers. Join text and values with an f-string such as f"{total:.2f} AED", and convert with int(), float() and str().

35 min read and practice · Content checked on 2 December 2026

In this lesson you will

  • Print text, numbers and Arabic and check a value’s type
  • Store values in variables and calculate with Python’s operators
  • Format output with f-strings and convert between text and numbers

Your first lines: print and the basic types

A Python program is a text file of statements that run from top to bottom. print() is the function you will use most at first: it shows whatever you give it, followed by a new line. Text, called a string, goes inside double or single quotes. Numbers do not. Arabic and any other language work as they are, because Python 3 strings are Unicode. Give print several values separated by commas and it puts a space between them, or whatever you pass as sep.

Every value has a type, and type() tells you which. You will meet four constantly: str for text, int for whole numbers such as 2026, float for numbers with a decimal point such as 19.99, and bool for True and False, which must start with a capital letter. The type decides what you can do with a value: you can multiply two numbers, but not two strings. Python also has no semicolons and no curly braces for blocks; the line ends the statement.

Try it: print, Arabic text and type()
Code
ResultUpdates as you type
Console
  1. Console messages, errors, form data and clicked links appear here.

Press Run: Python loads once (about 6 MB), then this printed seven lines, including مرحباً بك unchanged and the four types from <class 'str'> to <class 'bool'>. The last line used sep=" | " to print Dubai | Doha | Riyadh.

Sign in free to read the full lesson

You are reading the free preview. Create a free account (it takes one minute, no password) to unlock the rest of this lesson and track your progress.

Unlocks after sign-in:

  • 2 more sections with live code examples
  • Common mistakes to avoid
  • Hands-on coding exercise with automatic checks
  • Practice quiz and the graded lesson test
Sign in or create a free account

Free forever. No card, no paywall.

Questions people ask

Is the Python in these examples real Python?

Yes. It is CPython 3.14, the same interpreter you install from python.org, compiled to WebAssembly by the Pyodide project. A few things differ in a browser: there is no real file system or terminal, and input() is not available here.

Should I use single or double quotes for strings?

Both work the same. Pick one style and keep it; this course uses double quotes, as the Black formatter does. Switch when the text itself contains a quote: "Fatima's order" keeps the apostrophe safe inside double quotes.

How do I install Python on my own computer?

Download the installer from python.org for Windows or macOS and tick "Add python.exe to PATH" on Windows. Most Linux systems already include Python 3. Then run a file with python3 hello.py, or py hello.py on Windows.

What is the difference between Python and JavaScript for a beginner?

Both are good first languages. JavaScript is the language of web pages; Python is stronger for data, automation, scripting and AI. Python uses indentation instead of braces, which makes it very readable but strict about spaces.

Why does the first Run take a few seconds?

The browser downloads Python itself, about 6 MB, from the jsDelivr CDN the first time you press Run on a page, then keeps it in its cache. We do not load it until you ask, so lessons open fast on mobile data.

Sources

Facts in this lesson were checked against these official pages on 2 December 2026.

Code examples stay in English and run in a sandbox on your device. If you spot a mistake, tell us through the contact page.