Avatar ·

While loop "Sum of a sequence of numbers"

📁 Advanced Python Topics, AI

I started learning Python, sometimes I get terrible brain freezes.
A number of tasks with this loop seem to be solved and understood,
but here I can't figure out how to formulate the solution?

Determine the sum of all elements of a sequence that ends with the number 0.
In this and the following tasks, numbers after zero are not considered.
def hasn't been covered in this course yet, I don't know what it is.
I.e., the task needs to be solved within the scope of the material studied:

  1. Input-output, arithmetic operations
  2. Conditional statement
  3. Operations with integers and real numbers
  4. For loop
  5. Strings
  6. While loop

I just don't understand something.

i = 0while 

                    
                
Avatar ·

Why not refer to:

The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses, brackets and braces. Long lines can be broken over multiple lines by wrapping expressions in parentheses. These should be used in preference to using a backslash for line continuation.

The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses, brackets and braces. Long lines can be broken over multiple lines by wrapping expressions in parentheses. These should be used in preference to using a backslash for line continuation.

Example:

                                

Log in to leave an answer

Blogs