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
Identify the operation which is NOT one of the parts of the fivebasic set operations in relational algebra?
wariber [46]

Answer:

Join

Explanation:

Five basic set operators in relational algebra are as follows:

  • Selection - tuple selection
  • Projection - extract columns
  • Cartesian product - cross product of relations
  • Set union - union of two relations
  • Set difference - minus operation on two relations

As we can see, Join is not part of the basic set operations but it is implemented using the Cartesian Product operator.

5 0
2 years ago
The last time period the federal government of these United States ran a budget surplus was ________.
lina2011 [118]
Your answer is a 1998-2001
3 0
2 years ago
The factorial of n is equal to ______.
alexdok [17]

Answer:

n! = n*(n-1)*(n-2)*(n-3)* ... *2*1

Explanation:

The factorial operator is simply a mathematical expression of the product of a stated integer and all integers below that number down to 1.  Consider these following examples:

4! = 4 * 3 * 2 * 1

4! = 12 * 2 * 1

4! = 24

6! = 6 * 5 * 4 * 3 * 2 * 1

6! = 30 * 4 * 3 * 2 * 1

6! = 120 * 3 * 2 * 1

6! = 360 * 2 * 1

6! = 720

So, the factorial of n would follow the same as such:

n! = n * (n-1) * (n-2) * ... * 2 * 1

Cheers.

5 0
2 years ago
Objectives ** WILL GIVE BRAINIST PLEASE**
mamaluj [8]

Answer:

of which std this question is

8 0
2 years ago
Read 2 more answers
c Write a program that simulates a magic square using 3 one dimensional parallel arrays of integer type. Each one the arrays cor
Komok [63]

Answer:

hope this helps and do consider giving a brainliest to the ans if it helped.

Explanation:

//program to check if the entered grid is magic square or not

/**c++ standard libraries

*/

#include<bits/stdc++.h>

using namespace std;

/**function to check whether the entered grid is magic square or not

*/

int isMagicSquare(int arr[3][3]){

  int i,j,sum=0,sum1=0,rsum,csum;

  for(i=0;i<3;i++){

      sum+=arr[i][i];

      sum1+=arr[i][2-i];

  }

  if(sum!=sum1){

      return 0;

  }

 

  for(i=0;i<3;i++){

      rsum=0;

      csum=0;

      for(j=0;j<3;j++){

          rsum+=arr[i][j];

          csum+=arr[j][i];

      }

      if(sum!=rsum){

          return 0;

      }

      if(sum!=csum){

          return 0;

      }

  }

  return 1;

}

/** main function to get user entries and

* call function

* and print output

*/

int main(){

  int i,j,arr[3][3]={0};

  for(i=0;i<3;i++){

      for(j=0;j<3;j++){

          cout<<"Enter the number for row "<<i<<" and column "<<j<<" : ";

          cin>>arr[i][j];

      }

  }

  int ret = isMagicSquare(arr);

  if(ret==1){

      cout<<"This is a Lo Shu magic square"<<endl;

  }

  else{

      cout<<"This is not a Lo Shu magic square"<<endl;

  }

  return 0;

}

7 0
2 years ago
Other questions:
  • Can you give me a free neon legendary pet in Adopt Me on Roblox!!!​ my user is: IamNathan215
    15·2 answers
  • Write a program that prompts the user to enter an equation in the form of 10 5, or 10-5, or 1*5, or 13/4, or 13%4. The program s
    6·1 answer
  • What piece of software tells the operating system how to use a specific hardware device?
    14·1 answer
  • Write a date transformer program using an if/elif/else statement to transform a numeric date in month/day format to an expanded
    14·1 answer
  • When using color in a computer - generated presentation aids you should use?
    7·1 answer
  • Your wireless network consists of multiple 802.11n access points that are configured as follows: SSID (hidden): CorpNet Security
    8·1 answer
  • The process of arranging the item of a column in some sequence or order is known as?
    12·1 answer
  • Why is color important for all objects drawn ?​
    5·1 answer
  • What are the main advantages of the d-step tuning of 2023 murano’s xtronic cvt®?.
    13·1 answer
  • as a pc technician, you are on the road most of the day and use a laptop. when you get back to your office at the end of the day
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!