logo

Crowdly

Task 3: Range Function Practice Objective: Use Python’s range() to control lo...

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

Task 3: Range Function Practice

Objective: Use Python’s range() to control loops.

Instructions:

  1. Write a Python function range_sum(n) that:

    • Uses a for loop and range() to add numbers from 0 up to n-1.

  2. Modify the function to:

    • Use a while loop instead of a for loop.

    • Use a bottom-check loop (while True + break) structure to achieve the same.

Example Input:

n = 5

Expected Output:

Sum = 10

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

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

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