<jupyter_start><jupyter_text>Project Euler: Problem 2 Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 0 and 1, the first 12 terms will be:0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.                                                                                                                                                                                             Initialize total to zero and start fibonacci sequence with 0 and 1<jupyter_code>total = 0
fib = [0,1]<jupyter_output><empty_output><jupyter_text>Using a while loop, add the last two numbers in the fibonacci sequence until the last number reaches 3,000,000.  I did not use 4,000,000 because then the sum of the last two numbers exceed 4,000,000.<jupyter_code>while fib[-1] < 3000000:
    fib.append(fib[-1] + fib[-2])<jupyter_output><empty_output><jupyter_text>Using a lambda and filter, print the sum of the even-valued terms of the fibonacci sequence<jupyter_code>print(sum(filter(lambda x: x % 2, fib)))<jupyter_output>4613732<jupyter_text>Success! (Checked answer by hand)<jupyter_code># This cell will be used for grading, leave it at the end of the notebook.<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07407407407407407, 'fraction_numerical': 0.04888888888888889, 'mean_word_length': 2.681198910081744, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '457177', 'license': 'MIT', 'n_tokens_mistral': 426, 'n_tokens_neox': 366, 'n_words': 155, 'path': 'assignments/assignment02/ProjectEuler2.ipynb', 'repo_name': 'jegibbs/phys202-2015-work', 'size': '1350'}