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
________ is the application of statistical techniques to find patterns and relationships among data for classification and predi
Finger [1]

Answer:          

Data Mining

Explanation:

  • Data Mining is also called knowledge discovery.
  • It is a computer aided technique of searching and evaluating a bulk of data in order to obtain useful information.
  • This technique searches through the data to find hidden patterns and uses statistical methods to find relationship among data for finding predictive information and for classification of data.
  • This is a mixture of different disciplines which include machine learning, statistics and artificial intelligence and also some mathematical methods.
  • Often the useful information is extracted from enormous database using modeling technique which is used to build a model from instances of the data where the solution is known and later apply this model on the instances where the solution is unknown.
  • In unsupervised data mining, the data analysis is not done by using modeling technique. In other words the labels are provided in order not draw inferences and prediction from data sets. Example is clustering.
  • In supervised data mining the model is developed to make inferences and classification. Example is neural networks.
  • For example data mining is used in Medicine industry to provide more accurate diagnostics and treatments on the basis of patient's medical history , physical examination or different patient tests data.
  • Data mining also makes it possible to manage health resources more efficiently and cost-effectively by detecting risks, predicting diseases in certain sections of the population or predicting hospitalization duration.
4 0
3 years ago
Virtually all webcams plug into a(n) ________ port.
-Dominant- [34]
The answer is an usb port
5 0
3 years ago
Read 2 more answers
Please help me !!
gavmur [86]

e. uhmmm

19+21=30

like....

easy.

What grade class is this? I wanna do it cause it easy AFef

6 0
2 years ago
Write a program to enter 30 integer numbers into an array and display​
Rama09 [41]

Answer:

i764

Explanation:

3 0
2 years ago
Read 2 more answers
Does anyone know what anotmy means​
deff fn [24]

Answer:

also its spelled anatomy

Explanation:

The branch of science concerned with the bodily structure of humans, animals, and other living organisms, especially as revealed by dissection and the separation of parts.

Hope this helped :3

3 0
2 years ago
Read 2 more answers
Other questions:
  • How many megabytes of data can a factory made audio cd hold?
    13·1 answer
  • How to write a program that prompts the user to input two POSITIVE numbers — a dividend (numerator) and a divisor (denominator).
    13·1 answer
  • Which folder is the default choice for saving bitmap or JPEG files created by a user?
    9·1 answer
  • The jailbreak property that, if the user turns the device off and back on, the device will start up completely, and the kernel w
    15·1 answer
  • Image-editing software is used to_____
    7·1 answer
  • How did the internet originate??​
    12·1 answer
  • Which option represents the location of the Goal Seek function?
    8·2 answers
  • Which of the following is NOT one of the four benefits of using email?
    14·1 answer
  • A search expression entered in one search engine will yield the same results when entered in a different search engine.
    15·1 answer
  • which responses would you use for a computer or electronic medical record outage? (select all that apply)
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!