1 / 22

Python Programming – Answers to Exercises (Y. D. Liang)

Includes guided answers for exercises from Liangu2019s beginner Python programming book. Ideal for learning and practice. Reach out via email or Telegram listed in document.

Nazri
Télécharger la présentation

Python Programming – Answers to Exercises (Y. D. Liang)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. You can access com pl ete docum ent on f ol l ow i ng U RL. Contact m e i f si te not l oaded ???????????????????????????????????????????????????????????????????????????? This in a PDF converted from Python .py codes for Solution Manual of following book Introduction to Programming Using Python - Y. Daniel Liang smtb98@gmail.com ??????????????????????????????????????????????????????????????????????????????????????? ??????????????????????????????????????????????????????????????????????????????????? List of Solved Exercises Exercise01_01 Exercise01_02 Exercise01_03 Exercise01_04 Exercise01_05 Exercise01_06 Exercise01_07 Exercise01_08 Exercise01_09 Exercise01_10 Exercise01_11 Exercise01_12 Exercise01_13 Exercise01_14 Exercise01_15 Exercise01_16 Exercise01_17 Exercise01_18 Exercise01_19 Exercise01_20 Exercise01_21 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

  2. Exercise01_01 print("Welcome to Python") print("Welcome to Computer Science") print("Programming is fun")

  3. Exercise01_02 print("Welcome to Python") print("Welcome to Python") print("Welcome to Python") print("Welcome to Python") print("Welcome to Python")

  4. Exercise01_01 Exercise01_03 print("FFFFFFF U U NN NN") print("FF U U NNN NN") print("FFFFFFF U U NN N NN") print("FF U U NN N NN") print("FF UUU NN NNN")

  5. Exercise01_04 print("a a^2 a^3") print("1 1 1") print("2 4 8") print("3 9 27") print("4 16 64")

  6. Exercise01_05 print((9.5 * 4.5 - 2.5 * 3) / (45.5 - 3.5))

  7. Exercise01_06 print(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9)

  8. Exercise01_07 print(4 * (1 - 1 / 3 + 1 / 5 - 1 / 7 + 1 / 9 - 1 / 11)) print(4 * (1 - 1 / 3 + 1 / 5 - 1 / 7 + 1 / 9 - 1 / 11 + 1 / 13 - 1 / 15))

  9. Exercise01_08 print(5.5 * 5.5 * 3.14159) print(2 * 5.5 * 3.14159)

  10. Exercise01_09 print(4.5 * 7.9) print(2 * (4.5 + 7.9))

  11. Exercise01_10 print((14 / 45.5) * 60 / 1.6)

  12. Exercise01_11 print(312032486 + 365 * 24 * 60 * 60 // 7 - 365 * 24 * 60 * 60 // 13 + 365 * 24 * 60 * 60 // 45) print(312032486 + 2 * 365 * 24 * 60 * 60 // 7 - 2 * 365 * 24 * 60 * 60 // 13 + 2 * 365 * 24 * 60 * 60 // 45) print(312032486 + 3 * 365 * 24 * 60 * 60 // 7 - 3 * 365 * 24 * 60 * 60 // 13 + 3 * 365 * 24 * 60 * 60 // 45) print(312032486 + 4 * 365 * 24 * 60 * 60 // 7 - 4 * 365 * 24 * 60 * 60 // 13 + 4 * 365 * 24 * 60 * 60 // 45) print(312032486 + 5 * 365 * 24 * 60 * 60 // 7 - 5 * 365 * 24 * 60 * 60 // 13 + 5 * 365 * 24 * 60 * 60 // 45)

  13. Exercise01_12 import turtle turtle.forward(50) turtle.right(90) turtle.forward(50) turtle.right(90) turtle.forward(50) turtle.right(90) turtle.forward(50) turtle.forward(50) turtle.right(90) turtle.forward(50) turtle.right(90) turtle.forward(50) turtle.right(90) turtle.forward(100) turtle.right(180) turtle.forward(50) turtle.right(90) turtle.forward(50) turtle.right(90) turtle.forward(50) turtle.right(90) turtle.forward(50) turtle.forward(50) turtle.right(90) turtle.forward(50) turtle.right(90) turtle.forward(50) turtle.done()

  14. Exercise01_13 import turtle turtle.forward(50) turtle.right(180) turtle.forward(100) turtle.right(180) turtle.forward(50) turtle.left(90) turtle.forward(50) turtle.left(180) turtle.forward(100) turtle.done()

  15. Exercise01_14 import turtle turtle.right(60) turtle.forward(50) turtle.right(120) turtle.forward(50) turtle.right(120) turtle.forward(50) turtle.done()

  16. Exercise01_16 import turtle turtle.right(60) turtle.forward(50) turtle.right(120) turtle.forward(50) turtle.right(120) turtle.forward(100) turtle.left(120) turtle.forward(50) turtle.left(120) turtle.forward(50) turtle.done()

  17. Exercise01_17 import turtle turtle.penup() turtle.goto(-50, 0) turtle.pendown() turtle.circle(50) turtle.penup() turtle.goto(-50, -2 * 50) turtle.pendown() turtle.circle(50) turtle.penup() turtle.goto(50, 0) turtle.pendown() turtle.circle(50) turtle.penup() turtle.goto(50, -2 * 50) turtle.pendown() turtle.circle(50) turtle.done()

  18. Exercise01_18 import turtle turtle.penup() turtle.goto(-39, 48) turtle.pendown() turtle.write("(-39, 48)") turtle.goto(50, -50) turtle.write("(50, -50)") turtle.done()

  19. Exercise01_19 import turtle turtle.penup() turtle.goto(0, 100 / 2) turtle.pendown() turtle.right(72) turtle.forward(100) turtle.right(144) turtle.forward(100) turtle.right(144) turtle.forward(100) turtle.right(144) turtle.forward(100) turtle.right(144) turtle.forward(100) turtle.done()

  20. Exercise01_20 import turtle turtle.penup() turtle.goto(80, 0) turtle.pendown() turtle.goto(40, -69.28) turtle.goto(-40, -69.28) turtle.goto(-80, -9.8) turtle.goto(-40, 69) turtle.goto(40, 69) turtle.goto(80, 0) turtle.hideturtle() turtle.done()

  21. Exercise01_21 import turtle turtle.penup() turtle.goto(-50, -50) turtle.pendown() turtle.goto(50, -50) turtle.goto(50, 0) turtle.goto(-50, 0) turtle.goto(-50, -50) turtle.goto(-25, -25) turtle.goto(100 -25, -25) turtle.goto(100 -25, 50 -25) turtle.goto(-25, 50 -25) turtle.goto(-25, -25) turtle.penup() turtle.goto(50, -50) turtle.pendown() turtle.goto(100 -25, -25) turtle.penup() turtle.goto(-50, 0) turtle.pendown() turtle.goto(-25, 25) turtle.penup() turtle.goto(100 -25, 25) turtle.pendown() turtle.goto(100-25 - 25, 25 - 25) turtle.hideturtle() turtle.done()

  22. Exercise01_01 import turtle turtle.color("green") turtle.goto(-50, 0) turtle.penup() turtle.goto(0, 0) turtle.pendown() turtle.color("blue") turtle.goto(60, 0) turtle.penup() turtle.goto(0, 0) turtle.pendown() turtle.color("red") turtle.goto(0, 70) turtle.color("black") turtle.penup() turtle.goto(0, -100) turtle.pendown() turtle.circle(100) turtle.penup() turtle.goto(-5, 85) turtle.pendown() turtle.write(12) turtle.penup() turtle.goto(90, 0) turtle.pendown() turtle.write(3) turtle.penup() turtle.goto(-95, 0) turtle.pendown() turtle.write(9) turtle.penup() turtle.goto(0, -100) turtle.pendown() turtle.write(6) turtle.penup() turtle.goto(-15, -115) turtle.pendown() turtle.write("9:15:00") turtle.hideturtle() turtle.done()

More Related