Skip to main content

Command Palette

Search for a command to run...

Learn Python Basics: Start Building Simple Programs Easily

Updated
โ€ข3 min read
M

Hello World! ๐ŸŒ•

Hi, my name is Fariz and I am a backend engineer. I have 2 years of experience in web application development, with a primary focus on the backend. I really enjoy this work because I enjoy finding solutions to problems related to performance, scalability, and application security.

I also have skills in a few programming languages, such as Golang, and am comfortable using frameworks like Gin. In addition, I have a good understanding of RESTful API design principles and a good understanding of web application architecture.

On this blog, I will share my knowledge and experience on web application development, particularly in the backend. I hope the information I share is useful to readers who want to learn more about programming and web application development

Python is a popular and widely used programming language in various fields such as data science, web development, and application development. It is easy to learn due to its simple syntax and understandable nature.

Here are some of the basics of Python that you need to know:

Variables: A variable is a place used to store data in a program. You can use the equals sign (=) to assign a value to a variable. Example:

x = 10
y = "Hello, World!"

Data Types: Python has several basic data types such as integer, float, string, and boolean. An integer is a whole number, a float is a decimal number, a string is a collection of characters, and a boolean is a true or false value. Example:

a = 10 # integer
b = 10.5 # float
c = "Hello" # string
d = True # boolean

Operators: Python provides several operators for performing mathematical operations such as addition (+), subtraction (-), multiplication (*), and division (/). Example:

x = 10
y = 5
z = x + y # z = 15

Conditional Statements: A conditional statement is a mechanism used to execute different code depending on the result of a conditional. Python provides two conditional statements, if and if-else. Example:

x = 10
if x > 5:
print("x is greater than 5")

Loops: A loop is a mechanism used to repeat the same code several times. Python provides two types of loops, for and while. Example:

for i in range(5):
   print(i)

Functions: A function is a block of code that can be reused within a program. You can create your own functions or use built-in Python functions. Example:

def greet(name):
print("Hello, " + name)

greet("John")

Those are some of the basics of Python that you need to know. With this knowledge, you can start learning Python and easily create simple programs.

Here is an example of a simple program using Python:

Print "Hello, World!"
print("Hello, World!")

# Assign values to variables

x = 10
y = 20

# Add two variables

z = x + y

# Print the result of the addition
print(z)

Request input from the user

name = input("What is your name? ")

# Print a message using the user's input
print("Hello, " + name + "!")

Use a conditional statement

x = 10
if x > 5:
    print("x is greater than 5")
else:
    print("x is less than or equal to 5")

Use a loop

for i in range(5):
print(i)

Create a function

def greet(name):
print("Hello, " + name + "!")

# Use the created function
greet("John")

The program prints "Hello, World!", assigns values to two variables, adds the two variables, requests input from the user, uses a conditional statement and a loop, and creates and uses a function. These are some of the basics of Python that you can learn to create simple programs.

Support me at Buy Me Coffe and Buy Me Ko-Fi

A

You need to add spaces after for, if... statements in your code examples. I just made a Python tutorial for a ML course in Spanish. It is in Colab and should be easy to translate: https://colab.research.google.com/drive/1uoxgduAnH3e4Pz0YHLAyMnw2Cpilqqpy