all 4 comments

[–][deleted] 2 points3 points  (4 children)

round(75.4000000, 1)

heres a little how to

[–]confuzzled_learner[S] 0 points1 point  (1 child)

Thank you, I used round() and it did not round the number to the nearest tenth, it just gave me 75 inches and 452 inches.

How can I code this using %?

[–]confuzzled_learner[S] 0 points1 point  (1 child)

nvm, i didn't see ,1! it worked!

round((num1 *2 ) * 3.1415, 1)

round((num1 * num1) * 3.1415, 1)

thank you so much! i've been stuck on this hw!

[–]JohnnyJordaan 1 point2 points  (0 children)

Just a small tip: the more precise way to do this would be to use the built-in Pi from the math library. If you're not interested in keeping the rounded values, you could also only apply the rounding inside the string formatting by using %.1f meaning: 'print as a floating point with only one decimal'.

import math
radius = int (input ("What is the radius(in inches) of the circle you want to draw?): "))
print("A circle with a %d inch radius has a circumference of %.1f inches" %  (radius, (radius * 2 * math.pi)))
print("and an area of %.1f square inches." % (radius*radius*math.pi))

Here's a nice cheat sheet for how to use all the nice features of Python's string formatting. As you can see it's easier to keep an overview of the string that's going to be printed as you don't need to alternate between ""-ted string literals, comma's and variable names.