Friday, 30 January 2015

Python 3.4.2 part 2.1 printing hello tutorial

  1. cmd

       

cd /python34
python helloworld.py



  1. Notepad

       
       

print("helloworld")
  1. cmd

       
       
       

python helloworld.py








Sunday, 25 January 2015

Python 3.4.2 Part 5 Using input tutorial

>>> x=input("Enter a string")
Enter a string ayman
>>> x
' ayman'
>>> y=input("Enter your name: ")
Enter your name: Ayman
>>> x
' ayman'
>>> y
'Ayman'
>>> x=input("Enter a string")
Enter a string5
>>> x
'5'
>>> y=int(input("Enter a number"))
Enter a number8
>>> y
8
>>> y+int(x)
13



Now why we got an error in y+x??
please comment the reason

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)