Skip to content

added more code #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions CodeHS/2/10/4/Bubble-Wrap-2.0-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""
This code will fill the canvas with light blue circles with a white highlight
"""
speed(0)
## This function will draw one row of 10 circles
def draw_circle_row():
for i in range(10):
pendown()
begin_fill()
color("light blue")
circle(20)
end_fill()
penup()
forward(40)
## This function will move Tracy from end of row up to beginning of the row on top
def move_up_a_row():
left(90)
forward(40)
right(90)
backward(400)
## This creates a white highlight in the top right blue circle
def make_highlight():
for i in range(10):
pendown()
color("light blue")
circle(10,90)
color("white")
circle(10,90)
color("light blue")
circle(10,180)
penup()
forward(40)
## Send Tracy to starting position in bottom left corner
penup()
setposition(-180,-200)
# Call circle drawing function 10 times to fill ten rows
for i in range(10):
draw_circle_row()
move_up_a_row()
## Create the highlights
penup()
setposition(-180, -190)
for i in range(10):
make_highlight()
move_up_a_row()
18 changes: 18 additions & 0 deletions CodeHS/2/10/5/Sidewalk-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
penup()
setposition(-200,-200)
speed(0)
def draw_square():
for i in range(4):
pendown()
forward(50)
left(90)
def draw_row():
for i in range(8):
draw_square()
penup()
forward(50)
def draw_sidewalk():
for i in range(4):
draw_row()
left(90)
draw_sidewalk()
13 changes: 13 additions & 0 deletions CodeHS/2/11/4/Dartboard-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
speed(0)
radius = 25
circle(radius)
def init():
penup()
right(90)
forward(25)
left(90)
for i in range(3):
init()
pendown()
radius = radius + 25
circle(radius)
16 changes: 16 additions & 0 deletions CodeHS/2/11/5/Line-of-increasing-Blocks-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
speed(0)
penup()
setposition(-150,0)
pendown()

def make_square():
length = 10
for i in range(5):
for i in range(4):
pendown()
forward(length)
left(90)
penup()
forward(length * 2)
length = length + 10
make_square()
21 changes: 21 additions & 0 deletions CodeHS/2/12/4/Colored-Dartboard-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
Draws 4 circles
"""
speed(0)
radius = 125
penup()
right(90)
forward(100)
left(90)
for i in range(4): ## Draws a circle with radius and color_choice color. repeats 4 times
pendown()
radius = radius - 25
color_choice = input("Color of the circle?: ")
color(color_choice)
begin_fill()
circle(radius)
end_fill()
penup()
left(90)
forward(25)
right(90)
38 changes: 38 additions & 0 deletions CodeHS/2/17/4/Rating-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
This code will draw a symbol depending on the rating given. A red x mark will
be drawn if the rating is less than or equal to 4, a yellow line will be drawn
if the rating is in between 5 including 5 and 7 including 7. Else, a check will be
drawn
"""
speed(0)
penup()
pensize(10)
rating=int(input("Rating? (1-10): "))
def draw_x(): ## draws a red "x"
left(45)
color("red")
pendown()
for i in range(4):
forward(40)
backward(40)
left(90)
def draw_line(): ## draws a yellow line
pendown()
color("yellow")
backward(30)
forward(60)
def draw_check(): ## draws a green check
right(45)
backward(30)
pendown()
color("green")
forward(30)
left(90)
forward(60)
## check the rating to determine what symbol to draw
if rating <= 4:
draw_x()
elif rating >=5 and rating <=7:
draw_line()
else:
draw_check()
20 changes: 20 additions & 0 deletions CodeHS/2/18/4/Increasing-Squares-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
speed(0)
penup()
length=0
def move_to_position():
penup()
backward(25)
right(90)
forward(25)
left(90)
def make_square():
pendown()
for i in range(4):
forward(length)
left(90)
penup()
while length < 400:
penup()
make_square()
move_to_position()
length = length + 50
13 changes: 13 additions & 0 deletions CodeHS/2/18/5/Guess-a-Number-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
speed(0)
secret_number = 5
def draw_check(): ##Draws the green check mark
right(45)
color("green")
pensize(10)
backward(50)
forward(50)
left(90)
forward(100)
while int(input("Give a number (1-10): ")) != secret_number: ## Do not save the input as user_input. codehs crashed
print("Try again")
draw_check()
17 changes: 17 additions & 0 deletions CodeHS/2/19/4/Guess-a-Number-2.0-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
speed(0)
secret_number = 5
user_input = int(input("Give a number (1-10): "))
def draw_check(): ##Draws the green check mark
right(45)
color("green")
pensize(10)
backward(50)
forward(50)
left(90)
forward(100)
while user_input != secret_number: ## Do not save the input as user_input. codehs crashed
if user_input < secret_number: ## CodeHS compiler broke.
print("guess higher!")
else:
print("guess lower!")
draw_check()
23 changes: 23 additions & 0 deletions CodeHS/2/19/5/Circle_Pyramid_2.0-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
speed(0)
radius = 25
count = 1
row_value = int(input("How many circles (1-8) would you like on the bottom? "))
x_value = -((row_value*(radius*2))/2)+25
y_value = -225 + (count*radius)
def moveup():
setposition(x_value,y_value)
penup()
moveup()
def draw_row():
for i in range(row_value):
pendown()
circle(radius)
penup()
forward(radius*2)
for i in range(row_value):
draw_row()
count = count + 1
y_value = -225 + ((count*radius)*2)-25
x_value = -((row_value*(radius*2))/2)+50
moveup()
row_value=row_value-1
34 changes: 34 additions & 0 deletions CodeHS/2/19/6/Checkerboard-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
speed(0)
setposition(-200,-200)
def make_square(color_square): ##Creates one square 40x40 pixels with color color_square
color(color_square)
begin_fill()
for i in range(4):
forward(40)
left(90)
end_fill()
def make_row(first_color, second_color): ## creates a row of 10 squares with alternating colors between first_color and second_color
mod_check=0
for i in range(10):
if mod_check%2==0:
make_square(first_color)
else:
make_square(second_color)
forward(40)
mod_check=mod_check+1
def up_a_row(): ## moves tracy up a row
penup()
backward(400)
left(90)
forward(40)
right(90)
def make_two_rows(): ## makes a row with red,black and a row on top of it with black,red
make_row("red", "black")
up_a_row()
make_row("black", "red")
def make_checkerboard(): ##makes the checker board using make_two_rows and up_a_row
for i in range(5):
make_two_rows()
up_a_row()
make_checkerboard()

3 changes: 3 additions & 0 deletions CodeHS/2/5/5/Hexagon-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
for i in range(6):
forward(50)
left(60)
5 changes: 5 additions & 0 deletions CodeHS/2/5/6/X-Marks-The-Spot-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
left(45)
for i in range(4):
left(90)
forward(100)
backward(100)
19 changes: 19 additions & 0 deletions CodeHS/2/5/7/Circle-Pyramid-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
speed(0)
penup()
setposition(-100, -200)
for i in range(3):
pendown()
circle(50)
penup()
forward(100)
setposition(-50, -100)
for i in range(2):
pendown()
circle(50)
penup()
forward(100)
setposition(0, 0)
pendown()
circle(50)
penup()
forward(100)
23 changes: 23 additions & 0 deletions CodeHS/2/6/4/Circle-Pyramid-With-Comments-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
penup()
setposition(-100, -200)
## Makes the bottom three circles.
for i in range(3):
pendown()
circle(50)
penup()
forward(100)
setposition(-50, -100)
## Makes the middle two circles.
for i in range(2):
pendown()
circle(50)
penup()
forward(100)
"""
Makes the last circle.
"""
setposition(0, 0)
pendown()
circle(50)
penup()
forward(100)
12 changes: 12 additions & 0 deletions CodeHS/2/8/4/Beaded-Bracelet-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
speed(0)
def make_half_bracelet():
for i in range(18):
left(10)
penup()
forward(100)
pendown()
circle(10)
penup()
backward(100)
for i in range(2):
make_half_bracelet()
22 changes: 22 additions & 0 deletions CodeHS/2/8/5/Shape-Stack-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
speed(0)
penup()
setposition(-25, -200)
def square_circle_stack():
pendown()
for i in range(4):
forward(50)
left(90)
penup()
left(90)
forward(50)
right(90)
forward(25)
pendown()
circle(25)
penup()
backward(25)
left(90)
forward(50)
right(90)
for i in range(4):
square_circle_stack()
17 changes: 17 additions & 0 deletions CodeHS/2/9/5/Four-Colored-Triangles-Travis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
speed(0)
pensize(5)
color("red")
penup()
backward(100)
pendown()
forward(200)
penup()
left(120)
for i in range(4):
pendown()
color("blue")
forward(50)
left(120)
color("green")
forward(50)
right(120)
Loading