Tuesday, November 19, 2024
Google search engine
HomeLanguagesPython – turtle.radians()

Python – turtle.radians()

The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support.

turtle.radians()

This method is used to set the angle measurement units to radians. It doesn’t require any argument. By default the angle measurement unit is “degrees”.

Syntax : turtle.radians() 
Parameter : None 
Returns : None 
 

Below is the implementation of above method with some examples :

Example 1 : 

python3




# importing package
import turtle
 
# move as default in degrees
turtle.left(90)
 
# take value by heading
print(turtle.heading())
 
# set to radians
turtle.radians()
 
# again take value by heading
print(turtle.heading())


Output : 

90.0
1.5707963267948966

Example 2 : 

python3




# importing package
import turtle
 
# set to radians
turtle.radians()
 
# turn to left by 90
turtle.left(90)
 
# move forward by 100
turtle.forward(100)


Output : 

 

If the measurement unit is in degrees than it give shape turn to left by 90 degrees and a forward by 100. But after setting measurement unit to radians it is clearly see that it move to 90 radians = 5156.62 degrees (14 x 360 + 116.62) than a forward by 100 units.

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments