The Beginner’s Guide to Learning Python in 3 days — Day 2: Basic Syntax

Jalil Satria Wibowo
3 min readDec 17, 2022

--

Python is a high-level, interpreted programming language known for its simplicity and ease of use. It uses a syntax that is simple and easy to read, making it a good language for beginners to learn.

In Python, indentation is used to denote blocks of code, instead of using curly braces like in many other languages. For example, the following code shows a simple if-statement in Python:

print("Hello Mom")
Result:

Hello Mom

Basic Syntax

All the basic syntax of a programming language consists of:

1. Sequential: sequential steps

2. Branching: jump step if conditions are met

3. Looping: repeating the same step many times as long/until the condition is met

In most programming languages, the basic syntax includes the use of statements, expressions, and operators to specify a set of instructions for the computer to perform. These instructions can be used to perform a wide variety of tasks, such as performing calculations, making decisions, and repeating actions.

Sequencing

One of the fundamental concepts in programming is sequencing, which refers to the order in which instructions are executed. In most programming languages, instructions are executed in the order in which they appear in the code, from top to bottom.

print('Mom said, "Please take the Packages"')
print('Her son said,"Oke, Any else?"')
print('Mom said, "Hmmm and buy 1 bottle of soda"')
Result :Mom said, "Please take the Packages"
Her son said,"Oke, Any else?"
Mom said, "Hmmm and buy 1 bottle of soda"

Branching

Another important concept in programming is branching, which allows the program to make decisions based on certain conditions. This is typically achieved using conditional statements, such as “if-then” statements, which allow the program to execute different instructions depending on whether a particular condition is true or false.

The_number_of_pen = 175

print(f"The number of milk bottles is {The_number_of_milk_bottles} bottles ")

if The_number_of_milk_bottles > 0:
print("Her son buy 10 bottles of milk")
Result:

Her son buy 10 bottles of milk

Looping

Looping is another important concept in programming, which allows the program to repeat a set of instructions for a specified number of times or until a certain condition is met. This is typically achieved using looping constructs, such as “for” and “while” loops, which allow the program to execute a block of code multiple times.

The_number_of_books = 5

print('Mom said, "Please, read all your books"')

for The_number_of_books_read in range(1, The_number_of_books+1):
print(f"The order of reading book is {The_number_of_books_read}")
Result :

Mom said, “Please, read all your books”
The order of reading book is 1
The order of reading book is 2
The order of reading book is 3
The order of reading book is 4
The order of reading book is 5

Overall, the basic syntax of a programming language typically includes the use of sequencing, branching, and looping to specify a set of instructions for the computer to perform. These concepts form the foundation of most programming languages and are essential for creating effective and efficient programs.

Want to learn new skills and improve your life? Follow me, I will to help you with practical tips and advice regarding the study case

Let’s start our journey!

--

--

Jalil Satria Wibowo

Data Analyst Enthusiastic | Share lessons from the world of data