Question: 3 _ - / vozkspace / controlflow - programs $ python 3 root.py 3 2 1 e - 1 5 1 . 2 5 9

3_-/vozkspace/controlflow-programs
$ python3
root.py 321e-15
1.2599210498948732
$ python3 root. py 3271e-15
3.0
Problem 9.(Sum of Powers) Write a program called sum_of_powers.py that accepts n(int) and k(int) as command-line
arguments, and writes to standard output the sum 1k+2k+cdots+nk.
--/workspace/controlflou-programs
$ python3 sum_of-powers.py 151
120
8 python3 sum_of_powers.py 103
3025
Problem 7.(Greatest Common Divisor) Write a program called
gcd.py that accepts p(int) and q(int) as command-line
arguments, and writes to standard output the greatest common divisor (GCD) of p and q.
3_*/workspace/controlflou-programs
$ python3
gcd.py 4081440
24
$ python3 gcd:py 2122
1
Problem 8.(Root Finding) Write a program called
root.py (a variant of the
sqrt.py program we dicussed in class) that accepts
k(int),c(float), and epsilon (float) as command-line arguments, and writes to standard output the k th root of c, up to
epsilon decimal places.
3--/workspace/controlf1ow-programs
$ python3
root.py 321e-15
1.2599210498948732
$.python3
root.py 3271e-15
Problem 9.(Sum of Powers) Write a program called sum_of_powers.py that accepts n(int) and k(int) as command-line
arguments, and writes to standard output the sum 1k+2k+cdots+nk.
-/workspace/controlf1oy-programs
$ python3 sum_of_powers, py 151
120
$ python3 sum_of_powers.py 103
3 _ - / vozkspace / controlflow - programs $

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!