Skip to main content

VARIABLES AND MULTIPLE ASSIGNMENTS


VARIABLES AND MULTIPLE ASSIGNMENTS


Variables: Variables are reserved memory locations to store value. When a variable is created, some space is reserved into the memory. The assignment is done using the equal sign (=), example A=2(This expression means an integer 2 is saved in the variable A)
Python interpreter allocates memory depending on the datatype which is used. There are many datatypes like integers, float, strings, etc. Every datatype has different bytes of location reserved into the memory.
Let’s see some of the examples:
Name = “Arnold”
Here a string called Arnold is stored in variable called Name.
Age= 25
Here an integer or a number doesn’t require single or double quote to define.
Note: You cannot define variable name with space between two or more words
Example: My name = “Jack”
This will give an error
Correction: MyName = “Jack”

Multiple Assignments: Python allows user to assign single value to multiple variables simultaneously. For example:
a = b = c = d = 50
Here, an integer with value 50 is stored in all the four variables and all of them are assigned to the same memory location. You can also assign different datatypes to multiple variables. For example:
Name, age, income = “Tesla”, 30, 50000
Here, Name is a string which stores “Tesla” and two integer age and income are assigned to store the respective vales 30 and 50000.


 

Comments

Popular posts from this blog

DECISION MAKING STATEMENTS

DECISION MAKING STATEMENTS During the execution of the program, when there is a specific application to check the condition and make a proper decision, Decision making statements are used to anticipate specific actions which has to be taken depending upon the condition. Decision making statements are evaluated using TRUE and FALSE values. For example, if a particular condition is TRUE what outcome is expected and when, FALSE what outcome is expected. Depending on the application of program, set of statements are written into the code to perform a particular task. Python provides following types of decision making statements: Ø If statement: It is normal If statement which has condition in terms of Boolean expression, comparison operators, etc. Ø If..else statement: In this case, an If is followed by an else statement. It means ‘IF’ condition turns to be FALSE than ‘ELSE’ will be executed automatically Ø Ladder If.. else if .. else if: This is an extension o...

COMPARISON, LOGICAL, ASSIGNMENT AND BITWISE OPERATORS

COMPARISON, LOGICAL, ASSIGNMENT AND BITWISE OPERATORS In this blog we will see about Arithmetic operators and understand how to use it with Python IDLE to perform certain calculations. PYTHON COMPARISON OPERATORS OPERATOR DESCRIPTION EXAMPLE        == Checks whether LHS is equal to RHS, then the condition becomes true 10==10 is true        != Checks whether LHS is not equal to RHS, then the condition becomes true 2!=3 is true        > Checks whether LHS is greater than RHS, then the condition becomes true 6>3 is true        < Checks whether LHS is less than RHS, then the condition becomes true 6<10 is true        >= Checks whether LHS is gre...

BUILT INS FUNCTIONS IN PYTHON

BUILT INS FUNCTIONS IN PYTHON Every programming languages have certain pre-defined functions. Similarly, for certain tasks python has built in functions which you can access and understand as explained in the video.   dir(__builtins__): This module will return all the built in function and identifiers directly available to the programmer.   help(“function name”): This is the most important function in python. It gives the complete detail regarding the function which you mentioned inside help().