4. 2. Fix challenge 2 (python) Note : Your arguments are strings unless they are
ID: 3725748 • Letter: 4
Question
4. 2. Fix challenge 2 (python)
Note: Your arguments are strings unless they are converted into some other type. In this challenge, we are using decimals (float) rather than integers (int) for our type. So, you will need to tell Python to treat the variables as floating point decimal numbers by putting float(variable) in at the correct times.
Fix the broken code:
# Input from the command line
import sys
A = sys.argv[1]
B = sys.argv[2]
C = sys.argv[3]
# Your code goes here
num = A * (B + C/3
# Outputs
print ( num
Explanation / Answer
import sys
A = sys.argv[1]
B = sys.argv[2]
C = sys.argv[3]
# Your code goes here
A = float(A)
B = float(B)
C = float(C)
num = A * (B + C/3)
# Outputs
print ( num)
Output:
Arguements 1.1 2.2 3.3
3.63
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.