Math
average
+{% block content %}
+
-
{% endblock %}
\ No newline at end of file
Math
average
statistics.mean. statistics.mean takes an array as an argument whereas this function takes variadic arguments.
Returns the average of two or more numbers.
Takes the sum of all the args and divides it by len(args). The second argument 0.0 in sum is to handle floating point division in python2.
bubble_sort
+
+
Bubble_sort uses the technique of comparing and swapping
+ +def bubble_sort(lst): + for passnum in range(len(lst) - 1, 0, -1): + for i in range(passnum): + if lst[i] > lst[i + 1]: + temp = lst[i] + lst[i] = lst[i + 1] + lst[i + 1] = temp+ +
lst = [54,26,93,17,77,31,44,55,20]
+bubble_sort(lst)
+print("sorted %s" %lst) # [17,20,26,31,44,54,55,77,91]
+String
count_vowels
Retuns number of vowels in provided string.
Use a regular expression to count the number of vowels (A, E, I, O, U) in a string.
list
bubble_sort
-
-
Bubble_sort uses the technique of comparing and swapping
- -def bubble_sort(lst): - for passnum in range(len(lst) - 1, 0, -1): - for i in range(passnum): - if lst[i] > lst[i + 1]: - temp = lst[i] - lst[i] = lst[i + 1] - lst[i + 1] = temp- -
lst = [54,26,93,17,77,31,44,55,20]
-bubble_sort(lst)
-print("sorted %s" %lst) # [17,20,26,31,44,54,55,77,91]
-