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
Oliga [24]
3 years ago
13

Assume there are two variables, k and m, each already associated with a positive integer value and further assume that k's value

is smaller than m's. Write the code necessary to compute the number of perfect squares between k and m. (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).) Associate the number you compute with the variable q. For example, if k and m had the values 10 and 40 respectively, you would assign 3 to q because between 10 and 40 there are these perfect squares: 16, 25, and 36,.
PYTHON CODING
Computers and Technology
1 answer:
ehidna [41]3 years ago
8 0

Answer:

import math  

def isPerfectSquare(n):

 s = int(math.sqrt(n))

 return n == s*s

def countPerfectSquares(k,m):

 q = 0

 for i in range(k,m):

   if isPerfectSquare(i):

     q=q+1

 return q

print(countPerfectSquares(10,40))

Explanation:

Note that this is including the k, but excluding m. If you want to include m, write m+1 in the range expression.

You might be interested in
Which set of skills must a network administrator and a systems administrator both have?
Andreyy89
I think the answer to this is A
6 0
3 years ago
What is an electronic path over which data can travel.
disa [49]
Im pretty sure its Bandwidth 
7 0
3 years ago
When you are using the internet to research a school project, and you ignore the banner ads on websites even though you see them
FinnZ [79.3K]

Answer:

The answer is "selective exposure".

Explanation:

It is a theory in psychology, that is sometimes used in marketing and advertising studies. It traditionally applies to the propensity of people to prefer evidence, that enhances existing previous views while ignoring conflicting information.

These types of approaches are occurring, when the people pursue knowledge and consistently express desires for solutions, that are associated with their beliefs, rather than incompatible.

5 0
3 years ago
Which of the following types of software is most applicable to the promotion of new products through advertising?
LenaWriter [7]

It cannot be database programs because database programs can not

store and organize data.

create graphics.

communicate data.

alleviate information overload.

It cannot be spreadsheets because a spreadsheet or worksheet is a file made of rows and columns that help sort data, arrange data easily, and calculate numerical data. What makes a spreadsheet software program unique is its ability to calculate values using mathematical formulas and the data in cells.

It cannot be word processing tools because a word processor is software or a device that allows users to create, edit, and print documents. It enables you to write text, store it electronically, display it on a screen, modify it by entering commands and characters from the keyboard, and print it.

Therefore the answer is C. Web design programs.

Hope this helps.

8 0
3 years ago
Read 2 more answers
g 1. Write a program that asks the user for a number greater than 5 and prints all values between 1 and n that are multiples of
a_sh-v [17]

PROGRAM 1

#include <iostream>  

using namespace std;

int main() {

   int n;

   // user input taken for n

   cout<<"Enter any number greater than five: ";

   cin>>n;

   

   cout<<"The multiples of 5 between 1 to "<<n<<" are shown below."<<endl;

   

   // displaying multiples of 5 between 1 to n

   for(int h=1; h<=n; h++)

   {

       // if number is completely divisible by 5, remainder will be 0

       if( (h%5)==0)

           cout<<h<<endl;

   }

 

   return 0;

}

OUTPUT

Enter any number greater than five: 22

The multiples of 5 between 1 to 22 are shown below.

5

10

15

20

The program does not implements any input validation since this is not mentioned in the question.

User input is taken. All the multiples of 5 computed inside a for loop, and displayed to the console.

PROGRAM 2

#include <iostream>

using namespace std;

int main() {

   // variables to hold respective values

   int n;

   int sum=0;

   double avg=0;

   

   do

   {

       // user input taken for n

       cout<<"Enter any number between 1 and 100: ";

       cin>>n;

       if(n<1 || n>100)

           cout<<"Invalid number. Enter valid number."<<endl;

       cout<<""<<endl;

       

   }while(n<1 || n>100);

   

   // computing sum and average of numbers from 1 to n

   for(int h=1; h<=n; h++)

   {

       sum = sum+h;

   }

   

   avg=avg+(sum/n);

   

   cout<<"Sum of all the numbers from 1 to "<<n<<" is "<<sum<<endl;

   

   cout<<""<<endl;

   cout<<"Average of all the numbers from 1 to "<<n<<" is "<<avg<<endl;

   

   return 0;

}

OUTPUT

Enter any number between 1 and 100: 111

Invalid number. Enter valid number.

Enter any number between 1 and 100: 0

Invalid number. Enter valid number.

Enter any number between 1 and 100: 23

Sum of all the numbers from 1 to 23 is 276

Average of all the numbers from 1 to 23 is 12

The program not implements any input validation since this is mentioned in the question.

User input is taken inside do-while loop till valid input is obtained.

The sum of all numbers from 1 to n computed inside a for loop, average computed outside for loop.

Both values are displayed to the console.

5 0
3 years ago
Other questions:
  • a circuit has an inductor with an inductive reactance of 230 ohms. this inductor is in series with a 500 ohm resistor. if the so
    5·1 answer
  • What are the different components of the cloud architecture?
    5·2 answers
  • What best describes the purpose of occupational safety and health Administration
    5·2 answers
  • How can i learn about networks
    15·1 answer
  • Recall the insertion-sort-like algorithm in Problem 4 from Homework 2, where you know that certain pairs of contiguous items in
    15·1 answer
  • What are options in the Advanced tab in the Share Workbook dialog box? Check all that apply.
    14·2 answers
  • Write an if/else statement that assigns 0 to x when y is equal to 10; otherwise it should assign
    9·1 answer
  • What Is the Purpose of a Web Browser? *<br><br>​
    7·2 answers
  • in speech writing, it can be defined as all aspect of your writing that help the reader move smoothly from one sentence to the n
    7·1 answer
  • Consider the following code:
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!