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
kompoz [17]
3 years ago
13

Problem 5. (Greatest Common Divisor) Write a program gcd.py that accepts p (int) and q (int) as command-line arguments, and writ

es to standard output the greatest common divisor (gcd) of p and q.
Computers and Technology
1 answer:
netineya [11]3 years ago
8 0

Answer:

The following are the program in the Python Programming Language.

#import system

import sys

#define function

def gcd(p,q):

 #check that q is equal to 0

 if(q==0):

   #then, it returns the output

   return p

 #it returns the common divisor

 else:

   return gcd(q,p%q)

#get the command-line input

x=sys.argv[1]

#get the command-line input

y=sys.argv[2]

#convert input into the integer

p=int(x)

#convert input into the integer

q=int(y)

#call and print the function

print(gcd(p,q))

Explanation:

<u>The following are the description of the program</u>.

  • Firstly, we import the required package and define a function 'gcd()', pass arguments 'p' and 'q' and inside the function.
  • Set the if conditional statement to check that the variable 'q' is equal to 0 then, it returns the value of 'q' and otherwise, it returns the greatest common divisor value.
  • Finally, we set two variables 'x' and 'y' in which we get input from the command line then, convert the input of the both variable into integer and store them in other variables 'p' and 'q', after all, call and print the following function.
You might be interested in
What is better in everybodys opinion. AMD or Intel?
Rama09 [41]

Answer:

Intel is more for work and such, while AMD is foucsed on gamers. I use AMD because I play many games, but it really depends on what you use your computer for.

Explanation:

4 0
2 years ago
Read 2 more answers
After the explosion of the Union Carbide plant the fire brigade began to spray a curtain of water in the air to knock down the c
AysviL [449]

Answer:

d. The system of water spray pipes did not have sufficient water supply

Explanation:

The Union Carbide India Ltd. was chemical factory situated at Bhopal that produces various pesticides, batteries, plastics, welding equipment, etc. The plant in Bhopal produces pesticides. In the year 1984, on the night of 2nd December, a devastating disaster occurred on the Bhopal plant which killed millions of people due to the leakage of the poisonous, methyl isocyanate. This disaster is known as Bhopal Gas tragedy.

Soon after the gas pipe exploded, the fire brigade started spraying water into the air to \text{knock down} the cloud of the gases in the air but there was not sufficient amount of water in the water sprays and so it was not effective.

Thus the correct answer is option (d).

4 0
3 years ago
Adios brainly, wont be posting that much take my points away i d c
mrs_skeptik [129]
Omg I would die to have your points because when I get on people call me a noob because I just got the app like 3 days ago and every time I answer a question some says noob like dang I just started
5 0
3 years ago
Read 2 more answers
Wireless internet is an example of telecommunications.
lawyer [7]
Anything is telecommunication if it has a <span>transmitter</span> and receiver. If you're a Host, then you're hosting (Transmitting) a connection. If you have a router as a customer or service, then you're receiving their signal (transmitting). You're the receiver. 
7 0
2 years ago
Which of the following is NOT a reason to use cryptography?
Mars2501 [29]

Cryptography is not a reason to use when posting photos on a public social media website.

Cryptography is the use of certain techniques that help protect important and personal information from being accessed by other parties. This technological practice or method allows a person to send sensitive or personal information over the internet without risking any "leak" of information.

  • Cryptography literally means "hidden writing", which is what the method is all about.
  • It presents a safe and secure way of sending or passing information, even personal or sensitive ones.
  • This technological method enables businesses and other companies as well as individuals to procure and send information without fearing for any loss of their information.
  • Cryptography is mainly used in the military, secret operations, businesses, or even in maintaining one's passwords while using social media platforms or submitting a password on a website.
  • One reason to not use it is when posting photos on social media websites as the website is to be used by the web world and may/can be accessed by everyone around the world.

Cryptography not only allows a person to maintain certain privacy and security but also help the smooth functioning of businesses and other national security works. Thus, cryptography is the "security" of individuals in the 'internet world'.

Learn more about cryptography here:

brainly.com/question/88001

5 0
2 years ago
Read 2 more answers
Other questions:
  • Why does temperature decrease with higher altitude?
    14·1 answer
  • Which animation effects allow text or images to show movement on a slide? Check all that apply. Entrance, Emphasis, Exit, Motion
    5·2 answers
  • What is virtual reality?
    10·1 answer
  • Which small-group format would be most appropriate for the following situation? A large sporting event is coming to town. Key me
    14·2 answers
  • The CMS Quarterly Provider Update (QPU) is an online CMS publication that contains information about __________ currently under
    14·1 answer
  • What is an example of a hard skill?
    12·2 answers
  • A local variable that is declared as ____ causes the program to keep the variable and its latest value even when the function th
    10·1 answer
  • What is 36 Denary in Binary?? PLEASE ANSWER I WILL GIVE U BRAINLY!!
    9·2 answers
  • Jimmy has been issued a citation for littering in a city park. When Jimmy
    8·1 answer
  • What is the<br> binary code<br> for<br> "DMS"?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!