Skill - Managing Variables in python
Skills Required
Please make sure to have all the skills mentioned above to understand and execute the code mentioned below. Go through the above skills if necessary for reference or revision
Main Code
Assigning value to a variable
x = 1
y = 'abc'
The code above assigns the value 1 to variable x and assigns the value ‘abc’ to variable y
Deleting variables
del x
The above code deletes the variable x
Get type of the variable
x = 1
print(type(x))
The above code will print <type 'int'>
Some other operations
x = 2
# this makes value of y as 4 as x is multiplied by 2
y = 2*x
# this makes value of z as 6 as the addition of x and y is assigned to z
z = x + y
Further Reading
Video
You can see the video for this post here
Online Interpreter
You can run these codes online at https://www.programiz.com/python-programming/online-compiler/
Comments
Post a Comment