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
To paste text with the same formatting as the document in which it is entered, select _____ from the Paste menu. Keep Source For
SashulF [63]
Copy by command c and paste by command v
5 0
3 years ago
Read 2 more answers
Wireless networks use radio frequency (RF) or radio techniques, which allows wireless transmissions to reach out in all directio
tia_tia [17]

Answer: True

Explanation:

Yes, the given statement is true that that one of the quality of the wireless networks is that they uses the various radio techniques and the radio frequency.

 By using this techniques, the wireless transmission occur and it enable the connectivity and allow the direction of transmission to eavesdrop. It is one of the best technique as compared to the traditional method which include copper and fiber.

6 0
3 years ago
Write a cash register program that calculates change for a restaurant of your choice. Your program should include: Ask the user
eduard

Answer:

Python Code

Explanation:

total = 0.0

change = 0.0

itemone = float(input("Enter the first price: "))

itemtwo = float(input("Enter the second price: "))

itemthree = float(input("Enter the third price: "))

total = itemone + itemtwo + itemthree

print("Total:", total)

cash = float(input("Cash given: "))

change = total - cash

print("Your change:", change)

4 0
3 years ago
Which loan type requires you to make loan payments while you’re attending school?
tigry1 [53]
Direct Subsidized Loans I believe
7 0
3 years ago
. When a function template has two parameterized types, one as the return value, and one as an argument, then _____.
mart [117]

When a function template has two parameterized types, one as the return value, and one as an argument, then THE FIRST TIME MUST BE EXPLICITLY CODED.

Explanation:

  • The act of implicit and explicit coding, and implicit and explicit code, is defined by context of execution of additional behavior or type setting/casting. Specifically, implicit or explicit methods are defined by the contexts in which they are meant to be used.
  • The explicit coding discipline favors clear and explicit expression of intent in the code.
  • The uses-cases dictate the structure of the application. What the application does should not be implicitly hidden in an organization that the framework is trying to dictate you. Avoid having folders like /controllers, /views at the highest level of folders organization, in favor of folders containing features and use-cases: /categories, /products, etc.
  • Template parameter represents a type that has not yet been specified, but that can be used in the template function as if it were a regular type.

4 0
3 years ago
Other questions:
  • It's time for you to schedule a dental checkup. The responsible thing to do is to ___
    11·1 answer
  • "write a program that reads two floating point numbers and prints their sum difference and product."
    13·1 answer
  • If you need to use a custom theme frequently, you can save a presentation file as a(n) ____ theme file.
    12·2 answers
  • If anybody knows what does this mean I will answer any questions for you and plz answer this right plz what does that envelope w
    5·2 answers
  • What is the keyboard shortcut Ctrl+Z used for?
    14·2 answers
  • Communication of a message between two processes implies which of the following? (A) Synchronization (B) Atomic operation (C) Bl
    11·1 answer
  • Assuming the Direct Hashing function and the Subtraction preprocessing algorithm is used to map keys into indices, give the inde
    15·1 answer
  • 12. In cell A14, use the INDEX function and structured references to display the value in the first row and first column of the
    8·1 answer
  • What does the following Boolean operators do?<br>AND function<br>OR function<br>NOT function​
    8·1 answer
  • Please list 15 safety rules that you think should be practiced in the Computer Technology classroom/lab.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!