Lab – Python Basic

Open a shell (standard/ipython) and type the following statements:

numbers and statements

  • 213
  • 1+2
  • 5*(10+1)

integer and float

  • 5/2
  • 5//2
  • 5/2.0
  • 5/2*1.0
  • 5 / float(2)
  • 3/5+2
  • 1.0*3/5+2

modulo

  • 10%2
  • 10%3
  • 10%6
  • 5.23 % 2
  • 
5.4 % 0.5

power

  • 3**2
  • 100**0.5

binary/oct/hex

  • 0x64
  • 032
  • 0b1101
  • 0xf + 0b1010

Strings

  • “Hello world”
  • print(“Hello world”)
  • print(‘Hello world’)
  • print (“What’s up ?”)
  • print (‘The sign said: “No smoking”‘)
  • print (“hello\nworld”)
  • print (r”hello\nworld”)

Write the following script

x=input("enter num") 
y=input("enter num")
z=int(x)+int(y)
print ('res=' + str(z))

test it using python shell