logo

Crowdly

Task 1: Looping and Accumulator Variable Objective: Practice loop control and...

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

Task 1: Looping and Accumulator Variable

Objective: Practice loop control and accumulator patterns using Python.

Instructions:

  1. Write a Python function sum_list_elements(lst) that:

    • Takes a list of integers as input.

    • Returns the sum of all elements using a for loop and an accumulator variable.

  2. Extend the function to count how many elements in the list are greater than 10 using a separate counter.

Example Input:

[3, 11, 15, 7, 2, 18]

Expected Output:

Sum: 56

Count of numbers > 10: 3

Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на iitjbsc.futurense.com?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!