In this article we will learn about creating and naming variables in Python programming language along with examples.
What are Variables?
Variables are just names of memory locations. Variables are used to store and retrieve values from memory. Type of the variable in Python is based on the value we assign to the variable.
Variable Naming
In Python, names come into existence when you assign values to them, but there are a few rules to follow when choosing names for the subjects of your programs:
- Names must start with a letter or underscore and can be followed by any number of letters, digits, or underscores.
- Special symbols are not allowed in names.
- Names are case sensitive.
- Names cannot be reserved words.
Creating and Using Variables
Syntax for creating a variable is as follows:
Variable-name = value
Consider the following example which creates a variable named x and assigns the value 10 to it:
x = 10
Learn more about variables in Python through the following resources:
Suryateja Pericherla, at present is a Research Scholar (full-time Ph.D.) in the Dept. of Computer Science & Systems Engineering at Andhra University, Visakhapatnam. Previously worked as an Associate Professor in the Dept. of CSE at Vishnu Institute of Technology, India.
He has 11+ years of teaching experience and is an individual researcher whose research interests are Cloud Computing, Internet of Things, Computer Security, Network Security and Blockchain.
He is a member of professional societies like IEEE, ACM, CSI and ISCA. He published several research papers which are indexed by SCIE, WoS, Scopus, Springer and others.
Leave a Reply