Our tasks at school is to add a test example of the program at the bottom of the code with:
#example
"""
<insert example of you running the code>
"""
but when I do so, I get error. I never get it on any other codes, only on this one?:
C:\Users\David>C:\Users\David\Desktop\IN1900\uke38\qerror.py 1
File "C:\Users\David\Desktop\IN1900\uke38\qerror.py", line 22
"""
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 24-25: truncated \UXXXXXXXX escape
C:\Users\David>
My code is as following:
from math import sqrt
import sys
a=float(sys.argv[1])
b=float(sys.argv[2])
c=float(sys.argv[3])
d=(b**2)-(4*a*c)
x1=((-b+sqrt(d))/(2*a))
x2=((-b-sqrt(d))/(2*a))
print(f'The quadratic formula with used values gives two roots {x1:.1f} and {x2:.1f}')
#example
"""
#Fra command prompt:
#C:\Users\David>C:\Users\David\Desktop\IN1900\uke38\quadratic_roots_cml.py 1 0 -1
#The quadratic formula with used values gives two roots 1.0 and -1.0
#(koden funker ikke på et eller annet magisk vis når jeg bruker
"""