Python Programming – Answers to Exercises (Y. D. Liang)
0 likes | 4 Vues
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.
Python Programming – Answers to Exercises (Y. D. Liang)
E N D
Presentation Transcript
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
Exercise01_01 print("Welcome to Python") print("Welcome to Computer Science") print("Programming is fun")
Exercise01_02 print("Welcome to Python") print("Welcome to Python") print("Welcome to Python") print("Welcome to Python") print("Welcome to Python")
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")
Exercise01_04 print("a a^2 a^3") print("1 1 1") print("2 4 8") print("3 9 27") print("4 16 64")
Exercise01_05 print((9.5 * 4.5 - 2.5 * 3) / (45.5 - 3.5))
Exercise01_06 print(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9)
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))
Exercise01_08 print(5.5 * 5.5 * 3.14159) print(2 * 5.5 * 3.14159)
Exercise01_09 print(4.5 * 7.9) print(2 * (4.5 + 7.9))
Exercise01_10 print((14 / 45.5) * 60 / 1.6)
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)
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()
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()
Exercise01_14 import turtle turtle.right(60) turtle.forward(50) turtle.right(120) turtle.forward(50) turtle.right(120) turtle.forward(50) turtle.done()
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()
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()
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()
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()
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()
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()
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()