Deprecated: Return type of WPCF7_FormTag::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/cscircles/dev/www/wordpress/wp-content/plugins/contact-form-7/includes/form-tag.php on line 396
Deprecated: Return type of WPCF7_FormTag::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/cscircles/dev/www/wordpress/wp-content/plugins/contact-form-7/includes/form-tag.php on line 388
Deprecated: Return type of WPCF7_FormTag::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/cscircles/dev/www/wordpress/wp-content/plugins/contact-form-7/includes/form-tag.php on line 382
Deprecated: Return type of WPCF7_FormTag::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/cscircles/dev/www/wordpress/wp-content/plugins/contact-form-7/includes/form-tag.php on line 400
Deprecated: Return type of WPCF7_Validation::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/cscircles/dev/www/wordpress/wp-content/plugins/contact-form-7/includes/validation.php on line 78
Deprecated: Return type of WPCF7_Validation::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/cscircles/dev/www/wordpress/wp-content/plugins/contact-form-7/includes/validation.php on line 72
Deprecated: Return type of WPCF7_Validation::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/cscircles/dev/www/wordpress/wp-content/plugins/contact-form-7/includes/validation.php on line 59
Deprecated: Return type of WPCF7_Validation::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/cscircles/dev/www/wordpress/wp-content/plugins/contact-form-7/includes/validation.php on line 82 15B: Python Pushups | Computer Science Circles
[Introductory Python Lessons]
15B: Python Pushups
Exercises 15A, 15B, and 15C can be completed in any order.
In this lesson, we give several medium-size exercises combining tools learned in earlier lessons.
In the next exercise, use the methods string.split(), which removes the spaces from a word and returns a list of the words it contains, and string.lower() which converts a string to lower case. For example,
"Split these words!".split() returns the list ["Split", "these", "words!"]
"LOWERCase".lower() returns "lowercase"
Note: split() can accept further options to split in other ways; see the documentation.
Suppose you have n flavours of ice cream, and want to make a sundae using exactly k of those flavours. How many different flavour combinations are possible? For example, if n=4 and k=2, there are 6 possibilities:
(1) A and B, (2) A and C, (3) A and D, (4) B and C, (5) B and D, (6) C and D.
(for example here the flavours are Apricot, Blueberry, Chocolate, and Date).
Similarly, you could be choosing 2 people out of 4 (Al, Bob, Carol, Di) to make a committee. How many ways can the committee be built? The answer would still be 6. The next problem is about computing this number.
In mathematics, the number you computed in the previous exercise is usually written
and called "n choose k." There are many interesting facts about these values such as
and
This is the end of our exercise session; you can move on to another lesson.