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
katrin [286]
3 years ago
13

Write a program that accepts a positive integer N as command-line argument, and outputs True if N is the square of some integer,

and False otherwise. Do not use math.sqrt() or similar! Hint: Clearly, all candidates i which may satisfy i2 = N must be at most N (for which "corner case" of N is i equal to N?). Therefore, it is sufficient to check if there exists an i in the range 1 ≤ i ≤ N such that i2 = N. In other words, you want to evaluate the expression (12 == N)or (22 == N)or (32 == N)or ··· or ((N − 1)2 == N) or (N2 == N). Practice goal: A variation of the primality checking program we have seen in class; follows a Boolean accumulation pattern, with logical or.
Computers and Technology
1 answer:
Ann [662]3 years ago
3 0

Answer:

In Python:

N = int(input("Positive integer: "))

if N > 0:

   flag = False

   for i in range(1,N+1):

       if i * i == N:

           flag = True

           break

   print(str(flag))

else:

   print("Positive integer only")

   

Explanation:

N = int(input("Positive integer: "))

If the number is positive

if N > 0:

This initializes a boolean variable to false

   flag = False

This iterates from 1 to the input integer

   for i in range(1,N+1):

This checks if th number is a square of some integer

       if i * i == N:

If yes, flag is set to true

           flag = True

The loop is exited

           break

This prints either true or false, depending on the result of the loop

   print(str(flag))

If otherwise, that the number is not positive

<em>else:</em>

<em>    print("Positive integer only")</em>

You might be interested in
I figured out the secret message in Dad feels good, I can connect the dots
kati45 [8]

Answer:

Nope you figured it out

Explanation:

3 0
3 years ago
Which are elements involved in diagramming a solution? Choose all that apply.
katovenus [111]

Answer:

1) showing a visual graphic of the solution

3) showing the flow of information through the solution

4) showing decision points

5) showing the path of information to decision points

Explanation:

 I'm sure this is the answer!!

4 0
3 years ago
What kind of waste does a computer generate?<br><br> Will give brainly :3
Lena [83]

Answer:

waste???? a computer??

7 0
3 years ago
A stateful inspection firewall ________. select one:
mart [117]

;) https://quizlet.com/7016715/cyber-security-flash-cards/ go check the link

6 0
3 years ago
Suppose a system administrator at sls happened to read the details of this case. what steps should he or she take to improve the
kvv77 [185]
He should add more security applications to the software and inform the company to not tell any details.
6 0
4 years ago
Other questions:
  • Use-Cases are scenarios that describe
    9·1 answer
  • Do clocks have cell's?
    15·2 answers
  • We will pass in 2 values, X and Y. You should calculate XY XY and output only the final result. You will probably know that XY X
    13·1 answer
  • Given a link with a maximum transmission rate of 18 Mbps. Only two computers, X and Y, wish to transmit starting at time t = 0 s
    14·1 answer
  • Hey I don’t have a question I’m just testing something on this app
    6·2 answers
  • Using for loop . Input an integer and identify whether it's EVEN OR ODD ( without using modulo operator )
    9·1 answer
  • Why might you choose a Macintosh operating system rather than a Linux operating system?
    5·2 answers
  • When more open-ended questions are asked in a study group, discussions are more likely to
    14·2 answers
  • What is the first law of thermodynamics?
    5·2 answers
  • If you want the input gear to spin in the same direction as the output gear you must use a _______ gear.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!