From edc90a644fe653a2de535cb63d3f88e57bec93cc Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Fri, 5 Mar 2021 15:13:00 -0500 Subject: [PATCH 1/3] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/course/foundation/03_development_tools.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/course/foundation/03_development_tools.md b/docs/course/foundation/03_development_tools.md index 1d9079e..d888109 100644 --- a/docs/course/foundation/03_development_tools.md +++ b/docs/course/foundation/03_development_tools.md @@ -27,7 +27,7 @@ IDLE 运行界面与使用控制台的运行界面是相同的,只是 IDLE 的 ## IntelliJ IDEA 和 PyCharm Jetbrains 有很多开发工具,其中最核心的就是 IntellIJ IDEA。 -## IntellIJ IDEA 和 PyCharm 的关系 +### IntellIJ IDEA 和 PyCharm 的关系 如果你计算机中已经安装了 IntellIJ IDEA Ultimate 版本的话,你可以在 IntellIJ IDEA 中通过安装插件的方式扩展 Python,然后就能达到和 PyCharm 一样的功能了。 From 003ea2f9d47cd6407fbb4d95153f32926e401a39 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Fri, 5 Mar 2021 15:34:06 -0500 Subject: [PATCH 2/3] =?UTF-8?q?=E5=B0=86=E6=B5=8B=E8=AF=95=E7=9A=84?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=BF=9B=E8=A1=8C=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/HelloWorld.py | 9 +++ tests/USAFlag.py | 140 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 tests/HelloWorld.py create mode 100644 tests/USAFlag.py diff --git a/tests/HelloWorld.py b/tests/HelloWorld.py new file mode 100644 index 0000000..59565af --- /dev/null +++ b/tests/HelloWorld.py @@ -0,0 +1,9 @@ +# 第一个 Python 程序 - Hello, World! +# Version: 0.1 +# Author: YuCheng Hu + + +print('hello, world!') +print('你好', '世界') +print('hello', 'world', sep=', ', end='!') +print('goodbye, world', end='!\n') diff --git a/tests/USAFlag.py b/tests/USAFlag.py new file mode 100644 index 0000000..894c9be --- /dev/null +++ b/tests/USAFlag.py @@ -0,0 +1,140 @@ +# Python script to create USA flag using turtle. +# Author - https://www.ossez.com + +import turtle +import time + +# create a screen +screen = turtle.getscreen() +# set background color of screen +screen.bgcolor("white") +# set tile of screen +screen.title("USA Flag - https://www.ossez.com") +# "Yesterday is history, tomorrow is a mystery, +# but today is a gift. That is why it is called the present.” +# — Oogway to Po, under the peach tree, Kung Fu Panda Movie +oogway = turtle.Turtle() +# set the cursor/turtle speed. Higher value, faster is the turtle +oogway.speed(100) +oogway.penup() +# decide the shape of cursor/turtle +oogway.shape("turtle") + +# flag height to width ratio is 1:1.9 +flag_height = 250 +flag_width = 475 + +# starting points +# start from the first quardant, half of flag width and half of flag height +start_x = -237 +start_y = 125 + +# For red and white stripes (total 13 stripes in flag), each strip width will be flag_height/13 = 19.2 approx +stripe_height = flag_height / 13 +stripe_width = flag_width + +# length of one arm of star +star_size = 10 + + +def draw_fill_rectangle(x, y, height, width, color): + oogway.goto(x, y) + oogway.pendown() + oogway.color(color) + oogway.begin_fill() + oogway.forward(width) + oogway.right(90) + oogway.forward(height) + oogway.right(90) + oogway.forward(width) + oogway.right(90) + oogway.forward(height) + oogway.right(90) + oogway.end_fill() + oogway.penup() + + +def draw_star(x, y, color, length): + oogway.goto(x, y) + oogway.setheading(0) + oogway.pendown() + oogway.begin_fill() + oogway.color(color) + for turn in range(0, 5): + oogway.forward(length) + oogway.right(144) + oogway.forward(length) + oogway.right(144) + oogway.end_fill() + oogway.penup() + + +# this function is used to create 13 red and white stripes of flag +def draw_stripes(): + x = start_x + y = start_y + # we need to draw total 13 stripes, 7 red and 6 white + # so we first create, 6 red and 6 white stripes alternatively + for stripe in range(0, 6): + for color in ["red", "white"]: + draw_fill_rectangle(x, y, stripe_height, stripe_width, color) + # decrease value of y by stripe_height + y = y - stripe_height + + # create last red stripe + draw_fill_rectangle(x, y, stripe_height, stripe_width, 'red') + y = y - stripe_height + + +# this function create navy color square +# height = 7/13 of flag_height +# width = 0.76 * flag_height +# check references section for these values +def draw_square(): + square_height = (7 / 13) * flag_height + square_width = (0.76) * flag_height + draw_fill_rectangle(start_x, start_y, square_height, square_width, 'navy') + + +def draw_six_stars_rows(): + gap_between_stars = 30 + gap_between_lines = stripe_height + 6 + y = 112 + # create 5 rows of stars + for row in range(0, 5): + x = -222 + # create 6 stars in each row + for star in range(0, 6): + draw_star(x, y, 'white', star_size) + x = x + gap_between_stars + y = y - gap_between_lines + + +def draw_five_stars_rows(): + gap_between_stars = 30 + gap_between_lines = stripe_height + 6 + y = 100 + # create 4 rows of stars + for row in range(0, 4): + x = -206 + # create 5 stars in each row + for star in range(0, 5): + draw_star(x, y, 'white', star_size) + x = x + gap_between_stars + y = y - gap_between_lines + + +# start after 5 seconds. +time.sleep(5) +# draw 13 stripes +draw_stripes() +# draw squares to hold stars +draw_square() +# draw 30 stars, 6 * 5 +draw_six_stars_rows() +# draw 20 stars, 5 * 4. total 50 stars representing 50 states of USA +draw_five_stars_rows() +# hide the cursor/turtle +oogway.hideturtle() +# keep holding the screen until closed manually +screen.mainloop() From ac755fc7d53ff8a0865fb29082e3d7bf6edd1362 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Fri, 5 Mar 2021 16:06:29 -0500 Subject: [PATCH 3/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20VSC=20=E5=AE=89?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/course/foundation/03_development_tools.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/course/foundation/03_development_tools.md b/docs/course/foundation/03_development_tools.md index d888109..63266be 100644 --- a/docs/course/foundation/03_development_tools.md +++ b/docs/course/foundation/03_development_tools.md @@ -69,3 +69,7 @@ Jetbrains 有很多开发工具,其中最核心的就是 IntellIJ IDEA。 在下面的链接中,我们针对一些常见的问题进行了总结,通常这些可能都是初学者容易遇到的问题。 * [IntelliJ 安装 Python 插件](https://www.ossez.com/t/intellij-python/114) * [IntelliJ 配置 Python 项目提示 no python interpreter](https://www.ossez.com/t/intellij-python-no-python-interpreter/125) + + +## Visual Studio Code +Visual Studio Code 是一个免费的 \ No newline at end of file