1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
likoan [24]
3 years ago
15

What does the following loop do? val = 0 total = 0 while (val < 10): val = val + 1 total = total + val print(total)

Computers and Technology
1 answer:
labwork [276]3 years ago
4 0

Program in Python

val = 0

total = 0

while (val < 10):

   val = val + 1

   total = total + val

print(total)

Answer:

Prints the sum of the numbers from 1 to 10.

Explanation:

Given

The above lines of code

Required

What does the loop do?

To know what the loop does, we need to analyze the program line by line

The next two lines initialize val and total to 0 respectively

<em>val = 0 </em>

<em>total = 0 </em>

The following iteration is repeated while val is less than 10

while (val < 10):

This increases val by 1

   val = val + 1

This adds val to total

   total = total + val

This prints the value of total

print(total)

Note that the loop will be repeated 10 times and in each loop, val is incremented by 1.

The values of val is 1 to 10.

The summation of these value is then saved in total and printed afterwards.

<em>Hence, the loop adds numbers from 1 to 10</em>

You might be interested in
Write a program that lists all ways people can line up for a photo (all permutations of a list of strings). The program will rea
irinina [24]

Answer:

Check the explanation

Explanation:

Executable Code:

def all_permutations(permList, nameList):

   # Define the function to create a list

   # of all the permutations.

   def createPermutationsList(nameList):

       # Compute and store the length of the list.

       n = len(nameList)

       # Return an empty list if the size is 0.

       if n == 0:

           return []

       # Return the element if the size is 1.

       if n == 1:

           return [nameList]

       # Create an empty list to store the permutations.

       permList = []

       # Start the loop to traverse the list.

       for i in range(n):

           # Store the first element of the current list.

           first = nameList[i]

           # Compute the store the remaining list.

           remaining = nameList[:i] + nameList[i+1:]

           # Start the loop and call the function recursively

           # with the remaining list.

           for perm in createPermutationsList(remaining):

               # Append the element in the permutation list.

               permList.append([first] + perm)

       # Return the permutation list.

       return permList

   # Call the function to compute the permutation list

   # and store the result.

   permList = createPermutationsList(nameList)

   # Start the loop to display the values.

   for perm in permList:

       for val in perm:

           print(val, end = " ")

       print()

# Call the main() function.

if __name__ == "__main__":

   # Prompt the user to enter the input.

   nameList = input().split(' ')

   permList = []

   # Call the function to create and output

   # the permutations of the list.

   all_permutations(permList, nameList)

#endcode

3 0
3 years ago
What are benefits of using scenarios? check all that apply
barxatty [35]

Answer:

The benefit will be to "Reduce income volatility". The further explanation is given below.

Explanation:

  • The scenario could become theoretical, linear, or non-linear historical or conceptual.
  • Eventually, through the utilization of scenario analysis which helps shareholders avoiding looking for someone to blame and find investment opportunities which might improve equity returns and rising income fluctuations.

So that the above will be the right answer.

8 0
3 years ago
Can somoene explain the function of-<br><br>def __init__():<br><br>In python programming language​
JulsSmile [24]

Answer:

def is a keyword used to define a function, placed before a function name provided by the user to create a user-defined function

__init__ is one of the reserved methods in Python. In object oriented programming, it is known as a constructor. Python will call the __init__() method automatically when you create a new object of a class, you can use the __init__() method to initialize the object’s attributes.

Example code:

class Person:

 def __init__(self, name, age):

   self.name = name

   self.age = age

p1 = Person("John", 36)

print(p1.name)

print(p1.age)

Summary

  • Use the __init__() method to initialize the instance attributes of an object.
  • The __init__() doesn’t create an object but is automatically called after the object is created.
8 0
3 years ago
the actual use and implementation of computer started after third generation justify this statement in your own words.​
cestrela7 [59]

Answer:

BLACK LIVES DONT MATTER

Explanation:

6 0
2 years ago
What type of device is a keyboard?<br><br> Input<br> Memory<br> Output<br> Storage
Sever21 [200]

Answer:

a keyboard is an input device

8 0
3 years ago
Read 2 more answers
Other questions:
  • All of the following statements correctly describe an advantage or disadvantage associated with the use of Monte Carlo Analysis
    9·1 answer
  • Blackbaud is a company that supplies services and software designed for nonprofit organizations. Which type of e-commerce websit
    8·1 answer
  • Programmers refer to a sequence of characters as a ____.
    12·1 answer
  • Will give Brainiest and stuff to right answer[s].
    12·2 answers
  • 2. What is a cap? (0.5 points)
    9·1 answer
  • A user input is when the user interacts with the program by typing.<br> True<br> False
    11·2 answers
  • When is it appropriate to delete an entire row or column as opposed to deleting the data in the row or column
    14·1 answer
  • Some problems are better solved by a computer and some are better solved by humans.
    10·1 answer
  • A.m. client appears at the top of every page
    5·1 answer
  • How can the two independent clauses below be combined to form a correct complete sentence? Check all that apply.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!