Advertisement
Guest User

Untitled

a guest
Nov 7th, 2016
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. import math
  2. # BEGIN (write your solution here)
  3. x = input('x=')
  4. figure = input('figure=')
  5. square = 0.0
  6.  
  7. try:
  8. x = float(x)
  9. except:
  10. print ('error')
  11. exit(1)
  12.  
  13. if x <= 0:
  14. print ('error')
  15. exit(1)
  16.  
  17. if figure == 'circle':
  18. square = math.pi * x * x
  19. print ('The area is %.2f' % square)
  20. exit(0)
  21. elif figure == 'square':
  22. square = x * x
  23. print ('The area is %.2f' % square)
  24. exit(0)
  25. else:
  26. print ('error')
  27. exit(1)
  28. # END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement