Skip to content

Commit f6ea44a

Browse files
committed
Changes from Mac
1 parent 1695293 commit f6ea44a

File tree

6 files changed

+133
-5
lines changed

6 files changed

+133
-5
lines changed

Collections/UniqueMaximumNumber.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ def testing(args):
66
if args.count(i) == 1:
77
uniq.append(i)
88
if len(uniq) != 0:
9-
print max(uniq)
9+
print(max(uniq))
1010
else:
11-
print "It seems, all the numbers are repeated!"
11+
print("It seems, all the numbers are repeated!")
12+
1213

1314
if __name__ == '__main__':
1415
a=int(input())
15-
b = list(raw_input())
16+
b = list(input())
1617
while True:
1718
try:
1819
b.remove(" ")
@@ -24,5 +25,5 @@ def testing(args):
2425
orgInput.append(int(i))
2526
else:
2627
pass
27-
print orgInput
28+
print(orgInput)
2829
testing(orgInput)

Excersise/Factorial.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,19 @@ def fa(n):
1111
f = f*i
1212
print (f)
1313

14+
15+
def fac(n):
16+
resp = 1
17+
givenInput = list(range(1, n+1))
18+
for i in givenInput:
19+
resp = resp * i
20+
21+
return resp
22+
23+
24+
1425
if __name__ == '__main__':
1526
print ("Enter a number to find the factorial!")
1627
getInput = int(input())
17-
fa(getInput)
28+
fa(getInput)
29+
fac(5)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
__author__ = 'Sanjay'
2+
3+
# A deque, also known as a double-ended queue, is an ordered collection of items similar to the queue.
4+
# It has two ends, a front and a rear, and the items remain positioned in the collection.
5+
# What makes a deque different is the unrestrictive nature of adding and removing items.
6+
# New items can be added at either the front or the rear.
7+
# Likewise, existing items can be removed from either end.
8+
# it does not require the LIFO and FIFO orderings that are enforced by those data structures.
9+
# It is up to you to make consistent use of the addition and removal operations.
10+
11+
# Deque() creates a new deque that is empty. It needs no parameters and returns an empty deque.
12+
13+
# addFront(item) adds a new item to the front of the deque. It needs the item and returns nothing.
14+
15+
# addRear(item) adds a new item to the rear of the deque. It needs the item and returns nothing.
16+
17+
# removeFront() removes the front item from the deque. It needs no parameters and returns the item. The deque is modified.
18+
19+
# removeRear() removes the rear item from the deque. It needs no parameters and returns the item. The deque is modified.
20+
21+
# isEmpty() tests to see whether the deque is empty. It needs no parameters and returns a boolean value.
22+
23+
# size() returns the number of items in the deque. It needs no parameters and returns an integer.
24+
25+
class Deque:
26+
def __init__(self):
27+
self.items = []
28+
29+
def addFront(self,item):
30+
self.items.append(item)
31+
32+
def addRear(self,item):
33+
self.items.insert(0,item)
34+
35+
def removeFront(self):
36+
self.items.pop()
37+
38+
def removeRear(self):
39+
self.items.pop(0)
40+
41+
def isEmpty(self):
42+
return self.items == []
43+
44+
def size(self):
45+
return len(self.items)
46+
47+
if __name__ == '__main__':
48+
d=Deque()
49+
print(d.isEmpty())
50+
d.addRear(4)
51+
d.addRear('dog')
52+
d.addFront('cat')
53+
d.addFront(True)
54+
print(d.size())
55+
print(d.isEmpty())
56+
d.addRear(8.4)
57+
print(d.removeRear())
58+
print(d.removeFront())

QDataStructure/RenamingAFile.py

Whitespace-only changes.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
__author__ = 'Sanjay'
2+
3+
#
4+
# Stack() creates a new stack that is empty. It needs no parameters and returns an empty stack.
5+
6+
# push(item) adds a new item to the top of the stack. It needs the item and returns nothing.
7+
8+
# pop() removes the top item from the stack. It needs no parameters and returns the item. The stack is modified.
9+
10+
# peek() returns the top item from the stack but does not remove it. It needs no parameters. The stack is not modified.
11+
12+
# isEmpty() tests to see whether the stack is empty. It needs no parameters and returns a boolean value.
13+
14+
# size() returns the number of items on the stack. It needs no parameters and returns an integer.
15+
16+
17+
#The above information gives you clear understanding on Stacks Predefined functions.
18+
class Stack:
19+
def __init__(self):
20+
self.items = []
21+
22+
def push(self, newItem):
23+
self.items.append(newItem)
24+
25+
def pop(self):
26+
self.items.pop()
27+
28+
def isEmpty(self):
29+
return self.items == []
30+
31+
def size(self):
32+
return len(self.items)
33+
34+
def show(self):
35+
print self.items
36+
return self.items
37+
38+
def peek(self):
39+
return self.items[0]
40+
41+
def size(self):
42+
return len(self.items)
43+
44+
45+
if __name__ == '__main__':
46+
obj = Stack()
47+
obj.push(13)
48+
obj.show()
49+
obj.push('sanjay')
50+
obj.push('surya')
51+
obj.push(45)
52+
obj.show()
53+
obj.pop()
54+
obj.show()
55+
obj.size()
56+
obj.isEmpty()
57+
obj.show()

QDataStructure/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)