Computer Science, asked by tubglax, 10 months ago

write a program to accept a number and check whether the number is a perfect square or not sample input 49 sample output a perfect square​

Answers

Answered by tiger009
1

WAP to check Perfect Square.

Output:

Enter integer value to check perfect square: 49

a perfect square

Explanation:

Following are the program in the Python Programming Language.

#import math for math functions

import math as ps

#define function

def Perfect_Square(x):  

 # set variable to store square root    

 num = ps.sqrt(x)  

 # check that square root is integer or not

 return ((num - ps.floor(num)) == 0)  

# set variable to get input from the user

x = int(input('Enter integer value to check perfect square: '))

#check if it is a perfect square then

if (Perfect_Square(x)):  

 #print following message

 print("\na perfect square")  

#otherwise

else:  

 #print following message

 print("\nNot a perfect square")

Following are the description of the program:

  • Import required package for the math function.
  • Define function 'Perfect_Square()' with an argument 'x' in its parameter, inside it set variable 'num' that store the perfect square root of the argument, then check the following square root is a perfect square or not.
  • Finally, set variable 'x' which get integer data type input from the user, and check the following input is a perfect square or not.

Learn More:

WAP to checks that a given positive integer is a perfect square: brainly.com/question/6457650

Answered by deepakdhaanya1
6

hope it helpful for you

please follow me

Attachments:
Similar questions