Skip to main content
Contents
Search Book
Search Results:
No results.
Readability settings Prev Up Next Scratch ActiveCode Profile
title here
\(
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 16.4 Write the Code
Checkpoint 16.4.1 .
Write a function named
sum_to_n(n) that returns the sum from 1 to
n.
Checkpoint 16.4.2 .
Write a function named
count_evens(numbers) that returns how many values in the list are even.
Checkpoint 16.4.3 .
Write a function named
find_max(numbers)that returns the largest number in the list. Do not use
max().
Checkpoint 16.4.4 .
Write a function named
multiplication_table(n) that prints the multiplication table for
n from 1 through 10.
Checkpoint 16.4.5 .
Write a function named
count_passing(scores) that counts how many scores are greater than or equal to 70.
Checkpoint 16.4.6 .
Write a function named
sum_greater_10(numbers) that computes the sum of numbers greater than 10.
Checkpoint 16.4.7 .
Write code to print this pattern using a loop:
*
**
***
****
*****
Checkpoint 16.4.8 .
Write a function named f
first_duplicate(numbers) that returns the first number that appears more than once. Return
None if there are no duplicates.
Checkpoint 16.4.9 .
Write a function
sublist_until_target(numbers, target) that returns a list of elements before the first occurrence of target. If the target is not found, return the entire list.
Checkpoint 16.4.10 .
Write a function count_words(text) that returns the number of words in the given text. Assume that words are separated by a single space.
Checkpoint 16.4.11 .
Write a function format_names(names) takes a list of strings and returns a single string with names separated by ", ".
Example: ["Ali", "Sam", "Jo"] --> "Ali, Sam, Jo"
Checkpoint 16.4.12 .
Write a function censor_word(text) that returns a new string of the text where every occurrence of "bad" is replaced with "***". Do not modify the original string.
Checkpoint 16.4.13 .
Write a function short_words(text) that takes string of text and returns a list of words with length β€ 3. Do not modify the original string.
Checkpoint 16.4.14 .
Write a function contains_word(text, word) that returns True if the exact word appears in the text. Otherwise returns False.
Checkpoint 16.4.15 .
Write a function contains_word(text, word) that returns True if the exact word appears in the text. Otherwise returns False.
You have attempted
of
activities on this page.