three of the most common data types used in programming: numbers, strings and booleans. We assigned those data types to variables one-by-one, like so:
With working code below find examples and learn Python easily..
x = 3 # numbers
a = “gorillas” # strings
t = True # booleans
PS : To show OutPut we have used >> sign
Numbers
width = 20
height = 5 * 9
print width*height;
print(width*height);
>> 900
>> 900
Strings
item_1 = “milk”
item_2 = “cheese”
item_3 = “bread”
print ‘doesn’t’ # use ‘ to escape the single quote…
print “doesn’t” # …or use double quotes instead
>> doesn’t
s = ‘First line.nSecond line.’
# n means newline
print s
>> First line.
Second line.
If you don’t want characters prefaced by to be interpreted as special characters, you can use raw strings by adding an r before the first quote:
print r’C:somename’ # note the r before the quote
C:somename
Strings can be concatenated (glued together) with the + operator, and repeated with *:
print 3 * ‘un’ + ‘ium’
>> unununium
If you want to concatenate variables or a variable and a literal, use +:
prefix = ‘Dhaval’
prefix = prefix + ‘Devil’
print prefix
>> DhavalDevil
See Working code at http://ideone.com/cF38M7