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]
2 years 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]2 years 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
Drag each tile to the correct box.
garri49 [273]
I think select the video insert select the movie option under illustrations resize the video player then select the insert tab i’m not 100 percent sure tho
8 0
2 years ago
Read 2 more answers
Give at least one example computer application for which a connection-oriented service is appropriate and at least one example c
Leni [432]
Apple devices would be one
8 0
2 years ago
Question 1:State the values of a, b, c, d and e after the following operations are carried out:
pychu [463]

Answer:

1.

a = 1

b = 20(int). 20,2857143(double)

c = 39

d = 7.6

e = 456

2.

x = 98

y = 99

z = 97

w = ca

print(x,y,z,w) -> 98 99 97 ca

3.

x = Please

y = walk on the gras

Pleasewalk on the gras

Explanation:

you can use IDE/Interpreter python to get clue number 3 and number 2

Sorry for bad English.

5 0
2 years ago
You would like the user of a program to enter a customer’s last name. Write a statement thaUse the variables k, d, and s so that
mojhsa [17]

Answer:

1st question:

Use the variables k, d, and s so that they can read three different values from standard input an integer, a float, and a string respectively. On one line, print these variables in reverse order with exactly one space in between each. On a second line, print them in the original order with one space in between them.

Solution:

In Python:

k = input()  #prompts user to input value of k i.e. integer value

d = input()  #prompts user to input value of d i.e. float value

s = input()  #prompts user to input value of s i.e. a string

print (s, d, k)  #displays these variable values in reverse order

print (k, d, s)#displays these variable values in original order

In C++:

#include <iostream>    // to use input output functions

using namespace std;   //to identify objects like cin cout

int main() {    //start of main function

  int k;   //declare int type variable to store an integer value

  float d; //  declare float type variable to store a float value

  string s;   //  declare string type variable to store an integer value

  cin >> k >> d >> s;    //reads the value of k, d and s

  cout << s << " " << d << " " << k << endl;     //displays these variables values in reverse order

  cout << k << " " << d << " " << s << endl;   } // displays these variable values in original order

Explanation:

2nd question:

You would like the user of a program to enter a customer’s last name. Write a statement that asks user "Last Name:" and assigns input to a string variable called last_name.

Solution:

In Python:

last_name = input("Last Name:")

# input function is used to accept input from user and assign the input value to last_name variable

In C++:

string last_name;  //declares a string type variable named last_name

cout<<"Last Name: ";  // prompts user to enter last name by displaying this message Last Name:

cin>>last_name; // reads and assigns the input value to string variable last_name

The programs alongwith their outputs are attached.

6 0
2 years ago
Write the prototype for a function named showValues. It should accept an array of integers and an integer for the array size as
aalyn [17]

Answer:

void showValues(int [<em>maximum</em><em> </em><em>volume</em>],int);

4 0
2 years ago
Read 3 more answers
Other questions:
  • Problem statement: Using loop, write a program that will ask the user to enter a character for left or right. Then, the user wil
    13·1 answer
  • Judd puts password protection on all of his files, makes sure not to have any patient information open on his computer when he t
    12·2 answers
  • A patient asks her doctor to send a copy of her records to another medical office. However, the records are not transmitted beca
    10·2 answers
  • Which are examples of copyrighted online materials? Check all that apply.
    14·2 answers
  • Which selections are possible for controlling the start time of audio playback? Check all that apply. Automatic Rewind when done
    10·1 answer
  • Characteristics of a LAN include _____. can be connected to the Internet covers the most area of all networks does not have to b
    5·1 answer
  • Data Analysis The Iris Plants Database contains 3 classes of 50 instances each, where each class refers to a type of Iris plant.
    15·1 answer
  • You have enabled IPv6 on two of your routers, but on the interfaces you have not assigned IPv6 addresses yet. You are surprised
    10·1 answer
  • Define a method named roleOf that takes the name of an actor as an argument and returns that actor's role. If the actor is not i
    8·1 answer
  • 3.14 LAB: Simple statistics for Python
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!