Riju21

31_practicce

May 12th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. # int to binary
  2. # ----------
  3.  
  4. # n = 110
  5. # print('in binary:', bin(n)[2:])
  6.  
  7. # # octal
  8. # # -------
  9.  
  10. # n1 = 10
  11. # print('in octal:', oct(n1)[2:])
  12.  
  13. # # hexa
  14. # # ---------
  15.  
  16. # n2 = 1111
  17. # print('in hexa:', hex(n2)[2:])
  18.  
  19. # # decimal
  20. # # ----------
  21.  
  22. # n4 = 111
  23. # print('in dec:', int(str(n4), 2))
  24.  
  25.  
  26. # find the index from where it begins in string
  27. # ---------------------------------------------
  28. # word = ['banana ana','banana ban',
  29. #         'aquickbrownfoxjumpsoverthelazydog fox', 'foobar foobar']
  30.  
  31.  
  32. # def check(i):
  33. #     toLi = i.split(' ')
  34. #     ans = ''
  35. #     searchVal = toLi[1]
  36. #     mainVal = toLi[0]
  37. #     ans = mainVal.find(searchVal)
  38. #     print(ans, end='')
  39. # for i in word:
  40. #     check(i)
  41. #     print('\n')  
  42.  
  43.  
  44. # total substr
  45. # ------------
  46.  
  47. word = ['banana ana', 'banana anna',
  48.         'fox aquickbrownfoxjumpsoverthelazydog', 'ddddd ddd', 'foobar foobar']
  49.  
  50. def check(i):
  51.     toli = i.split(' ')
  52.     search = toli[1]
  53.     main = toli[0]
  54.     res = main.count(search)
  55.     print(res, end=' ')
  56.  
  57. for i in word:
  58.     check(i)
  59.     print('\n')
Advertisement
Add Comment
Please, Sign In to add comment