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
Daniel [21]
3 years ago
9

Assume there is a variable, h that has already been assigned a positive integer value. Write the code necessary to compute the s

um of the perfect squares whose value is less than h, starting with 1. (A perfect square is an integer like 9, 16, 25, 36 that is equal to the square of another integer (in this case 3*3, 4*4, 5*5, 6*6 respectively). Assign the sum you compute to the variable q. For example, if h is 19, you would assign 30 to q because the perfect squares (starting with 1) that are less than h are: 1, 4, 9, 16 and 30==1+4+9+16.
Computers and Technology
1 answer:
malfutka [58]3 years ago
3 0

Answer:

import math

h = 19

total = 0

for i in range(1, h):

   if math.sqrt(i) - int(math.sqrt(i)) == 0:

       total += i

print(total)

Explanation:

*The code is in Python.

Initialize the h and total

Create a for loop that iterates from 1 to h. Inside the loop, check if the difference between the square root of a number and the integer part of the square root of that number is equal to 0 (This means the number is a perfect square. For example, if the number is 3, the square root is 1.73 and the integer part of this is 1, the difference is 0.73, not 0. However, if the number is 4, the square root is 2.0 and the integer part is 2, the difference is 0), add that number to the total

When the loop is done, print the total.

You might be interested in
What has been your background with using Windows-based computers?
Radda [10]

Answer:

Anything i desire.

Explanation:

4 0
3 years ago
Read 2 more answers
(tco 8) when asp.net receives a request for an application that uses forms-based authentication from a user who hasn't been auth
leonid [27]
Hi,

This what you are looking for: "records incorrect prompt"

Hope this helps.
r3t40
7 0
3 years ago
List of bad websites and why
r-ruslan [8.4K]

Penny Juice – bad design examples.

Blinkee website – bad design example.

Great Dreams I — bad designed website.
8 0
3 years ago
PLEASE HELP ASAP I WILL GIVE BRAINLIEST TO CORRECT ANSWER
salantis [7]
The correct answer is letter b
8 0
3 years ago
Read 2 more answers
Certificates of indebtedness sold to raise long-term funds for a corporation or government agency are known as _____
ankoles [38]
Those are corporate- or government-"bonds".
8 0
3 years ago
Other questions:
  • After a robbery, what is the purpose of conducting a neighborhood canvass?
    9·1 answer
  • What are some programs that you have used that have condition-controlled loops and count-controlled loops?
    10·1 answer
  • Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 te
    13·1 answer
  • What kind of skills does an electronics engineering tech need as requirement in the workplace?
    6·1 answer
  • Suppose that a program asks a user to enter multiple integers, either positive or negative, to do some calculation. The data ent
    13·1 answer
  • To which of these options does the style in Word apply? Select three options.
    7·1 answer
  • The image below is an example of a
    6·1 answer
  • Write a method, public static void selectSort(ArrayList list), which implements a selection sort on the ArrayList of Integer obj
    10·1 answer
  • In what ways is the human brain like a computer? In what ways is it different?
    14·2 answers
  • We can save our data peremently on a
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!