当前位置:   article > 正文

python第二章课后习题_获得用户输入的一个整数n,计算并输出n的32次方

获得用户输入的一个整数n,计算并输出n的32次方
  1. 2.1温度转换
  2. temp = eval(input('''请输入温度:
  3. '''))
  4. c = input("请输入符号:")
  5. if c in ['F','f']:
  6. temp = int((temp-32)/1.8)
  7. print("温度:{}".format(temp))
  8. elif c in ['c','C']:
  9. temp = int(temp*1.8+32)
  10. print("温度:{}".format(temp))
  11. else:
  12. print("error")
  13. 2.2汇率
  14. temp = eval(input('''请输入金额:
  15. '''))
  16. c = input("请输入币种:")
  17. if c == 'RMB':
  18. temp = int(temp/6)
  19. print("$:{}".format(temp))
  20. elif c == '$':
  21. temp = int(temp*6)
  22. print("RMB:{}".format(temp))
  23. else:
  24. print("error")
  25. 2.3画乌龟
  26. import turtle
  27. def draw(r,ag,len):
  28. turtle.seth(-40)
  29. # for i in range(int(len)):
  30. turtle.pencolor("blue")
  31. turtle.circle(r,ag)
  32. turtle.circle(-r,ag)
  33. turtle.pencolor("green")
  34. turtle.circle(r,ag)
  35. turtle.circle(-r,ag)
  36. turtle.pencolor("pink")
  37. turtle.circle(r,ag)
  38. turtle.circle(-r,ag)
  39. turtle.pencolor("red")
  40. turtle.circle(r,ag)
  41. turtle.circle(-r,ag)
  42. turtle.circle(r,ag/2)
  43. turtle.fd(40)
  44. turtle.circle(16,180)
  45. turtle.fd(40*2/3)
  46. turtle.setup(650,350,200,200)
  47. turtle.penup()
  48. turtle.fd(-250)
  49. turtle.pendown()
  50. turtle.pensize(25)
  51. draw(40,80,4)
  52. turtle.done()
  53. 2.4
  54. from turtle import *
  55. setup(300,400,0,0)
  56. fd(100)
  57. left(120)
  58. fd(100)
  59. left(120)
  60. fd(100)
  61. 或者
  62. from turtle import *
  63. setup(300,400,0,0)
  64. fd(100)
  65. seth(120)
  66. fd(100)
  67. seth(240)
  68. fd(100)
  69. 或者
  70. from turtle import *
  71. setup(300,400,0,0)
  72. circle(200,steps = 3)
  73. 2.5
  74. from turtle import *
  75. setup(300,400,0,0)
  76. fd(200)
  77. seth(120)
  78. fd(200)
  79. seth(240)
  80. fd(200)
  81. seth(0)
  82. fd(100)
  83. seth(60)
  84. fd(100)
  85. seth(180)
  86. fd(100)
  87. seth(-60)
  88. fd(100)
  89. 2.6
  90. from turtle import *
  91. setup(300,400,0,0)
  92. for i in range(4):
  93. penup()
  94. fd(50)
  95. pendown()
  96. fd(100)
  97. penup()
  98. fd(50)
  99. left(90)
  100. 2.8
  101. from turtle import *
  102. setup(1000,1400,0,0)
  103. a=20
  104. for i in range(20):
  105. a = a+2*i
  106. fd(a)
  107. left(90)
  108. fd(a)
  109. left(90)
  1. 2.7
  2. from turtle import *
  3. seth(30)
  4. fd(200)
  5. left(120)
  6. fd(200)
  7. left(120)
  8. fd(200)
  9. left(90)
  10. t=(200/3)*pow(3,0.5)
  11. penup()
  12. fd(t)
  13. pendown()
  14. left(90)
  15. fd(200)
  16. left(120)
  17. fd(200)
  18. left(120)
  19. fd(200)


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/621421
推荐阅读
相关标签
  

闽ICP备14008679号