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]
2 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]2 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
If you want to wrap text so that it fits a particular cell size, which formatting section would you use?
Pavlova-9 [17]

You would use the formatting section of alignment.

7 0
3 years ago
Read 2 more answers
Implication of technological literacy to a teacher training today
Dafna1 [17]

<u>Implication of technological literacy to a teacher training today :</u>

  • First of training has to be under technology literacy before training starts. Trainer also should have enough knowledge on technology literacy.
  • Trainer can take printed materials to share the document on the topic which to be covered and circulated to trainers
  • Since it given as general topic, training teacher has to cover the following topic, general on computer and purpose of computer today's life, life cycle of computer grown from old PC to laptop and tablet.
  • Next topic such be covered operating system and explain about the operating system and different technology is used.
  • Revolution on technology should be also covered and explained in details.
8 0
2 years ago
What is the CPI of the central processing unit cpu of a computer
vlada-n [284]
Electronic component on a computer's
motherboard that interprets and carries
out the basic instructions that operate
the computer; also called processor.
5 0
2 years ago
Password cracking is a technique used to extract user’s password of application/files without the knowledge of the legitimate us
Vlada [557]

Answer:

Rule based Attack.

Explanation:

                    As password cracking is a technique used to extract user’s password of application/files without the knowledge of the legitimate user. The attacker can use Rule Based Attack to find the password and to intrude or compromise the network and systems.

                    This is like a programming language to generate the password. This involves functions to modify, cut, edit and extend the generally used terms by the user.

5 0
2 years ago
Anyone here good with PS4's?
Nookie1986 [14]
I can help you out ! What do you need to know bud ?
6 0
3 years ago
Read 2 more answers
Other questions:
  • PLEASE HELP
    12·2 answers
  • Which one of the following items is an example of software?
    15·1 answer
  • The computer mouse is used to
    11·1 answer
  • You’re creating a table for one of your slides, and need to make some modifications to your table structure. Which of the follow
    6·2 answers
  • I'm 11, except my profile says I'm 15.
    15·1 answer
  • If you wanted to have wireless connectivity in your home or​ apartment, you would need a​ _________________ to move packets of d
    11·1 answer
  • You have just finished installing a network adapter adapter and booted up the system, the drivers. You open File Explorer on a r
    13·1 answer
  • Which of the following is a career that's indirectly linked to careers in web technologies?
    10·1 answer
  • What is meant by index of an element?​
    11·1 answer
  • What is Parallelism? And what is Pipelining?<br> Can someone please explain them fully?!
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!