answer.
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
mezya [45]
1 year ago
14

Write a program that asks the user to input an integer that is a perfect square. A perfect square is an integer that is equal to

the product of another integer with itself; e.g., 16 is a perfect square because it equals 4 times 4. Repeatedly force the user to input a new integer until they enter a perfect square. Once the user has entered a perfect square, print its square root as an integer. Hint: you can modulo a float by 1 to get the decimal part of the float, e.g., 2.75 % 1 equals 0.75, and 5.0 % 1 equals 0.
Computers and Technology
1 answer:
BlackZzzverrR [31]1 year ago
3 0

Answer:

// program in python

# import math library

import math

#read input from user

num=int(input("enter an integer:"))

while True:

#find square root on input

   s_root=math.sqrt(num)

#find remainder of root

   r=s_root%1

#if remainder if 0 then perfect square

   if r==0:

       print("square root of the number is:",s_root)

       break

   else:

#if number is not perfect square then ask again

       num=int(input("input is not perfect square !!enter an integer again:"))

Explanation:

Read an integer from user.Find the square root of the input number and then find  the remainder of square root by modulo 1.If the remainder is 0 then number is perfect square otherwise ask user to enter an integer again until user enter a perfect square  number.

Output:

enter an integer:12                                                                                                        

input is not perfect square !!enter an integer again:16                                                                    

square root of the number is: 4.0    

You might be interested in
The it department is reporting that a company web server is receiving an abnormally high number of web page requests from differ
Talja [164]
<span>In the scenario in which the IT department is reporting that a company web server is receiving an abnormally high number of web page requests from different locations simultaneously the DDoS security attack is occurring.
</span>DDos stands for Distributed Denial of Service<span> . This </span><span>attack is an attempt to make an online service unavailable by overwhelming it with traffic from multiple sources.</span>
8 0
1 year ago
What is the purpose of using self.id in tests, while working with unittest?A. self.id returns the name of moduleB. self.id retur
ikadub [295]

Answer:

B. self.id returns the name of method.

5 0
1 year ago
Var name = prompt("Enter the name to print on your tee-shirt");
Vinil7 [7]

Willy Shakespeare has 17 characters. It's higher than 12,so the output will be Too long. Enter a name with fewer than 12 characters.

Letter a.

3 0
2 years ago
Suppose that the following processes arrive for execution at the times indicated. Each process will run for the amount of time l
Len [333]

Answer:

a) 10.53

b) 9.53

Explanation:

a) Average Turnaround Time: ( (8-0)+(12-0.4)+(13-1.0) ) / 3 = 10.53

b) Average Turnaround Time: ( (8-0)+(13-0.4)+(9-1.0) ) / 3 = 9.53

5 0
2 years ago
Python comes with ________ functions that have been already prewritten for the programmer.
Gnoma [55]
Python comes with built-in functions...
6 0
2 years ago
Other questions:
  • Brake lights on freeways invite A: law enforcement B: panic C: sudden lane changing D: both B and C E: positive driving habits
    13·1 answer
  • When a file is transferred between two computers, two acknowledgment strategies are possible. in the first one, the file is chop
    9·1 answer
  • A business wants to centralize its administrative tasks. At the same time, it wants the existing systems to manage and sustain t
    14·2 answers
  • You're the sole IT employee at your company, and you don't know how many users or computers are in your organization. Uh oh! Wha
    8·1 answer
  • Write a class with a constructor that accepts a String object as its argument. The class should have a method that returns the n
    13·1 answer
  • Write multiple if statements: If carYear is before 1968, print "Probably has few safety features." (without quotes). If after 19
    6·1 answer
  • Given an int variable k, an int array incompletes that has been declared and initialized, an int variable studentID that has bee
    10·1 answer
  • Write a function named max that accepts two integer values as arguments and returns the value that is the greater of the two. Fo
    12·1 answer
  • Write any 5 activities that help to remove bad events from the society?​
    13·2 answers
  • Write a public static method named printArray, that takes two arguments. The first argument is an Array of int and the second ar
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!