Given a string str and a pattern pat. You need to check whether the pattern is present or not in the given string. 
Example 1:-
Input:
2
abcdefh
bcd
axzy
xy
Output:
Present
Not present
 
Your task:
You need to complete the function searchPattern() and you need to return a boolean value (True or False) according to the pattern present or not in the given string.
Returning True will represent the "Present" and False will be "Not Present".
 
Constraints:
1 <= T <= 100
1 <= |str| <= 100
1 <= |text| <= 100

Difficulty: EASY
Tags: Data structures
Skill types: Data structures

Starter code:
#User function Template for python3



def searchPattern(st, pat):

    # code here

Solutions:
def searchPattern(st, pat):
	if pat in st:
		return True
	else:
		return False


def searchPattern(st, pat):
	x = st.find(pat)
	if 0 <= x:
		return True
	return False


import re

def searchPattern(st, pat):
	c = re.findall(pat, st)
	if len(c) >= 1:
		return True
	return False


def searchPattern(st, pat):
	if pat in st:
		return 1
	return 0


def searchPattern(st, pat):
	if st.find(pat) != -1:
		return 1
	return 0


def searchPattern(st, pat):
	pos = st.find(pat)
	if pos == -1:
		return False
	return True


def searchPattern(st, pat):
	wstart = 0
	wend = 0
	count = 0
	temp = ''
	while wend < len(st):
		temp += st[wend]
		if wend - wstart + 1 == len(pat):
			if pat == temp:
				count += 1
				break
			else:
				res = temp[1:]
				wstart += 1
				temp = res
		wend += 1
	if count == 1:
		return True
	return False


def searchPattern(st, pat):
	s = st.count(pat)
	if s > 0:
		return True
	return False


def searchPattern(st, pat):
	for i in range(len(st) - len(pat) + 1):
		if st[i:i + len(pat)] == pat:
			return 1
	return 0


def searchPattern(st, pt):
	st_len = len(st)
	pt_len = len(pt)
	window = st[0:pt_len]
	if window == pt:
		return True
	for i in range(1, st_len):
		if i + pt_len > st_len:
			break
		window = st[i:i + pt_len]
		if window == pt:
			return True
	return False


def searchPattern(st, pt):
	st_len = len(st)
	pt_len = len(pt)
	for i in range(len(st)):
		check = ''
		i_pt = 0
		i_st = i
		while i_st < st_len and i_pt < pt_len and (st[i_st] == pt[i_pt]):
			check += pt[i_pt]
			if check == pt:
				return True
			i_pt += 1
			i_st += 1
	return False


def searchPattern(st, pt):
	if pt in st:
		return True
	return False


def searchPattern(st, pat):
	if len(pat) > len(st):
		return False
	n = len(pat)
	sliding_str = st[0:n]
	if sliding_str == pat:
		return True
	else:
		for i in range(1, len(st) - n + 1):
			sliding_str = sliding_str[1:]
			sliding_str += st[i + n - 1]
			if sliding_str == pat:
				return True
		return False


def searchPattern(st, pat):
	return pat in st


def searchPattern(st, pat):
	(m, n) = (len(st), len(pat))
	for i in range(m - n + 1):
		for j in range(n):
			if pat[j] != st[i + j]:
				break
		else:
			return 1
	return 0


def searchPattern(st, pat):
	window = len(pat)
	length = len(st)
	slides = length - window + 1
	for i in range(slides):
		if st[i:window] == pat:
			return True
		window += 1
	return False


import re

def searchPattern(st, pat):
	if len(re.findall(pat, st)) > 0:
		return True
	else:
		return False


def searchPattern(st, pat):
	l = len(st)
	l1 = len(pat)
	for i in range(l - l1 + 1):
		if st[i:i + l1] == pat:
			return True
	return False


def searchPattern(s, pat):
	count = 0
	j = 0
	for i in range(len(s) - len(pat) + 1):
		if s[i] == pat[0]:
			j = 1
			while j < len(pat):
				if s[i + j] != pat[j]:
					break
				j += 1
			if j == len(pat):
				return True
	return False


def searchPattern(str, pat):
	n = len(str)
	m = len(pat)
	for i in range(n - m + 1):
		j = 0
		while j < m:
			if str[i + j] != pat[j]:
				break
			j += 1
		if j == m:
			return True
	return False


def searchPattern(s, p):
	n = len(s)
	m = len(p)
	arr = badchar(p)
	shift = 0
	while shift <= n - m:
		j = m - 1
		while j >= 0 and p[j] == s[shift + j]:
			j -= 1
		if j < 0:
			return True
		else:
			shift += max(1, j - arr[ord(s[shift + j])])
	return False

def badchar(s):
	bad = [0] * 256
	for i in range(len(s)):
		bad[ord(s[i])] = i
	return bad


def searchPattern(st, pat):
	n = len(st)
	m = len(pat)
	if m > n:
		return False
	for i in range(n):
		k = st[i:m + i]
		if k == pat:
			return True
	return False


def searchPattern(st, pat):
	s = st.replace(pat, '')
	if len(s) == len(st):
		return 0
	else:
		return 1


