diff --git a/website/app/snippets b/website/app/snippets index e33435ef8..28ea1fabc 100644 --- a/website/app/snippets +++ b/website/app/snippets @@ -1 +1,8 @@ -bubble_sort \ No newline at end of file +count_vowels +byte_size +capitalize +capitalize_every_word +decapitalize +palindrome +is_upper_case +is_lower_case \ No newline at end of file diff --git a/website/app/templates/index.html b/website/app/templates/index.html index 1ec679e81..dfb026db0 100644 --- a/website/app/templates/index.html +++ b/website/app/templates/index.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% block content %}

Math

average

+{% block content %}

Math

average

Already implemented via 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.

@@ -290,6 +290,22 @@ insertionsort(lst) print('Sorted %s' %lst) # sorted [2, 3, 4, 6, 7, 9]
+

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.

@@ -383,22 +399,6 @@ is_lower_case('a3@$') # True is_lower_case('Ab4') # False
-

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]
-
-
{% endblock %} \ No newline at end of file