What are Tuples in Python.

By definition Tuples are immutable data types which store a collection of objects.

Creating Tuples

Creating a tuple is as simple as putting different comma-separated values. Optionally you can put these comma-separated values between parentheses also.

Accessing Tuples

Like string indices, tuple indices start at 0, and they can be sliced, concatenated, and so on.

Updating Tuples

Tuples are immutable which means you cannot update or change the values of tuple elements. You are able to take portions of existing tuples to create new tuples as the following example demonstrates −

Tuples are immutable but potential changeable.


What are Pointers?

If you’ve ever worked with lower level languages like C or C++, then you’ve probably heard of pointers. Pointers allow you to create great efficiency in parts of your code. They also cause confusion for beginners and can lead to various memory management bugs, even for experts.

Pointers are widely used in C and C++. Essentially, they are variables that hold the memory address of another variable. Lets understand pointers with simple real world analogy.

There is a requirement to paint your office building. Hence you search for an company online to do this task for you (custom_function). The company initial requirement is to ship the office building to them and after completing the task of painting the building will be ship back to you. This might seems an heavy task and company deny to do it. As shipping back entire office building is cost heavy. Hence you decided to copy the address of the building (pointers) on an envelope and send it to the paint company. The company goes to the address and do the necessary work , in this way they has nothing to return back to you.

Why Python does not have Pointers?

Pointers seem to go against the Zen of Python. Pointers encourage implicit changes rather than explicit…

Sushant Pupneja

Software Developer during day time, blogger at night.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store