to assign a variable , use one equal sign
>>>x =7
Variable can be assigned as many times as you want
In python , variables don't have specific type , so you can assign a string to a variable , and later asign an integer to the same variable
>>>x = 123.456
>>>x = "This is a string"
Variables name : letters , numbers,underscores, can;t start with number
Python is a case sensitive programming language , A a is different
Trying to reference a variable , you haven't assigned to cause an error
use "del" to remove a variable => you have to reassign before you use it
>>>fool = 50
>>> del fool
Can also take the value of the variable form the user input
>> name = input("What is your name :")
foo and bar are called "metasyntactic variables"=> use for placeholder names
No comments:
Post a Comment