Skip to content

Dr. Praveen Borra

  • About
  • Expertise
  • Work
  • Research
  • Media
  • Blog
  • Contact
September 18, 2020

·

2–3 minutes

Introduction to Python

By Dr. Praveen Borra

Python is an interpreted, high-level and general purpose programming language. Created by Guido van Rossum and first released in 1991, Python’s design philosophy emphasizes code readability with its notable use of significant whitespace.


Python combines remarkable power with very clear syntax. It has modules, classes, exceptions, very high-level dynamic data types, and dynamic typing. There are interfaces to
many system calls and libraries, as well as to various windowing systems. New built-in modules are easily written in C or C++ (or other languages, depending on the chosen
implementation). Python is also usable as an extension language for applications written in other languages that need easy-to-use scripting or automation interfaces.


Downloading Python:
https://www.python.org/downloads/

Numbers:
The interpreter acts as a simple calculator: you can type an expression at it, and it will write the value. Expression syntax is straightforward: the operators +, -, * and / work just like in most other languages (for example, Pascal or C); parentheses (()) can be used for grouping.
Example:

>>>4 + 5
9
>>>100 – 5*7

65

>>>100 – 5*7/ 5
13.0


>>>9 / 5 # division always returns a floating point number
1.8
Division (/) always returns a float. To do floor division and get an integer result (discarding any fractional result) you can use the // operator; to calculate the remainder you can use %:
>>>20 / 3 # classic division returns a float
6.666666666666667
>>>20// 3 # floor division discards the fractional part
6


The equal sign (=) is used to assign a value to a variable. Afterwards, no result is displayed before the next interactive prompt:
>>>width = 10
>>>height = 4 * 8
>>>width * height
320

Strings:
Besides numbers, Python can also manipulate strings, which can be expressed in several ways. They can be enclosed in single quotes (‘…’) or double quotes (“… .”) .\ can be used to escape


Example:

>>> ‘Hello World’ # single quotes

‘Hello World’

>>>’Haven\’t’ # use \’ to escape the single
“haven’t”
Two or more string literals (i.e. the ones enclosed between quotes) next to each other are automatically concatenated.
>>>’Hello’ ‘World’
‘Hello World’
Strings can be indexed (subscripted), with the first character having index 0. There is no separate character type; a character is simply a string of size one:
>>>word = ‘Welcome’
>>>word[0] # character in position 0
‘W’
>>>word[5] # character in position 5
‘m’
The built in function len() returns the length of a string:
>>>s = ‘welcometopythonworld’
>>>len(s)
20

Lists:
Python knows a number of compound data types, used to group together other values. The most versatile is the list, which can be written as a list of comma separated values (items) between square brackets. Lists might contain items of different types, but usually the items all have the same type.


Example:

>>> squares = [1, 4, 9, 16, 25, 36, 49, 64]

>>>squares
[1, 4, 9, 16, 25, 36, 49, 64]


lists can be indexed and sliced:
>>>squares[0] # indexing returns the item
1
>>>squares[-1]
64
>>>squares[-3:] # slicing returns a new list
[36, 49, 64]


You can also add new items at the end of the list, by using the append() method:

>>>squares.append (81) # add the cube of 6

>>>squares.append (10 ** 2) # and the cube of 7
squares
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

Video Session Module:

Share this:

  • Share on X (Opens in new window) X
  • Share on Facebook (Opens in new window) Facebook
Like Loading…

Dr. Praveen Borra

Principal Data & AI Architect for Microsoft Fabric and Azure, with a Ph.D. in Computer Science from Florida Atlantic University. I write about cloud, data and AI.

About me · Services · Get in touch

Leave a Reply Cancel reply

Keep reading

Latest articles

  • July 5, 2024

    Edge Computing: Applications Across Industries and Future Innovations

    Introduction In today’s digital landscape, where data generation and consumption are at an all-time high, traditional methods of data processing face significant…

  • July 13, 2022

    Azure SQL Edge

    What is Azure SQL Edge? Azure SQL Edge is an optimized relational database engine geared for IoT and IoT Edge deployments. It…

  • July 13, 2022

    Microsoft Purview

    What’s available in the Microsoft Purview governance portal? Microsoft Purview’s solutions in the governance portal provide a unified data governance service that…

All articles →

Dr. Praveen Borra

Enterprise data and AI leader on Microsoft Fabric and Azure. Ph.D. in Computer Science, Florida Atlantic University.

Dallas, Texas

Get in touch →

Explore

About

Services

Work

Research

Teaching

Media

Blog

Connect

Contact

LinkedIn

YouTube

Google Scholar

All profiles

© 2026 Dr. Praveen Borra

Views expressed on this site are my own.

  • Comment
  • Reblog
  • Subscribe Subscribed
    Dr. Praveen Borra

    Have a WordPress.com account? Log in now.

  • Dr. Praveen Borra
    Copy shortlinkView post in Reader
    Manage subscriptionsSign upLog in
    Report this content
    Collapse this bar
%d