Value of variable


#1

Can we assign other type of values rather than numerical to a variable in python?


#2

Yes!

Standard Data Types
The data stored in memory can be of many types. For example, a person’s age is stored as a numeric value and his or her address is stored as alphanumeric characters. Python has various standard data types that are used to define the operations possible on them and the storage method for each of them.

Python has five standard data types −

Numbers
String
List
Tuple
Dictionary

See TutorialsPoint page on the topic.


#3

Thank you. This is helpful.


#4

We could add a couple of others that are standard data types…

Boolean
Set

A set is written like a dictionary, in curly braces, but is not made up of key-value pairs, only comma separated values. Like a dictionary it is unordered, but unlike a dictionary it is immutable and we need to use special methods to add to or remove items. Sets are similar to tuples, which are also immutable, though they do preserve their order. Unlike sets, tuples cannot have values added or removed. We can only unpack a tuple into its individual components.