DEV Community

Cover image for Python 101: Introduction to Modern Python

Posted on

Python 101: Introduction to Modern Python

Python is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis. Python is a general purpose language, meaning it can be used to create a variety of different programs and isn’t specialized for any specific problems. This versatility, along with its beginner-friendliness, has made it one of the most-used programming languages today.

Python is the most rapidly growing programing language. It can build web applications, games, consoles, and more .
python has become a world-famous and powerful programming language and has been ranked the best in the year 2022. Python 3 is the most up-to-date version of the language with many improvements made to increase the efficiency and simplicity of the Python code that you write. It’s friendly, simple, and easy to learn.

Get Started!

As a beginner in python , you do not have to worry , the python community has lots of resources that you can use to learn.They include Youtube tutorials , writeups and so many sites that will help you write your code and debug .But first things first :

Before you using python first you have to ensure you have the right environment and libraries installed

Python installation steps

2.Select your Operating system(Windows,Linux/UNIX,MacOS,Other
3.Select the release or version, click on it to download.
4.Double click on the file to execute and install.
5.For window mark “add to system paths”

An alternative way to install python on Linux is to run

sudo apt install python3 
Enter fullscreen mode Exit fullscreen mode


sudo apt install python
Enter fullscreen mode Exit fullscreen mode

on the terminal.
For more check on ( for more documentations.
What makes python code is its syntax which emphasizes readability thus easy and simple to read and write
Sample python code compared to java code:

Java Code

public class HelloWorld{
public static void main(String[] args){
System.out.println("Hello World");

Python code

`print("Hello World")`
Enter fullscreen mode Exit fullscreen mode

fundamental programming concepts and the Python programming language

1.Control Flow
A program’s control flow is the order in which the program’s code executes.

The control flow of a Python program is regulated by conditional statements, loops, and function calls.

Python has three types of control structures:

Sequential **- default mode
- used for decisions and branching
Repetition - used for looping, i.e., repeating a piece of code multiple times.


Image description


Lists are used to store multiple items in a single variable.

Lists are one of 4 built-in data types in Python used to store collections of data, the other 3 are Tuple, Set, and Dictionary, all with different qualities and usage.

Lists are created using square brackets:

Example :
thislist = ["apple", "banana", "cherry"]

3.Loop Functions

The for loop in Python is used to iterate over a sequence (list, tuple, string) or other iterable objects. Iterating over a sequence is called traversal.

for val in sequence:
loop body

*4.Strings *
string is an immutable sequence data type. It is the sequence of Unicode characters wrapped inside single, double, or triple quotes.

a = "Hello"


In Python, Modules are simply files with the “.py” extension containing Python code that can be imported inside another Python Program.

In simple terms, we can consider a module to be the same as a code library or a file that contains a set of functions that you want to include in your application.

With the help of modules, we can organize related functions, classes, or any code block in the same file


`import mymodule



Dictionary in Python is an unordered collection of data values, used to store data values like a map, which, unlike other Data Types that hold only a single value as an element, Dictionary holds key:value pair. Key-value is provided in the dictionary to make it more optimized.

thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964

Note – Keys in a dictionary don’t allow Polymorphism.

*7.Files *

A file is some information or data which stays in the computer storage devices. You already know about different kinds of file , like your music files, video files, text files. Python gives you easy ways to manipulate these files. Generally we divide files in two categories, text file and binary file.

he key function for working with files in Python is the open() function.

The open() function takes two parameters; filename, and mode.

There are four different methods (modes) for opening a file:

"r" - Read - Default value. Opens a file for reading, error if the file does not exist

"a" - Append - Opens a file for appending, creates the file if it does not exist

"w" - Write - Opens a file for writing, creates the file if it does not exist

"x" - Create - Creates the specified file, returns an error if the file exists

In addition you can specify if the file should be handled as binary or text mode

"t" - Text - Default value. Text mode

"b" - Binary - Binary mode (e.g. images)

Example :

f = open("demofile.txt", "rt")

For better understanding visit the site . (Python tutorial for beginners )

“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” – Martin Fowler

Top comments (0)