diff --git a/ana.py b/ana.py new file mode 100644 index 0000000..4812fac --- /dev/null +++ b/ana.py @@ -0,0 +1,20 @@ +def count(): + s=input("Enter length ") + p=raw_input("enter word") + f=0 + flag=0 + l=[] + l=[] + for i in range(s): + st=raw_input("enter the word") + l.append(st) + print l + for i in l: + for j in range(len(i)): + for f in range(len(p)): + if i[j]==p[f]: + flag+=1 + if flag==len(p): + print i + flag=0 +count() diff --git a/bob.py b/bob.py new file mode 100644 index 0000000..3acc03b --- /dev/null +++ b/bob.py @@ -0,0 +1,14 @@ +# +# Skeleton file for the Python "Bob" exercise. +# +def hey(what): + if what[len(what)-1]=='?': + return "Sure" + elif len(str)>3: + for i in range(len(what)-1): + if what[i]=='!': + return 'Whoa, chill out!' + else: + return 'Whatever' + elif (what=='Bob'): + return 'Fine, Be that way!' diff --git a/clock.py b/clock.py new file mode 100644 index 0000000..e4e24e2 --- /dev/null +++ b/clock.py @@ -0,0 +1,49 @@ +class Clock: + def __init__(self, h, m): + self._hour = h + self._min = m + + while self._min >= 60: + self._min -= 60 + self._hour += 1 + + if self._hour > 23: + self._hour = self._hour % 24 + + while self._min < 0: + self._min += 60 + self._hour -= 1 + + if self._hour < 0: + self._hour = self._hour % 24 + + + + def __str__(self): + if self._hour < 10: + hour_str = '0' + str(self._hour) + else: + hour_str = str(self._hour) + if self._min < 10: + min_str = '0' + str(self._min) + else: + min_str = str(self._min) + + return hour_str + ":" + min_str + + def __eq__(self, other): + if self._hour != other._hour: return False + if self._min != other._min: return False + return True + + def add(self, m): + tot_min = (self._hour * 60) + self._min + tot_min += m + self._hour = (tot_min // 60) % 24 + self._min = tot_min % 60 + + def getHour(self): + return self._hour + + def getMinute(self): + return self._min diff --git a/hammer.py b/hammer.py new file mode 100644 index 0000000..ecf5b41 --- /dev/null +++ b/hammer.py @@ -0,0 +1,11 @@ +class hammer(object): + def dna(self,str1,str2): + self.str1=str1 + self.str2=str2 + j=0 + c=0 + for i in str1: + if i!=self.str2[j]: + c+=1 + j+=1 + print c diff --git a/pangram.py b/pangram.py new file mode 100644 index 0000000..935994c --- /dev/null +++ b/pangram.py @@ -0,0 +1,19 @@ +class pangram: + c=0 + flag=0 + def __str__(self,str): + self.str=str + self.check=self.def_pangram() + print self.check + def def_pangram(self): + for i in range(65,91): + for j in self.str: + if self.flag==0: + if (i==ord(j) or i+32==ord(j)): + self.flag+=1 + self.c+=1 + self.flag=0 + if self.c==26: + return "True" + else: + return "False"