Python was developed by Guido van Rossum in the early 1990s and its latest version is 3.11.0, we can simply call it Python3. Python 3.0 was released in 2008. and is interpreted language i.e it's not compiled and the interpreter will check the code line by line. This article can be used to learn the very basics of Python programming language .
Python 3 Basics
Python 3 is a popular high-level programming language used for a wide variety of applications. Here are some basics of Python 3 that you should know:
- Variables : In Python 3, variables are created by assigning a value to a name. For example, x = 5 creates a variable called x and assigns the value 5 to it.
- Input and output : In Python 3, you can use the input() function to get user input, and the print() function to output text to the console.
- Data types : Python 3 supports several built-in data types, including integers, floats, strings, booleans, lists, tuples, and dictionaries.
- Operators : Python 3 supports a variety of operators, including arithmetic operators (+, -, *, /), comparison operators (>, <, ==, !=), and logical operators (and, or, not).
- Control flow statements : Python 3 supports several control flow statements, including if-else statements, for loops, and while loops. These statements allow you to control the flow of execution in your code.
- Functions : In Python 3, functions are created using the def keyword. For example, def my_function(x): creates a function called my_function that takes one argument called x.
- Modules : Python 3 supports modules, which are collections of functions and variables that can be imported and used in other Python code. You can import modules using the import keyword.
Advantages of Python 3
- Python 3 has a simple syntax that is easy to learn and read, making it a good choice for beginners.
- Python 3 is a high-level language that has a large standard library and many third-party libraries available, making it a versatile language that can be used for a wide variety of applications.
- Python 3 supports multiple programming paradigms, including object-oriented, functional, and procedural programming.
- Python 3 is an interpreted language, meaning that it does not need to be compiled before running, making it easy to write and test code quickly.
- Python 3 has good support for data analysis and scientific computing, with libraries such as NumPy and Pandas.
- Easy to learn and user-friendly
Disadvantages of Python 3
- Python 3 can be slower than compiled languages such as C++ or Java, which may be a concern for applications that require high performance.
- Python 3 has a global interpreter lock (GIL), which can limit its ability to take advantage of multiple CPU cores.
- Python 3 may not be the best choice for low-level systems programming, as it does not offer the same level of control over hardware as other languages.
- Python 3 is not as popular in some fields as other languages, such as R for data analysis or C++ for game development, so it may not always be the best choice for specific applications.
Let's do the most popular 'HelloWorld' tradition and hence compare Python's Syntax with C, C++, and Java ( I have taken these 3 because they are the most famous and mostly used languages).
Python
# Python code to print the Hello, World!;
# nothing else to type...see how simple is the syntax.
print("Hello, World!")
Note: Please note that Python for its scope doesn't depend on the braces ( { } ), instead it uses indentation for its scope. Let us start with our basics of Python where we will be covering the basics in some small sections. Just go through them and trust me you'll learn the basics of Python very easily.
If you are on Windows OS download Python by Clicking here and now install from the setup and in the start menu type IDLE.IDLE, you can think it as a Python's IDE to run the Python Scripts. It will look somehow this : 
If you are on Linux/Unix-like just open the terminal and on 99% linux OS Python comes preinstalled with the OS.Just type 'python3' in terminal and you are ready to go. It will look like this :
The ” >>> ” represents the python shell and its ready to take python commands and code.
In other programming languages like C, C++, and Java, you will need to declare the type of variables but in Python you don’t need to do that. Just type in the variable and when values will be given to it, then it will automatically know whether the value given would be an int, float, or char or even a String.
Python Program to Illustrate a DataTypes
Python
# print the integer number
myNumber = 3
print(myNumber)
#print the float number
myNumber2 = 4.5
print(myNumber2)
#print the string
myNumber ="helloworld"
print(myNumber)
See, how simple is it, just create a variable and assign it any value you want and then use the print function to print it. Python have 4 types of built-in Data Structures namely List , Dictionary , Tuple, and Set .
Python Program to Illustrate a List
List is the most basic Data Structure in Python. Python List is a mutable data structure i.e items can be added to list later after the list creation. It’s like you are going to shop at the local market and made a list of some items and later on you can add more and more items to the list.
append() function is used to add data to the list.
Python
# creates a list
list1=["geeks","for","geeks",100,10.19,5j+10,]
#print the list
print("the list is: ",list1)
#print first index data
print("the zeroth index value: ",list1[0])
#print range of list
print("the index of 0 to 4 datas in list: ",list1[0:4])
#print backward of list
print("the backward is list: ",list1[::-1])
Outputthe list is: ['geeks', 'for', 'geeks', 100, 10.19, (10+5j)]
the zeroth index value: geeks
the index of 0 to 4 datas in list: ['geeks', 'for', 'geeks', 100]
the backward is list: [(10+5j), 10.19, 100, 'geeks', 'for', 'geeks']
Python program to illustrate a Dictionary
A Python dictionary is a data structure that stores the value in key:value pairs. Python dictionaries are essential for efficient data mapping and manipulation in programming.
Python
# creates a empty list
Dict = []
# putting integer values
Dict = {1: 'Geeks', 2: 'For', 3: 'Geeks'}
print(Dict)
#print the value in dict using keyword
print("the value of key is:", Dict[3])
Output{1: 'Geeks', 2: 'For', 3: 'Geeks'}
the value of key is: Geeks
Python program to illustrate a Tuple
A Python tuple is a collection of objects separated by commas. While it shares similarities with a Python list—such as indexing, nested objects, and support for repetition—the key distinction is that tuples are immutable, meaning their elements cannot be changed after creation, whereas lists are mutable and allow for modifications.
Python
# creates a tuple which is immutable
tup = ('Geeks', 'For', 'Geeks')
print(tup)
#print the value by index
print(tup[2])
Output('Geeks', 'For', 'Geeks')
Geeks
Python Program to illustrate a Set
A Set in Python programming is an unordered collection data type that is iterable, mutable and has no duplicate elements.
Python
# define a set and its elements
myset = set(["Geeks", "For", "Geeks"])
#as set doesn't have duplicate elements so, 1 geeks will not be printed
print(myset)
#union in set
myset= myset.union({"good","online","learning","platform"})
print(myset)
#intersection in set
set1={"geeks","online","platform"}
set2={"for","geeks","platform"}
new_set=set1.intersection(set2)
print(new_set)
Output{'Geeks', 'For'}
{'Geeks', 'platform', 'good', 'For', 'online', 'learning'}
{'platform', 'geeks'}
Comments:
# is used for single line comment in Python
""" this is a comment """ is used for multi line comments
In this section, we will learn how to take input from the user and hence manipulate it or simply display it. input() function is used to take input from the user.
Python
# Python program to illustrate
# getting input from user
name = input("Enter your name: ")
# user entered the name 'harssh'
print("hello", name)
Output:
hello harsh
Python program to get Input from User
Python
# accepting integer from the user
# the return type of input() function is string ,
# so we need to convert the input to integer
num1 = int(input("Enter num1: "))
num2 = int(input("Enter num2: "))
#Multiplicaion
num3 = num1 * num2
print("Product is: ", num3)
num3 = num1 * num2
print("Product is: ", num3)
#Addition
num4 = num1 + num2
print("Addition is: ", num4)
#Subtraction
num5 = num1 - num2
print("Subtraction is: ", num5)
#Division
num6 = num1 / num2
print("Division is: ", num6)
Output:
Enter num1: 8 Enter num2: 6 ('Product is: ', 48)
Condition in Python is made using the two keywords ‘if’ and ‘elif’(elseif) and else.
Python
# Python program to illustrate Conditional statement
num1 = 34
if(num1>12):
print("Num1 is good")
elif(num1>35):
print("Num2 is not gooooo....")
else:
print("Num2 is great")
You can think of functions like a bunch of code that is intended to do a particular task in the whole Python script. Python used the keyword ‘def’ to define a function.
Syntax:
def function-name(arguments):
#function body
Python
# Python program to illustrate functions
def hello():
print("hello")
print("hello again")
# initiate the function by calling function name
hello()
# calling function
hello()
Outputhello
hello again
hello
hello again
Now as we know any program starts from a ‘main’ function…lets create a main function like in many other programming languages.
Python
# Python program to illustrate
# function with main
def getInteger():
result = int(input("Enter integer: "))
return result
def Main():
print("Started")
# calling the getInteger function and
# storing its returned value in the output variable
output = getInteger()
print(output)
# now we are required to tell Python
# for 'Main' function existence
if __name__ == "__main__":
Main()
As the name suggests it calls repeating things again and again. We will use the most popular ‘for and while’ loop here.
Python
# print the iteration in single line
print("For Loop:")
for step in range(5):
print(step)
# a simple while loop
print("While Loop:")
step = 0
while(step < 5):
print(step)
step = step+1
OutputFor Loop:
0
1
2
3
4
While Loop:
0
1
2
3
4
Python has a very rich module library that has several functions to do many tasks. ‘import’ keyword is used to import a particular module into your python code. For instance consider the following program.
Python
# Python program to illustrate math module
import math
#factorial for given number
def fact(num):
factorial=1
for i in range(1,num+1):
factorial*=i
return factorial
num=5
#print factorial
print(fact(num))
These are some of the basics of the Python programming language and I will be covering both the intermediate and advanced level Python topics in my upcoming articles.
Similar Reads
How to Learn Python from Scratch in 2025 Python is a general-purpose high-level programming language and is widely used among the developersâ community. Python was mainly developed with an emphasis on code readability, and its syntax allows programmers to express concepts in fewer lines of code.If you are new to programming and want to lea
15+ min read
Python Introduction Python was created by Guido van Rossum in 1991 and further developed by the Python Software Foundation. It was designed with focus on code readability and its syntax allows us to express concepts in fewer lines of code.Key Features of PythonPythonâs simple and readable syntax makes it beginner-frien
3 min read
Python 3 basics Python was developed by Guido van Rossum in the early 1990s and its latest version is 3.11.0, we can simply call it Python3. Python 3.0 was released in 2008. and is interpreted language i.e it's not compiled and the interpreter will check the code line by line. This article can be used to learn the
10 min read
Important differences between Python 2.x and Python 3.x with examples In this article, we will see some important differences between Python 2.x and Python 3.x with the help of some examples. Differences between Python 2.x and Python 3.x Here, we will see the differences in the following libraries and modules: Division operatorprint functionUnicodexrangeError Handling
5 min read
Download and Install Python 3 Latest Version If you have started learning of Python programming, then for practice, Python installation is mandatory, and if you are looking for a guide that teaches you the whole process from downloading Python to installing it, then you are on the right path.Here in this download and install Python guide, we h
6 min read
Statement, Indentation and Comment in Python Here, we will discuss Statements in Python, Indentation in Python, and Comments in Python. We will also discuss different rules and examples for Python Statement, Python Indentation, Python Comment, and the Difference Between 'Docstrings' and 'Multi-line Comments. What is Statement in Python A Pytho
7 min read
Python | Set 2 (Variables, Expressions, Conditions and Functions) Introduction to Python has been dealt with in this article. Now, let us begin with learning python. Running your First Code in Python Python programs are not compiled, rather they are interpreted. Now, let us move to writing python code and running it. Please make sure that python is installed on th
3 min read
Global and Local Variables in Python In Python, global variables are declared outside any function and can be accessed anywhere in the program, including inside functions. On the other hand, local variables are created within a function and are only accessible during that functionâs execution. This means local variables exist only insi
7 min read
Type Conversion in Python Python defines type conversion functions to directly convert one data type to another which is useful in day-to-day and competitive programming. This article is aimed at providing information about certain conversion functions. There are two types of Type Conversion in Python: Python Implicit Type C
5 min read
Private Variables in Python Prerequisite: Underscore in PythonIn Python, there is no existence of âPrivateâ instance variables that cannot be accessed except inside an object. However, a convention is being followed by most Python code and coders i.e., a name prefixed with an underscore, For e.g. _geek should be treated as a n
3 min read