Explore Westonci.ca, the leading Q&A site where experts provide accurate and helpful answers to all your questions. Connect with a community of professionals ready to provide precise solutions to your questions quickly and accurately. Get quick and reliable solutions to your questions from a community of experienced experts on our platform.
Sagot :
Answer:
import math
n = int(input("Enter n: "))
for number in range(1, n+1):
if number % 2 == 1:
print("{:.2f}".format(math.sqrt(number)), end=" ")
Explanation:
In order to calculate the square roots of the numbers, import math. Note that math.sqrt() calculates and gives the square root of the given number as a parameter
Ask the user to enter the n
Create a for loop that iterates from 1 to n+1 (Since n is included, you need to write n+1)
Inside the loop, check whether the number is odd or not using the if structure and modulo. If the number is odd, calculate its square root using the math.sqrt() and print the result with two digits after the decimal
Thank you for visiting. Our goal is to provide the most accurate answers for all your informational needs. Come back soon. Thank you for choosing our platform. We're dedicated to providing the best answers for all your questions. Visit us again. Find reliable answers at Westonci.ca. Visit us again for the latest updates and expert advice.