Python Nested If else ,if elif ,Logical and Bitwise Operators

Write a program that performs the following

 
      If a user enters D print Delhi 
      If a user enters C print Chennai ,If a user enters M print Mumbai . For any other 
      Input print “Enter only D C or M as your input. 

choice=input("Enter your choice")
if choice=="D":
   print("Delhi")
elif choice=="C":
   print("Chennai")
elif choice=="M":
   print("Mumbai")
else:
   print("Enter only D C or M as input")
    
Output

Write an program to check if a given number is a magic number – For any 4 digit number as your input check if the sum of the square of the first two digits and the square of the last two digits is equal to the given number. For Example if input is 8833 then 882 + 332 = 8833

 
      n=int(input("enter the number "))
      last_two_digits=n%100
      first_two_digits=n//100
      if (last_two_digits**2) + (first_two_digits**2)==n:
          print("its a magic number")
      else:
          print("not a magic number")
    
Output

Print the fibonacci series up to n terms as entered by the user

 
      #fibonacci
      first=0
      second=1
      n=int(input("enter the number of terms >0 "))
      if n==1:
          print(first)
      elif n==2:
          print(first,second)
      else:
          print(first,second,end=" ")
          for i in range(2,n):
              current=first+second
              print(current,end=" ")
              second=current
              first=second
    
Output