Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Convert between degrees and radians
# -*- coding: utf8 -*- from math import pi pic = 'π' #only radians to degrees mode works online; the glitches with the online interpreter prevents the degrees mode from working. if raw_input('Convert from Deg or Rad? > ').lower() == 'deg': ans = (pi/180)*float(raw_input('How many degrees?\n > ')) print str(ans) + '\nor\n' + str(ans/pi) + pic else: uin = raw_input('How many radians? ex: \'0.24 pi\' and \'0.75498\' are acceptible input.\nIt is more accurate to enter input with pi (0.25 pi, 1.34 pi etc...), fractions can also be used.\n > ').split(' ') try: if uin[1] == 'pi': try: dev = uin[0].split('/') ans = (180/pi)*((float(dev[0])*pi) / float(dev[1])) except: ans = (180/pi)*(float(uin[0])*pi) except: try: dev = uin[0].split('/') ans = (180/pi)*(float(dev[0]) / float(dev[1])) except: ans = (180/pi)*float(uin[0]) print str(ans) + '°'
run
|
edit
|
history
|
help
0
Dictionary comprehension - convert to lowercase
check if any permutations of a word is a palindrome - python
Aufgabe 15
Speed up Python2 nested loops with XOR
PyMap
1 code
Printing
PySet
a
Demo - Test