Join us
A little history about the Python Programming language
Python is a multipurpose and dynamic interpretive programming language, python language is much easier to understand even for a beginner, and unlike other programming languages
With code that is simple and easy to implement, a programmer can prioritize the development of the application that is made, instead of being busy looking for syntax errors.
Only by you writing the code as above, you can print what you want inside the ( ) with quotes â â, without having to use a semicolon at the end
How to install python
Before you use python, you must install the latest version of python at this time, How to install python is very easy, follow the guide below. Below is a guide on how to install python on Linux, Windows, and Mac OS platforms.
LINUX
WINDOWS
Mac OS
Running Python
LINUX
OR
WINDOWS
Using shell
Mac OS
OR
A data type is a medium or memory on a computer that is used to store information.
Python itself has a data type that is quite unique when we compare it with other programming languages.
Here are the data types of the Python programming language:
To try various data types, please try the Python script below.
Variables are memory locations reserved for storing values.
Variables store data that is carried out during program execution, which later the contents of these variables can be changed by certain operations on programs that use variables
Variables are dynamic, meaning that Python variables do not need to be declared a specific data type and Python variables can be changed when the program is run.
Writing rules :
to create a variable in python, the method is very easy, just write any free variable, then fill it with any value by adding equals ( = ), before the value
Below is an example of using variables :
Operators are constructs that can manipulate the value of an operand.
For example operation 3 * 2 = 6. Here 3 and 2 are operands and * is the operator.
Python programming language supports a variety of operators, including:
below is an example of arithmetic operators:
comparison operator is used to compare a value :
Assignment Operator is used to assign and modify the value to a variable.
IF Conditions
If conditions are used to determine the actions and conditions to be taken
there are several statements including if, else and elif The if the condition is used to execute code if the condition evaluates to true True
If the condition evaluates to False, the if statement/condition will not be executed.
Below is an example of using IF :
IF ELSE Conditions
Is used to determine what action to take/execute if the conditions do not match.
The IF ELSE condition is a condition where if the statement is true True then the code in the if will be executed, but if it is False then the code in the else will be executed.
Below is an example of IF ELSE:
ELIF Conditions
With elif we can create program code that will select several possibilities that can occur. Almost the same as the âelseâ condition, the difference is that the âelifâ condition can be many, not just one.
Below is an example of ELIF :
A loop is a program code instruction that is executed repeatedly. Its function is to command the computer to do something repeatedly with a certain amount as long as a predetermined condition is still met.
The loop has three parts :
While loop
A while loop is a statement that is executed many times as long as the condition evaluates to True.
Below is an example of using a While Loop :
For Loop
Pythonâs for loop has the ability to iterate over items of any order, such as a list or a string.
Below for an example For Loop :
Nested Loop
A nested loop is a programming term that means to make loops within loops.
Below Is an example of the nested loop:
In the Python programming language, the most basic data structure is a sequence of lists. Each successive element will be assigned a position number or index. The first index in the list is zero, the second index is one, and so on.
Make a python list
The list is the most versatile data type available in Python, which can be written as a comma-separated list of values ââ(items) between square brackets. The important thing about lists is that the items in a list cannot be of the same type.
Below is an example of a list :
Access values in the python list
To use it, use square brackets to slice along with the index, to get the values ââavailable in the index
Below is an example :
list1[0]: fisika
list2[1:5]: [2, 3, 4, 5]
Delete values in the python list
To delete a value in a python list, you can use one of the del statements if you know exactly which element you are removing.
Below is an example :
Python List Methods and Functions
Python includes the following methods and functions:
Tuples are sequences, like lists. The main difference between tuples and lists is that tuples are immutable, unlike Pythonâs Lists. Tuples use brackets, while Python lists use square brackets.
Creating tuples is as easy as entering comma-separated values. Optionally, you can enter these comma-separated values ââbetween the brackets as well. As an example :
Empty tuples are written as two empty parentheses, for example, tup_1 = (); To write a tuple containing a single value, you must enter a comma, even if there is only one value, for example, tup_1 = (10,) Like String indexes, the index of tuples starts at 0, and they can be sliced, concatenated, and so on.
Access Values ââIn Python Tuples
To access values ââin tuples, use square brackets to slice along with the index or index to get the values ââavailable at that index. As an example:
After you execute the code above, the result will be like this:
Basic Operations on Python Tuples
Tuples respond to the + and * operators in the same way as Strings; They mean concatenation and looping here also applies
, except the result is a new tuple, not a string.
The following example :
Built-in Functions in Python Tuples
Python includes the following built-in functions :
Dictionary is a data type in python that serves to store a collection of data/values ââwith a âkey-valueâ approach, each key is separated from its value by a colon (:)
The dictionary value can be of any type, but the key must be an immutable data type such as a string, number, or tuple.
Access values in the python dictionary
To access a Dictionary element, you can use the familiar square brackets along with the key to getting the value. Here is a simple example:
Update Values ââIn Python Dictionary
You can update the Dictionary by adding new entries or key-value pairs, modifying existing entries, or deleting existing entries as shown in the simple example given below.
Remove Python Dictionary Element
You can delete individual Dictionary elements or delete the entire contents of the Dictionary. You can also delete the entire Dictionary in one operation.
To explicitly delete the entire Dictionary, just use the del statement. Here is a simple example:
Method Build-in in Python Dictionary
Python includes the following built-in methods:
Functions are organized and reusable blocks of code that are used to perform an action. Functions provide better modularity for your application and a high level of code usage.
Defining Python Functions
You can define functions to provide the required functionality. Here are simple rules for defining functions in Python.
Function example :
Join other developers and claim your FAUN account now!
Only registered users can post comments. Please, login or signup.