Sunday, 25 January 2015

Python 3.4.2 Part 4 Using Variables tutorial

Storing a number to x


       

x=10
        
    


       

x+20
        
    


Storing string

       

x="mams"
        
    


       

x+" "+"Python"
        
    


Now adding a number with string variable must type cast to int
eg
x=100
y="10"
to add x and y we should convert y to a number

type casting (Converting string to number)

       

x+int(y)
        
    



No comments:

Post a Comment