Skip to content
Open

5 #80

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions ana.py
Original file line number Diff line number Diff line change
@@ -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()
14 changes: 14 additions & 0 deletions bob.py
Original file line number Diff line number Diff line change
@@ -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!'
49 changes: 49 additions & 0 deletions clock.py
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions hammer.py
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions pangram.py
Original file line number Diff line number Diff line change
@@ -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"