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
A construction-based client would like to develop an application that can analyze an image of machinery and overlay information
Elden [556K]

A form of Extended Reality which can best assist the client with information on the repair is: 3. Augmented Reality.

<h3>What is Extended Reality?</h3>

Extended reality refers to an umbrella terminology that is used to describe all real and virtual physical environments (realities) and human-machine interactions through the use of computer technologies and wearables.

<h3>The forms of Extended Reality.</h3>

In Computer technology, there are four (4) main types of Extended Reality and these include:

  • Mixed Reality
  • Haptic Reality
  • Virtual Reality
  • Augmented Reality

Augmented Reality is mainly applied in maintenance and repair by analyzing an image of machineries and provide information that will assist in the repair process.

Read more on Augmented Reality here: brainly.com/question/9054673

4 0
2 years ago
Is a network traffic management device used to connect different network segments together?
son4ous [18]
No, network traffic management software is only concerned with the health of the Network.
7 0
3 years ago
What addresses do not change if you copy them to a different cell?
Anika [276]

Answer: absolute then relative

Explanation:

7 0
3 years ago
Jakob is stuck in the airport on a long layover while traveling for work. He sees two Wi-Fi’s he can log onto: one says Airport
Andrei [34K]
You should pick Free Airport Wifi bc its free
3 0
3 years ago
Read 2 more answers
Data with values that change continuously or smoothly over time is known as:
Alexeev081 [22]

Answer:

A.  \:  \boxed{analog  \: data}

5 0
3 years ago
Read 2 more answers
Other questions:
  • a computer that no longer works after having minor repair work done to it may have been damaged by ______.
    6·1 answer
  • DRU is a small brokerage house that enables its clients to buy and sell stocks over the Internet, as well as place traditional o
    11·1 answer
  • 5. In Access, data is stored in a _______ once a form is completed. A. cell B. page C. record D. form
    13·1 answer
  • Customers access the internet through what usually for a monthly fee
    14·1 answer
  • When a rectangular region is defined using an appropriate style, which value matches the specified edge of the clipping region t
    7·1 answer
  • The ____ command displays the last 10 lines of a text file.
    5·1 answer
  • Explain the importance of mobile computing in communication​
    7·2 answers
  • What does good time management mean​
    8·2 answers
  • Spreadsheets are sometimes credited with legitimizing the personal computer as a business tool. Why do you think they had such a
    13·1 answer
  • If userNum1 is less than 0, put "userNum1 is negative.\n" to output. If userNum2 is greater than 10, assign userNum2 with 0. Els
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!