Python Programming Tutorial- Expressions and Variables

by | Oct 26, 2020 | Python | 0 comments

Python Programming Tutorial- Expressions and Variables’ post is follow up to ‘Types in Python Explained- Built-in Data types‘. All posts in this series are based on course “Python For Data Science” at

Python Expressions

Expressions are operations that Python performs. For example, basic arithmetic operations like adding multiple numbers. You can check in Jupyter Notebooks by typing different expressions.

We can perform operations such as subtraction using the subtraction sign.

type  30-70  and run in python, here python acts as a calculator.

We can use the double slash for integer division, where the result is rounded 50//10.5

The expressions in the parentheses are performed first- (45*5) + 8

Python follows mathematical conventions when performing mathematical expressions.

You can do a variety of mathematical operations in Python including:

  • addition: 2 + 2
  • subtraction: 5 – 2
  • multiplication: 3 * 2
  • division: 4 / 2
  • exponentiation: 4 ** 2

What is Variable?

In Python a variable is a name that refers to a value. Usually Assignment statements create new variables and also give them values to refer to.

In simplest terms, a variable is just a box that you can put stuff in. You can usevariables to store all kinds of stuff, but for now, we are just going to look at storing numbers in variables.

lucky = 7

print (lucky)


This code creates a variable called lucky , and assigns to it the integer number 7

Convention for Variable names

It can be arbitrarily long. They can contain both letters and numbers, but they have to begin with a letter. It is legal to use uppercase letters, but it is a good idea to begin variable names with a lowercase letter.

The underscore character (_) can appear in a name. It’s common to use the underscore to represent the start of a new word, you can also use a capital letter.

keywords cannot be used as variable names. A error will be thrown if it is used.


 Watch the Video

Join Today

Know more about latest trends, News in Field of Data Analytics.

We will offer Free SAS and Python Programme in Data Science & enhance your understanding of data analysis.

By rlochan2021

We offer Everything Free here and always will be, so joining is Risk Free and Always Cost Free.

Check Out These Related Posts

Functions in Python Programming for Data Science

I am really impressed with two online courses one is “Analytics in Python” at edX by ColombiaX and another is “Python for Data Science” at or (Previously Bigdatauniversity). So i am going to document what ever i will learn about functions in these two courses. First there are Built-in functions(Ready made for use), such […]

read more

String Functions in SAS and Python

I always believe SAS and Python can make a great team together for Data Scientists. So Why Now we study them together. In this Post we will discuss various String functions in SAS and Python. String Functions in Python 3 Hope you must have gone through my previous post “Python Programming- Strings explained“. len(): returns […]

read more



Submit a Comment

Your email address will not be published. Required fields are marked *