def countup_str(end):
---
out = ""
---
for i in range(1, end + 1):
---
for i in range(1, end): #paired
---
out = out + str(i)
---
out = out + i #paired
---
return out
def reverse(s):
---
out = ""
---
for i in range(len(s) - 1, -1, -1):
---
for i in range(len(s), -1, -1): #paired
---
out = out + s[i]
---
out = s[i] + out #paired
---
return out
def countdown_str(start):
---
out = ""
---
for i in range(start, -1, -1):
---
for i in range(start, 0, -1): #paired
---
out = out + str(i)
---
out = out + i #paired
---
return out
Create the function, odd_sum(start, increment, end), to return the sum of all of the odd numbers between start (inclusive) and end (exclusive) using a range with increment. For example, if start is 1, increment is 2, and end is 6, the returned sum should be (1 + 3 + 5) which is 9.
def odd_sum(start, increment, end):
---
sum = 0
---
for number in range(start, end, increment):
---
for numbers in range(start, increment, end): #paired
---
sum = sum + number
---
return sum
Write the function, odd_sum(start, increment, end), to return the sum of all of the odd numbers between start (inclusive) and end (exclusive) using a range with increment. For example, if start is 1, increment is 2, and end is 6, the returned sum should be (1 + 3 + 5) which is 9.
Create the function, sum_of_range(start, end), to return the sum of all numbers between the start and end inclusive. For example, if start is 0 and end is 5, the returned sum should be (0 + 1 + 2 + 3 + 4 + 5) which is 15.
Write the function, sum_of_range(start, end), to return the sum of all numbers between the start and end inclusive. For example, if start is 0 and end is 5, the returned sum should be (0 + 1 + 2 + 3 + 4 + 5) which is 15.
Create the function, copy_till_gt_value(s,value), to return a copy of the string s with all the digits in the string until it finds a digit greater than the passed value. For example, copy_till_gt_value("1357", 5) would return β135β.
Write the function, copy_till_gt_value(s,value), to return a copy of the string s with all the digits in the string until it finds a digit greater than the passed value. For example, copy_till_gt_value("1357", 5) would return β135β.
Create the function, count_last2(s), to return a count of the number of times the last two characters appears in the string s. If there are less than 2 characters in s return 0. For example, count_last2("hixxhi") returns 2, count_last2("axxxaaxx") returns 3, and count_last2('x') returns 0.
Write the function, count_last2(s), to return a count of the number of times the last two characters appears in the string s. If there are less than 2 characters in s return 0. For example, count_last2("hixxhi") returns 2, count_last2("axxxaaxx") returns 3, and count_last2('x') returns 0.
Create the function, list_to_5(n), so that while the integer n is less than 5, add n to a list to return and increment n by 1. Then return the list. For example, if n is 0, then the function should return [0, 1, 2, 3, 4].
Write the function, list_to_5(n), so that while the integer n is less than 5, add n to a list to return and increment n by 1. Then return the list. For example, if n is 0, then the function should return [0, 1, 2, 3, 4].
Create the function, water_quality(pHvalues), to return a float for the average pH of water samples in the list pHvalues. For example, if pHvalues is [7.0, 8.2, 6.7, 7.5, 8.0, 7.2], then the function should return 7.433333333333334.
def water_quality(pHvalues):
---
total = 0
---
for number in pHvalues:
---
total = total + number
---
total = total * number #paired
---
average = total / len(pHvalues)
---
return average
Write the function, water_quality(pHvalues), to return a float for the average pH of water samples in the list pHvalues. For example, if pHvalues is [7.0, 8.2, 6.7, 7.5, 8.0, 7.2], then the function should return 7.433333333333334.