Module #4 Assignment: Roots & Reciprocals
Overall, I was able to complete this assignment easily. I only had to figure out a few issues regarding the format of my output (and gave myself a mini refresher on the quadratic formula.) I also began to incorporate comments into my code. This will help me in the future when reviewing my work.
Roots
Roots |
The first part of this assignment was to create code to compute and print both roots of the quadratic equation x^2-5.86 x+ 8.5408. This part required the use of import math and the square root function. For my answer, I decided to include both answers rounded to two decimal places and not rounded up.
Reciprocals
Reciprocals |
The last part of this assignment asked us to use a for loop to print the decimal representations of fractions 1/2 to 1/10, one on each line. The biggest issue I had with this part was formatting the answers. I wanted to figure out how to print out both the fraction and the decimal for each. After some research, I decided to go with the f-string method which from my understanding is a newer way to format strings in Python. F-strings require the letter f followed by an opening and closing curly brace.
Comments
Post a Comment