1/14
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Type of variable returned by the define function [8]
List
Slicing and Modifying a String
result = text[8:].upper() + text[0]
result = (text[2:] + text[0]).replace('d', 'rat')
result = text[0:12].upper() + text[-1]
result = text[8:].lower() + text[0]
result = elements[0:5] + [elements[-1]]
result = elements[2:]
result.append(elements[0])
result.pop(2)
Arbitrary Math Formulas
n = len(xx)
result = float(sum((x**(n - 2)) / (x ** 2) for x in xx))
Group as Maximum
yy = [max(xx[i:i+5]) for i in range(0, len(xx), 5)]
Return a List of Parameters that Fit the Specified Conditions
def list_make(a, b, c):
return [x for x in (a, b, c) if x < -2]
def list_make(a, b, c):
return [num for num in (a, b, c) if 0 < num < 5]
Add the Multi-Dimensional Coordinates after Squaring
result = sum(int(x)**2 for x in coords.split(','))
Slicing and Modifying a List
result = elements[2:] + [elements[0]]
result.insert(2, 56)
Temperature Checks
def temp_check(temp):
if temp > 79:
return "Impossibly hot"
elif temp < 49:
return "Too cold!"
elif (79 - temp) < 5 or (temp - 49) < 5:
return "Somewhat questionable"
else:
return "Great!"
Add sqrt of multi dimensional coords
result = sum(math.sqrt(int(num)) for num in coords.split(','))
Joining Strings
yy = [";".join(xx[i:i+5]) for i in range(0, len(xx), 5)]
Group as Averages
yy = [sum(xx[i:i+4]) / 4 for i in range(0, len(xx), 4)]
FizzBuzz
def fizzbuzz_family(num):
if num % 3 = 0 and num % 5 = 0:
return "FizzBuzz"
elif num % 3 == 0:
return "Fizz"
elif num % 5 == 0:
return "Buzz"
else:
return num
Multiply multi dimensional coords
result = 1.0
for num in coords.split('/'):
result *= (int(num) / 2)
Average the cubed multi-dimensional coords
nums = coords.split(';')
result = sum(float(num) ** 3 for num in nums) / len(nums)
Group as Minimum
yy = [min(xx[i:i+4]) for i in range(0, len(xx), 4)]