Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # int to binary
- # ----------
- # n = 110
- # print('in binary:', bin(n)[2:])
- # # octal
- # # -------
- # n1 = 10
- # print('in octal:', oct(n1)[2:])
- # # hexa
- # # ---------
- # n2 = 1111
- # print('in hexa:', hex(n2)[2:])
- # # decimal
- # # ----------
- # n4 = 111
- # print('in dec:', int(str(n4), 2))
- # find the index from where it begins in string
- # ---------------------------------------------
- # word = ['banana ana','banana ban',
- # 'aquickbrownfoxjumpsoverthelazydog fox', 'foobar foobar']
- # def check(i):
- # toLi = i.split(' ')
- # ans = ''
- # searchVal = toLi[1]
- # mainVal = toLi[0]
- # ans = mainVal.find(searchVal)
- # print(ans, end='')
- # for i in word:
- # check(i)
- # print('\n')
- # total substr
- # ------------
- word = ['banana ana', 'banana anna',
- 'fox aquickbrownfoxjumpsoverthelazydog', 'ddddd ddd', 'foobar foobar']
- def check(i):
- toli = i.split(' ')
- search = toli[1]
- main = toli[0]
- res = main.count(search)
- print(res, end=' ')
- for i in word:
- check(i)
- print('\n')
Advertisement
Add Comment
Please, Sign In to add comment