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
What does UDP stand for?
sleet_krkn [62]
User Datagram Protocol
3 0
3 years ago
Read 2 more answers
Do laws ever change to help enforce cyber hacking crimes
prisoha [69]
No I don’t think so personally
5 0
2 years ago
Read 2 more answers
What is a spacecraft virus?
photoshop1234 [79]
A spacecraft virus<span> is a type of bacteria virus that feeds on other bacteria. It got it name because it is mostly shaped like a spacecraft.</span>
4 0
3 years ago
Read 2 more answers
In what ways are computers being used to improve our quality of life
serg [7]

Explanation:

makes info easy to get

improves communication

enhances education

etc

plsss mark me brainliesttt

3 0
3 years ago
A user called to inform you that the laptop she purchased yesterday is malfunctioning and will not connect to her wireless netwo
kakasveta [241]

Answer:

You can perform the following two steps

Explanation:

  1. Have the user press the appropriate function key combination to enable the wireless radio and then attempt to connect to the wireless network (since by mistake he could have disabled it).
  2. Ask the user to turn on the laptop’s airplane mode and attempt to reconnect to the wireless network (this mode basically what it does is disable adapters and activate it will connect the Wi-Fi network).
7 0
3 years ago
Other questions:
  • Pretrial services programs are also known as early intervention programs. <br> a. True <br> b. False
    15·1 answer
  • 8. A pattern of being late for work or for appointments is usually
    12·1 answer
  • Vector testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full cr
    7·1 answer
  • You are requesting information about wireless connectivity for your workplace computers. Because you expect the information to b
    15·1 answer
  • 2) What is the value stored in the variable z by the statements below?
    11·1 answer
  • Define Based Assessment ​
    5·1 answer
  • Identify the correct characteristics of Python tuples. Check all that apply.
    9·1 answer
  • Hdhdhrhdh you are not the intended recipient. xmp-qite-xsy.​
    12·1 answer
  • Connect research concepts to their definitions
    13·1 answer
  • Which structures protect the cell? Select two options.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!