Skip to content

Commit

Permalink
p44
Browse files Browse the repository at this point in the history
  • Loading branch information
Xuefeng-Zhu committed Jul 7, 2014
1 parent 2c4fe54 commit b8b9a93
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion 19-second-greatlow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def SecondGreatLow(arr):
newArr = sorted(set(arr))
return "%d %d", %(newArr[1], newArr[-2])
return "%d %d" %(newArr[1], newArr[-2])


# keep this function call here
Expand Down
2 changes: 1 addition & 1 deletion 24-swapcase.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def SwapCase(str):
return "".join[i.lower() if i.isupper() else i.upper() for i in str]
return "".join([i.lower() if i.isupper() else i.upper() for i in str])

# keep this function call here
# to see how to enter arguments in Python scroll down
Expand Down
6 changes: 3 additions & 3 deletions 43-prime-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Use the Parameter Testing feature in the box below to test your code with different arguments.
def is_Prime(n):
if n % 2 == 0:
return False
if n % 2 == 0:
return False
for i in xrange(3, int(n ** 0.5)+1, 2):
if n % i == 0:
return False
Expand All @@ -19,4 +19,4 @@ def PrimeChecker(num):

# keep this function call here
# to see how to enter arguments in Python scroll down
print PrimeChecker(raw_input())
print PrimeChecker(raw_input())
17 changes: 17 additions & 0 deletions 44-dash-insert2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
def DashInsertII(num):
result = ""
for i in str(num):
if (len(result)==0):
result += i
continue
if int(i)%2 == 1 and int(result[-1])%2==1:
result += "-" + i
elif int(i) != 0 and int(i)%2 == 0 and int(result[-1]) != 0 and int(result[-1])%2 == 0:
result += "*" + i
else:
result += i
return result

# keep this function call here
# to see how to enter arguments in Python scroll down
print DashInsertII(raw_input())

0 comments on commit b8b9a93

Please sign in to comment.