What are Variables in Python - Learn Online

What are Variables in Python

Lesson Details:
September 17, 2020

Video Transcription: In this lecture we are going to have a fair idea about variables in Python this video is brought to you by Appy Pie's Academy as you might already be knowing a variable is a named container of a value so whenever we are supposed to contain a value somewhere in the memory location it is stored under a variable name this value can be of certain data type like integer float string etc now python is a dynamically typed language unlike C C++ Java etcetera now let me explain what is dynamically typed language a dynamically typed language is a language in which there is no need to declare a variable because declaration of a variable involves specifying its datatype now in Python you need not declare a variable before using it it's data type will be decided when the value will be assigned to it now there is no need to declare a variable in Python it's data type is decided at runtime when it is assigned a value when the program is in execution stage and a value is going to be assigned to the variable what is the type of that value accordingly that particular variable will be taken to be of that data type examples X is equal to hundred now access a variable it is being assigned a value 100 as hundred is an integer value datatype of X will be assumed to be integer city is equal to within quotation marks I have written New York so within quotation marks we people write string constants so New York is a string constant so city variable will be treated as a string variable similarly salary is equal to 12,000 point seven eight because it's a decimal value so salary will be considered to be a float data type now by float data type I mean to say the the variable of flow data type is the one which is containing the decimal values like this one now let me tell you about certain rules for naming variables rules are very simple a variable name consists of alphanumeric characters and underscore only I mean to say the variable name can consist of consists of the letters from capital a to capital Z from small a to small said from digit 0 to digit 9 and underscore a variable name is case-sensitive what I mean to say by saying case since they ways for example say a variable small a is different from capital a both are a but the difference is in case a small letter a would not be treated as the same as capital letter a and variable code C is capital is different from variable code C is small so this is to say that a variable name is case-sensitive in Python now the next rule is the first character should be either a letter or underscore the first letter cannot be a number I mean to say I cannot have a variable like one digit 1 ABC yes it could be a BC digit 1. 

Course content