def searchPattern(txt, pat):
	bad = [-1] * 256
	n = len(txt)
	m = len(pat)
	for i in range(m):
		bad[ord(pat[i])] = i
	s = 0
	while s <= n - m:
		j = m - 1
		while j >= 0 and pat[j] == txt[s + j]:
			j = j - 1
		if j < 0:
			return True
			if s + m < n:
				s = s + (m - bad[ord(txt[s + m])])
			else:
				s = s + 1
		else:
			s = s + max(1, j - bad[ord(txt[s + j])])
	return False


def searchPattern(st, pat):
	a = len(pat)
	t = []
	if len(pat) > len(st):
		return False
	elif len(pat) == len(st) and st != pat:
		return False
	elif len(pat) == len(st) and st == pat:
		return True
	else:
		for i in range(0, len(st) - a + 1):
			if st[i:i + a] == pat:
				t.append(1)
			else:
				t.append(0)
	if 1 in t:
		return True
	else:
		return False


def searchPattern(st, pat):
	arr = [0] * (len(pat) + 1)
	map = {}
	for i in range(len(pat)):
		if pat[i] in map.keys():
			arr[i + 1] = map[pat[i]]
		map[pat[i]] = i + 1
	(l, r) = (0, 0)
	while l < len(st):
		if st[l] == pat[r]:
			l += 1
			r += 1
		elif r == 0:
			l += 1
		else:
			r = arr[r]
		if r == len(pat):
			return True
	return False


def searchPattern(a, b):
	if b in a:
		return True
	return False


def searchPattern(st, pat):
	for i in range(len(st) - len(pat) + 1):
		found = True
		for j in range(len(pat)):
			if st[i + j] != pat[j]:
				found = False
				break
		if found:
			return True
	return False


def searchPattern(st, pat):
	n = len(st)
	m = len(pat)
	if m > n:
		return False
	for i in range(n - m + 1):
		flag = True
		for j in range(m):
			if st[i + j] != pat[j]:
				flag = False
				break
		if flag == True:
			return True
	return False


def searchPattern(st, pat):
	if st.__contains__(pat):
		return True
	else:
		return False


def searchPattern(st, pat):
	l_s = len(st)
	l_p = len(pat)
	for i in range(0, l_s - l_p + 1):
		j = i
		k = 0
		while st[j] == pat[k]:
			j = j + 1
			k = k + 1
			if k == l_p:
				return True
	return False


def searchPattern(st, pat):
	no_of_char = 256
	n = len(st)
	m = len(pat)
	badChar = [-1] * no_of_char
	for i in range(m):
		value = pat[i]
		badChar[ord(value)] = i
	s = 0
	while s <= n - m:
		j = m - 1
		while j >= 0 and pat[j] == st[s + j]:
			j = j - 1
		if j < 0:
			return True
		else:
			s = s + max(1, j - badChar[ord(st[s + j])])
	return False


def searchPattern(st, pat):
	lo = 0
	hi = len(pat) - 1
	n = len(st)
	while hi < n:
		if st[lo:hi + 1] == pat:
			return 1
		lo += 1
		hi += 1
	return 0


def searchPattern(st, pat):
	l = 0
	r = len(pat)
	while r <= len(st):
		if st[l:r] == pat:
			return True
		l += 1
		r += 1
	return False


def searchPattern(s, p):
	k = len(p)
	s1 = 0
	for i in range(len(s)):
		if s[i:i + k] == p:
			s1 = 98
			return True
	if s1 != 98:
		return False


def searchPattern(st, pat):
	i = j = 0
	n = len(st)
	m = len(pat)
	while i < n:
		if j - i < 0:
			j += 1
		elif st[i:j + 1] == pat:
			return True
		elif j - i > m - 1:
			i += 1
		elif st[i] == pat[0] and j < n - 1:
			j += 1
		else:
			i += 1
	return False


def searchPattern(st, pat):
	lps = compute_lps(pat)
	(N, M) = (len(st), len(pat))
	(i, j) = (0, 0)
	while N - i >= M - j:
		if st[i] == pat[j]:
			i += 1
			j += 1
			if j == M:
				return True
		elif j != 0:
			j = lps[j - 1]
		else:
			i += 1
	return False

def compute_lps(pat):
	lps = [0] * len(pat)
	L = 0
	i = 1
	while i < len(pat):
		if pat[i] == pat[L]:
			L += 1
			lps[i] = L
			i += 1
		elif L != 0:
			L = lps[L - 1]
		else:
			lps[i] = 0
			i += 1
	return lps


def searchPattern(st, pat):
	try:
		return True if st.index(pat) > -1 else False
	except:
		return False


def searchPattern(st, pat):
	if len(st) < len(pat):
		return False
	s = 0
	e = len(pat) - 1
	while e < len(st):
		if st[s:e + 1] == pat:
			return True
		s += 1
		e += 1
	return False


def searchPattern(st, pat):
	import re
	x = re.search(pat, st)
	if x is None:
		return False
	else:
		return True


def searchPattern(st, pat):
	j = 0
	m = len(pat)
	for i in range(len(st)):
		tmp = st[i:i + m]
		if tmp == pat:
			return True
	return False


def searchPattern(st, pat):
	i = 0
	j = len(pat)
	if j > len(st):
		return False
	while j <= len(st):
		if st[i:j] == pat:
			return True
		i += 1
		j += 1
	return False