Python syntax is the rules we follow when we write code in Python. It helps us communicate with
the computer and tell it
what to do.
The colon
:
is a special symbol that tells Python that something important is coming
next.
We use the colon before starting a for or while loop or
if/else
statements.
It's like saying, "Here comes a
block of code!"
Quotes are used to represent text in Python.
They always come in pairs.
We use quotes to tell the computer that something is a piece of text, like a message
or a name.
In print() statements, we
put
the text inside quotes to
tell
Python to show that message on the screen.
Brackets always come in pairs.
We use round brackets ()
in commands like print() or getting input().
For example:
print("Hello")
or
input("What's your name?")
Square brackets [] are used to define lists or arrays.
They help us keep things
organised, like putting objects
in a
box.
In Python, we often need to work with different types of data, such as numbers and text. To
make
our code
understand and handle these different types correctly, we use special functions or
operators.
str() function: When we want to convert a number into text (a string),
we use the
str() function. It helps us represent numbers as words or combine them
with other
text.
int() function/operator: On the other hand, if we have text (a
string) and we
want
to use it as a number for
calculations, we can convert it into a number using the int()
function/operator.
Indentation is like the way we organise our toys or books.
It helps the computer
understand which lines of
code belong together.
In Python, we use spaces or tabs to indent our code.
When we start a new block of code, like
inside a loop or a
function, we indent the code by adding spaces or tabs at the beginning of each line. It's
like
giving those lines a
special place.

We should set indentation:
In loops: When we have a loop, like a for loop or a while loop
In conditional statements: When we have an if statement or an else statement.
We shift code after using a colon : in loops and conditional statements