Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function sum_5_consecutive that takes a list of numbers as input and returns True if there are 5 consecutive numbers in the list that

image text in transcribed

Write a function sum_5_consecutive that takes a list of numbers as input and returns True if there are 5 consecutive numbers in the list that sum to zero. Otherwise it returns False. The function should also return False if the list has less than 5 elements Solve this in two ways: 1.for loop (over indices of the list) 2. while loop (over indices of the list) In both cases you need to think about "stopping condition" in order to avoid "Indexerror: list index out of range" 3. Test your function with at least the examples below >um_5_consecutive ([2,3,3,2,4,6]) True >>> sum_5_consecutive ([10,1,1,4,2,10,13]) False >> sum_5_consecutive ([2,1,3,3,3,2,7,4,6]) True >>> sum_5_consecutive ([]) False >> sum_5_consecutive ([1,1,0]) False

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

1. How do most insects respire ?

Answered: 1 week ago

Question

Who is known as the father of the indian constitution?

Answered: 1 week ago

Question

1.explain evaporation ?

Answered: 1 week ago

Question

Who was the first woman prime minister of india?

Answered: 1 week ago

Question

Explain the concept of going concern value in detail.

Answered: 1 week ago