DEV Community

Cover image for Python Basics, Python 101!
Acar Emmanuel
Acar Emmanuel

Posted on

Python Basics, Python 101!

In this article I am going to introduce the basics of Python and what you need to know to get started.

What is Python?

According to the official Python docs Python is an interpreted, object-oriented, high-level programming language with dynamic semantics.

Python was created by Guido van Rossum, and first released on February 20, 1991.
The need to develop Python was premised on the idea of easy code readability which is facilitates easy understanding, and a simple syntax which allows programmers to write programs in fewer lines of code.

The very first version of python released was version 0.9 on February 20,1991 and the latest version at the moment is python 3.10 released on October 04, 2021.

Python has become very popular over the years and the following are some of the reasons why it has become a darling among most software developers;

  • Easy to Learn and Use.
  • Mature and Supportive Python Community.
  • Support from Renowned Corporate Sponsors.
  • Hundreds of Python Libraries and Frameworks.
  • Versatility, Efficiency, Reliability, and Speed.
  • Big data, Machine Learning and Cloud Computing capabilities.

Installing and setting up Python.

Python is free for download from the official python website . Choose the appropriate operating system and computer architecture. Make sure to add Python to path during installation to be able to use it via the command line.

Installing the IDE to use.

There are several IDEs that you can use among which include;

Getting started.

1. Python variables.

Variables also known as identifiers are reserved memory locations used to store values.
There are a couple of rules to follow when naming variables as follows;

  • A variable name must start with a letter or the underscore character
  • A variable name cannot start with a number
  • A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
  • Variable names are case-sensitive (age, Age and AGE are three different variables)
  # correct variables
  name = "Manuel"
  my_name = "Manuel"
  myName = "Manuel"
  name1 = "Manuel"
  _name = "Manuel"

  # incorrect variable
  2name = "Manuel"
  *myName = "Manuel"
Enter fullscreen mode Exit fullscreen mode

2. Python keywords.

These are reserved words that can not be used when naming variables in Python and for version 3.9 there are about 36 keywords.
Some few of them are; True,While,if,elif and for among many others.
The full list of keywords can be found from here.

3. Data types.

A data type is an attribute associated to a piece of data that tells a computer system how to interpret and execute its value.
Python data types or simply type include;

  • string
  • integer
  • float
  • boolean
  • byte
     string_demo = ' I am a string'
     float_demo = 2.45
     integer_demo = 245
     character_demo = 'A'
     bool_demo = True
Enter fullscreen mode Exit fullscreen mode

4. Python operators.

There are various operators used in python.

  • Comparison operators.
  • Logical operators.
  • Arithmetic operators.
  • Bitwise operators.
     #Arithmetic operators
     y += 1 #incrementing by 1
     y -= 2 #incrementinh y by 2
     #comparison operators
     y = 2
     x = 3
     y > x  #evaluates to false
     x > y #evaluates to True
     x == y  #evaluates to false
     #logical operators
     logical_stuff = ['and','or','not']
Enter fullscreen mode Exit fullscreen mode

5. Python literals.

Generally, literals are a notation for representing a fixed value in source code. They can also be defined as raw value or data given in variables or constants.(Geek for geeks)

  • String literals
  • Numeric literals
  • Boolean literals
    #string literal
    letter = 'n'
    #integer literal
    score = 90
    #string literal
    fruit = 'banana'
Enter fullscreen mode Exit fullscreen mode

Happy reading and feel free to suggest any improvements. Stay safe.

Top comments (0)