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
Vladimir [108]
2 years ago
6

Use the variables k and total to write a while loop that computes the sum of the squares of the first 50 counting numbers, and a

ssociates that value with total. Thus your code should associate 11 22 33 ... 4949 50*50 with total. Use no variables other than k and total.
Computers and Technology
1 answer:
Tems11 [23]2 years ago
3 0

Answer:

total = 0

k = 1

while k <= 50:

total += k**2

k += 1

print(total)

Explanation:

Note: There some errors in the question. The correct complete question is therefore provided before answering the question as follows:

Use the variables k and total to write a while loop that computes the sum of the squares of the first 50 counting numbers, and associates that value with total. Thus your code should associate 1*1 + 2*2 + 3*3 +... + 49*49 + 50*50 with total. Use no variables other than k and total.

The answer is now explained as follows:

# Initialize k which is the number of term

k = 1

# Initialize total which is the sum of squares

total = 0

# Loop as long as k is less than or equal to 50.

while (k <= 50):

# Add the square of k to total in order to increase it

total = total + k * k

# Increase the value of k by one.

k += 1

# Finally, output total

print (total)

You might be interested in
1. Extract title Write a function extract_title that takes one parameter, the filename of a GenBank formatted file, and returns
trapecia [35]

Answer:

def extract_title(file):

   import re

   a =''

   with open(file,'r') as file:

       for line in file:

           a += line

       m = re.search("^(TITLE)(.*?)(JOURNAL)", a, re.M + re.S)

       print(m.groups()[1])

extract_title('new.txt')

Explanation:

The programming language used is python 3.

The function is first defined and the regular expression module is imported.

A variable is initialized to an empty string that will hold the content of the GenBank formatted file.

The file is opened and every line in the file is assigned to the string variable. The WITH statement allows files to be closed automatically.

Regular expression is used to capture all the files between TITLE and JOURNAL in a group.

The group is printed and the function is called.

I have attached a picture of the code in action.

6 0
3 years ago
Which type of software is the most similar to database software?\
kykrilka [37]
The answer is graphics
5 0
3 years ago
Which of the following is not a type of bank?
andreyandreev [35.5K]
Where is the following banks that is listed?
3 0
3 years ago
Read 2 more answers
Cmo se puede añadir amigo ??'
seropon [69]

Answer:ok

Explanation:

5 0
3 years ago
Plz help meeeeee QUICKLY!!! WORTH 15 POINTS!
Lady bird [3.3K]

Answer:

Im pretty sure Domain name system but dont trust me

Explanation:

8 0
3 years ago
Other questions:
  • What is the purpose of lookup tables in spreadsheet software
    13·2 answers
  • The ____________________ packet-filtering firewall allows only a particular packet with a particular source, destination, and po
    10·1 answer
  • Can someone help me with...A table can help? PLEASE
    8·1 answer
  • 50 Points! 25 Points Each! Please help ASAP! Will mark brainliest! See attached image.
    10·2 answers
  • Displays are geared for a specific resolution. what is this resolution called?
    15·1 answer
  • 8.13 LAB: Elements in a range Write a program that first gets a list of integers from input. That list is followed by two more i
    8·1 answer
  • A nonprofit organization uses a contact management database to track donations, amounts donated, and all correspondence and phon
    11·1 answer
  • Determine the following information about each value in a list of positive integers.
    14·1 answer
  • When would the Jerusalem virus attack?<br> 1. Friday the 13th<br> 2. Wednesday the 13th
    13·2 answers
  • Every finger has a key it should be resting on when you are not typing<br> 1. False<br> 2. True
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!