cont....
of Python#4-If and elif Statements in Python
VariableName = values
Example:
variable = 1
print variable
Output:
1
Integer Variable can be used like this in python...eg: variable =1
Note Worthy: Like C, C++, Java you don't have to declare the data type of the variable in python. The variable in Python is itself acts as datatype based on the values it holds.
Syntax:
StringVariableName = "String values goes here"
Example:
String="Dharani"
print String
Output:
Dharani
Note Worthy: Some times you might get a doubt that...whether we should ' ' or " " for string .Chill!...No worries in Python..You can use both..It works..
Quick Rules Of Variable Usage in Python:
Syntax:
StringVariableName = "String goes here! " (or) StringVariableName = 'String goes here!'
Example:
String1="Hello Google bird User - Double Quotes"
String2='Hello google bird user - single quotes'
print String1
print String2
Output:
Hello Google bird User - Double Quotes
Hello google bird user - single quotes
Note Worthy: In python there is function called title() .It will be used to Capitalize the first Letter of word in the sentence(CamelCase)..
Example:
Variable="google bird dd search in google to find me"
print Variable.title()
Output:
Google Bird Dd Search In Google To Find Me
of Python#4-If and elif Statements in Python
What are variables?
A variable is the one which holds the values.
Syntax:VariableName = values
Example:
variable = 1
print variable
Output:
1
Integer Variable can be used like this in python...eg: variable =1
Note Worthy: Like C, C++, Java you don't have to declare the data type of the variable in python. The variable in Python is itself acts as datatype based on the values it holds.
How to store the Strings in variables?
Its the same as the Integer Variable usage, but the minor change is ....
The String should be surrounded with quotes ..
Syntax:
StringVariableName = "String values goes here"
Example:
String="Dharani"
print String
Output:
Dharani
Note Worthy: Some times you might get a doubt that...whether we should ' ' or " " for string .Chill!...No worries in Python..You can use both..It works..
Try Yourself in the below working area..
Quick Rules Of Variable Usage in Python:
- Variables can contains Letters, Numbers and Underscores.
- It can start with Letters or Underscores but not Numbers.
- You cannot use Python Keywords as variables name.
What are Strings?
Strings are called as literal which is surrounded by either single quotes or double quotes.
Syntax:
StringVariableName = "String goes here! " (or) StringVariableName = 'String goes here!'
Example:
String1="Hello Google bird User - Double Quotes"
String2='Hello google bird user - single quotes'
print String1
print String2
Output:
Hello Google bird User - Double Quotes
Hello google bird user - single quotes
Note Worthy: In python there is function called title() .It will be used to Capitalize the first Letter of word in the sentence(CamelCase)..
Example:
Variable="google bird dd search in google to find me"
print Variable.title()
Output:
Google Bird Dd Search In Google To Find Me
_________________________________________________________________________________
Don't Forget to Try it!
_________________________________________________________________________________
Thanks and Regards,
Tech Bird
Comments