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
When you first turn on a computer and you don’t hear a spinning drive or fan or see indicator lights, is the problem hardware or
abruzzese [7]
It is a hardware issue. Hope it helps! 
5 0
3 years ago
2Discuss the difference between overriding and overloading. (This is a very common interview question in programming)
nordsb [41]

Explanation:

Following are the difference between overriding and overloading

(1) Method overloading means method having same name but different parameter or method signature Whereas  Method overriding means method having same name and same parameter or signature.

(2) Method overloading is achieved the compile time Polymorphism whereas Method overriding is achieved the Run time Polymorphism .

(3 ) In method overriding child class have facility to provide a specific implementation of a method which is already defined by parent class method whereas there is no such facility is available in method overloading

(4 )Programming structure of method overloading

class test

{

 void fun()

{

// statement

}

void fun(int b)

{

// statement

}

}

In this fun() method name is same but different signature I.e void fun() and void fun(int a);  

Programming structure of method overriding  

class parent

{

  void fun()

{

// statement in parent class

}

}

class child extends test

{

void fun()

{

// override the statement in child class

}

}

In this fun() method have same name and same signature in both class  

7 0
3 years ago
You want to display the process of raising a scholarship request and its approval on a slide. Which element in the presentation
mario62 [17]

The answer is actually a flowchart, since flowcharts are used to show processes. The person who said it's a table is wrong, I just took this test on Plato and got a 5/5.

4 0
4 years ago
With what for a human may a heatsink in the computer be compared? a crispy lettuce salad an ice cold drink of water a sizzling s
Marysya12 [62]

Answer: I'd say an ice cold drink

7 0
4 years ago
Individual mental blocks may cause option
Bond [772]

B. negative attitude option

3 0
3 years ago
Other questions:
  • Which of the following should businesses and organizations do to promote a safe work environment?
    6·1 answer
  • HELP ME WITH JAVA: This is my assignment. I need to write a program with a main method and methods. Use a scanner to get the Str
    5·1 answer
  • Other drivers and pedestrians expect you to be sober and attentive, so you are responsible for ___________.
    15·2 answers
  • 1. Landscapes are the one type of photograph in which you should always use the traditional perspective.
    15·2 answers
  • What is the maximum number of communication paths for a team of twenty people.
    14·1 answer
  • Write code that will copy the contents of the file into an array. You can assume that the file will only have 5 data values
    11·1 answer
  • Guys how can i video my self from my laptop <br> my laptop is (lenovo)
    8·2 answers
  • A mobile operating system is stored on a ___ chip.​
    11·1 answer
  • 12. Why is it so important to pay attention to your digital reputation?
    14·1 answer
  • Find the name of the professor with the maximum percentage of students that failed his course.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!