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
Access to sensitive or restricted information is controlled describes which of the key communications and information systems pr
Viktor [21]

Answer:

C: Security

Explanation:

Communications and information systems principles need to be, among other things, secure. They need to be able to protect sensitive information from those who intentionally not need to know. Some incident information like voice, networks, and data, are very sensitive and thus, should be secure to the right levels and should comply with privacy laws and data protection.

4 0
3 years ago
You've just installed a new video card in a user's Windows workstation. When the system is powered on the screen is blank. You
valentinak56 [21]

After having verified that the video cable is installed correctly we should check to see that the computer's RAM is correctly fastened to the motherboard and functional.

The question states that the video card being installed is new, therefore we can comfortably assume that the card itself is not the issue. Other computer components that can cause a blank screen immediately upon powering on the workstation are:

  • RAM
  • Hard drive
  • Bad video driver.
  • Monitor input is faulty

however, assuming the installation was performed correctly, it is not likely to be caused by a bad video driver and a faulty monitor input is very improbable given that there are very few ways this can break to begin with.

A bad or missing hard drive may cause this kind of issue because the workstation will not have a windows file to boot. In most cases, this will not cause a completely blank screen without first allowing access to the BIOS.

After having verified that the video cable is installed correctly, the very next thing you should check is if the RAM is installed correctly. This is because the issue explained is exactly what will happen if a workstation attempts to boot without RAM, and also because it is the easiest fix among the possible causes and any troubleshooting should always be performed in order from the easiest fix to the most difficult.

To learn more visit:

brainly.com/question/2160588?referrer=searchResults

8 0
2 years ago
How to adjust screen from 1024x728 to 800x600
densk [106]
Goto settings>display>resolution what os is your system? this was for a win 10
5 0
3 years ago
Larry recently viewed an auction listing on a website. as a result, his computer executed code that popped up a window that aske
RUDIKE [14]
<span>Larry recently viewed an auction listing on a website. as a result, his computer executed code that popped up a window that asked for his password. The type of attack larry had likely encountered is the </span><span>Cross-site scripting (XSS).</span>
4 0
3 years ago
Assume the variable costOfBusRental has been declared as an int and assigned the amount that it costs to rent a bus. Also assume
Basile [38]

It’s a total price divided to a number of riders involved. So costPerRider = costOfBusRental/maxBusRiders

4 0
3 years ago
Other questions:
  • Can a computer will work more efficiently if you perform disk optimization
    9·1 answer
  • The difference between a for loop and a while loop is that a for loop is a loop that happens for a certain number of times. A wh
    14·1 answer
  • Java provides a number of interfaces and classes to systematically implement collections.
    6·1 answer
  • If you design your pages using a font that your user does not have installed, the browser defaults to ____ on a macintosh.
    13·1 answer
  • What Fortnite skin is more og?
    5·2 answers
  • The 10 and 2 o'clock hand position on the steering wheel is no longer recommended because _____.
    13·1 answer
  • What is the d/c b/n information rich and information poor society​
    13·1 answer
  • Tyra is peer conferencing about her project with a friend. Tyra's friend provided feedback that Tyra does not agree with. What s
    6·1 answer
  • Would my phone still work if I snapped it in half?
    8·2 answers
  • Does anyone know how many Brainliests you need to be able to send a private message to someone??
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!