Python Programming for Raspberry Pi, Sams Teach Yourself in 24 Hours

(singke) #1
2. You must import the Python math library in order to use the Python trigonometric functions.
True or false?
3. How do you create a fraction by using the Fraction class in Python?

Answers


1. You should use the sqrt() function to find the square root of a value.
2. True. The Python standard library only supports standard math functions and features. You’ll
need to import the separate math library module to use any of the more advanced math features
such as working with trigonometric functions.
3. The Fraction class uses the Fraction() method to create a fraction value. The format of
the Fraction() method is Fraction(numerator, denominator), which specifies
the numerator and the denominator of the fraction as separate values.
Free download pdf