Python Basic Syntax and Variables


What Are Variables in Python?

Python is a general-purpose programming language, and variables are a fundamental building block. Variables are elements used to store data. In this article, we will provide information about Python's basic syntax and variables. As Python is a dynamic language, you do not need to specify a data type when defining a variable. This allows developers to work more flexibly and quickly.

Defining Variables in Python

Defining a variable in Python is quite simple. After choosing the name of the variable, you can define it by assigning a value with the equals sign. Python imposes some rules on variable naming. The variable name must start with a letter and can contain alphanumeric characters. Also, it cannot contain spaces or special characters.

Example Variable Definition

# Defining a variable
name = "Ahmet"
age = 30

Above, a "name" variable is defined as a string (text); an "age" variable is defined as integer (whole number). Now let's print the values of these variables to the screen.

Printing Variables

# Printing variables
print("My Name:", name)
print("My Age:", age)

Conclusion

Defining and using variables in Python is quite easy. By following the basic syntax rules, you can work with variables. Because Python is a dynamic language, it gives you flexibility in the coding process. In this article, we looked at the basic syntax and variable definition methods in Python. For beginners, these topics form a very important foundation.