Need code complete This program will look for the next perfect square. Check the argument to see if it is a perfect square itself, if it is not then return -1 otherwise look for the next perfect square. for instance if you pass 121 then the script should return the next perfect square which is 144. """ def find_next_square(sq):     root = sq ** 0.5     if root.is_         return (root + 1)**2     retrn -1 def find_next_square2(sq):     """ Alternative method, works by evaluating anything non-zero as True (0.000001 --> True) """     root = sq**0.5

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 20PE
icon
Related questions
Question

Need code complete
This program will look for the next perfect square.
Check the argument to see if it is a perfect square itself, if it is not then return -1 otherwise
look for the next perfect square.
for instance if you pass 121 then the script should return the next perfect square which is 144.
"""

def find_next_square(sq):
    root = sq ** 0.5
    if root.is_
        return (root + 1)**2
    retrn -1

def find_next_square2(sq):
    """ Alternative method, works by evaluating anything non-zero as True (0.000001 --> True) """
    root = sq**0.5

 

 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning