Skip to content

Commit

Permalink
Merge pull request #8 from silshack/gh-pages
Browse files Browse the repository at this point in the history
Before Weekend Break
  • Loading branch information
jpulliza committed Oct 11, 2013
2 parents 4737fd3 + 080bfef commit 1b12427
Show file tree
Hide file tree
Showing 42 changed files with 1,345 additions and 1 deletion.
34 changes: 34 additions & 0 deletions _posts/2013-09-30-JaleesaIOAssignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
layout: post
author: jpowell
categories: post
title: I/O Assignment
---

Here's my screenshot:

![IOScreenshot](http://i947.photobucket.com/albums/ad316/dieschwarzeskobra/Screenshotfrom2013-09-30190559_zps1ee3c498.png)

``` python
def add_names(list_of_names, file):
"""
Opens and adds a list of names to the end of a file, each on its own line
"""
# We open a file in 'a' mode, for appending to it.
names_file = open(file, 'a')

# For each line in the list, we print that to the file.
# This assumes one file per line.
for name in list_of_names:
print >> names_file, name

# Close the file so the changes are visible.
names_file.close()


# Exercise: make new_names customizible:
new_names = input('Enter a list of names: ')

# Exercise: make the file name used here customizible:
add_names(new_names, input('Enter the file name: '))
```
37 changes: 37 additions & 0 deletions _posts/2013-09-30-input-output-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
layout: post
author: kshaffer
categories: post
---

Below is my code for the IO exercise from class today.

```python
def add_names(list_of_names, file):
"""
Opens and adds a list of names to the end of a file, each on its own line
"""
# We open a file in 'a' mode, for appending to it.
names_file = open(file, 'a')

# For each line in the list, we print that to the file.
# This assumes one file per line.
for name in list_of_names:
print >> names_file, name

# Close the file so the changes are visible.
names_file.close()


# Exercise: make new_names customizible:
# Accept keyboard input from user and assign
# to variable new_names.
new_names = input("Enter a list of names: ")

# Exercise: make the file name used here customizible:
# Accept keyboard input from the user and assign
# to variable filename. Then pass new variable filename
# to function add_names as second argument.
filename = input("Enter a file name: ")
add_names(new_names, filename)
```
27 changes: 27 additions & 0 deletions _posts/2013-09-30-input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
layout: post
username: jgeer
categories: post
---

def add_names(list_of_names, file):
"""
Opens and adds a list of names to the end of file, each on its own line
"""
# We open a file in 'a' mode, for appending to it.
names_file =open(file, 'a')

# For each line in the list, we print that to the file.
# This assumes one file per line.
for name in list_of_names:
print >> names+files, name

# Close the file so the changes are visible.
names_file.close()

# Exercise: make new_names customizable:
new_names= input('Enter a list of names: ')

# Exercise: make the file name used here customizable:
new_file= input('Enter a file: ')
add_names(new_names, new_file)
9 changes: 9 additions & 0 deletions _posts/2013-09-30-python-program.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
layout: post
author: mbaxter
category: post
---
Here is the screenshot of my terminal window after finishing Exercise Two:
![Ubuntu Screenshot](https://lh4.googleusercontent.com/-tEca61KR_-Y/UkmAn-UgcqI/AAAAAAAAAV0/CcMleZaBLfw/w607-h322-no/Screen+Shot+2013-09-30+at+9.21.54+AM.png "Ubuntu Screenshot")

A little shoutout to Grant for helping me, with great patience, on that exercise!
37 changes: 37 additions & 0 deletions _posts/2013-09-30-zekuny-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: Exercise
layout: post
author: zekuny
categories: post
---


Exercise codes:

```python

def add_names(list_of_names, file):
"""
Opens and adds a list of names to the end of a file, each on its own line
"""
# We open a file in 'a' mode, for appending to it.
names_file = open(file, 'a')

# For each line in the list, we print that to the file.
# This assumes one file per line.
for name in list_of_names:
print >> names_file, name
print name + " written to file"

# Close the file so the changes are visible.
print "The names have been added successfully"
names_file.close()


# Exercise: make new_names customizible:
new_names = input('Enter a list of names:')

# Exercise: make the file name used here customizible:
file_name = input('Enter a file name:')
add_names(new_names, file_name)
```
22 changes: 22 additions & 0 deletions _posts/2013-10-10-turtlehack-assignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
layout: post
author: kshaffer
categories: post
---

Here's the graphic:

![](http://i.imgur.com/C3ofI79.png)

And here's the code:

```python
import turtle
from turtlehack import *

samo = turtle.Turtle()

for i in range(0, 10):
random_location = (samo, i, i)
n_sided_polygon(samo, 6, color = random_color(), line_thickness = 5, line_length = 80)
```
29 changes: 29 additions & 0 deletions _posts/2013-10-11-Caroline's-Turtlehack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
layout: post
author: carolinp
categories: post
---

![my python turtlehack drawing](https://lh3.googleusercontent.com/--wt2U_IdVP4/Ulg1miqTcjI/AAAAAAAAAMk/e094NHv7i-U/w737-h553-no/python_turtlehack.png)

```python

import turtle
import random
from turtlehack import *
lisa = turtle.Turtle()

size = 50
for i in range(10):
colored_square(lisa, size, random_color())
size += 10

for i in range(3):
lisa.forward(75)
lisa.left(120)
lisa.color(random_color())
random_circle(lisa, 5, 10)


```

35 changes: 35 additions & 0 deletions _posts/2013-10-11-turtlehack-assignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: assignment
layout: post
author: zekuny
categories: post
---

Codes:

```python

import turtle
from turtlehack import *
import random

focus=turtle.Turtle()

for i in range(random.randint(0,10)):
random_location(focus, 300, 300)
focus.color(random_color())
random_circle(focus, 5, 15)

for i in range(random.randint(0,5)):
colored_square(focus, 50, random_color())

random_location(focus,300,300)

for i in range(random.randint(0,8)):
n_sided_polygon(focus,8,color=random_color(),line_thickness=3,line_length=80)

for i in range(random.randint(0,12)):
n_sided_polygon(focus,8,color=random_color(),line_thickness=3,line_length=80)
```

![Image](https://pbs.twimg.com/media/BWUlsfOCcAAO4zi.jpg)
33 changes: 33 additions & 0 deletions _posts/2013-9-30-Caroline's-Python-Names.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
layout: post
author: carolinp
categories: post
---


```python
def add_names(list_of_names, file):
"""
Opens and adds a list of names to the end of a file, each on its own line
"""
# We open a file in 'a' mode, for appending to it.
names_file = open(file, 'a')

# For each line in the list, we print that to the file.
# This assumes one file per line.
for name in list_of_names:
print >> names_file, name

# Close the file so the changes are visible.
print 'awesome'
names_file.close()


# Exercise: make new_names customizible:
new_names = input('Enter a list of names: ')

# Exercise: make the file name used here customizible:
file_name = input('Enter a file name: ')
add_names(new_names, file_name)

```
30 changes: 30 additions & 0 deletions _posts/alexharding/2013-09-30-alex-addnames.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
layout: post
author: alexharding
published: true
---






#My Code

What follows is my python code which allows the user to add their own list of names and choose a file name to write out to.

```
def add_names(list_of_names, file):
names_file = open(file, 'a')
for name in list_of_names:
print >> names_file, name
names_file.close()
new_names = input('Type a list of names. ')
file_name = input('Type a file name ')+'.txt'
add_names(new_names,file_name)
print 'This program created '+str(file_name)+' in your home directory.'
```
59 changes: 59 additions & 0 deletions _posts/alexharding/2013-10-11-alex's-turtle-triangles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
layout: post
author: alexharding
published: true
---

# Right triangles!

I decided to try and make a function that builds regular right triangles. Everone's familiar with the grade-school idea of the pythagorean theorem, with a^2 + b^2 = c^2.
So I wrote a function that takes three inputs... a width, a height and a direction. The width and height make up the right angle of the triangle, and the function creates the hypotenuse.
The direction input decides which direction it draws in, or which side the right angle will face.

Instead of making this only work with standard triangles (45/45/90 or 30/60/90), I brushed up on geometry and trig a little to make it work for any two lengths. The function requires some math importing to get this to work.

At the end of each triangle, the turtle gets reset to the home position.

There're other things that could be added to this for fun... right now it only draws right and left, making it able to flip up or down would be cool. Or add a fill component so it fills a color too. Lots of fun to be had!
#Function

```
import turtle
from math import sqrt, asin, pi
def right_triangle(height,width,direction):
# takes direction to mean which side of the triangle will have the hypoteneuse
# using pythagorean theorem: hyp is the sqrt of height^2 + width^2
hypotenuse=sqrt((height**2)+(width**2))
# using radians for sin functions
turtle.radians()
if direction == 'right':
turtle.forward(width)
#90 degrees in radians
turtle.setheading(1.57079633)
turtle.forward(height)
#pi is 180 degrees in radians, arcsin of side over hypotenuse equals angle
turtle.setheading(pi+asin(height/hypotenuse))
turtle.forward(hypotenuse)
turtle.home()
if direction =='left':
turtle.setheading(pi)
turtle.forward(width)
#90 degrees in radians
turtle.setheading(1.57079633)
turtle.forward(height)
#arcsin of side over hypotenuse equals angle, subtracted
turtle.setheading(-asin(height/hypotenuse))
turtle.forward(hypotenuse)
turtle.home()
```


#Screenshot
![](http://i.imgur.com/v3bk98n.png)
10 changes: 10 additions & 0 deletions _posts/asherman/2013-09-30-asherman-ioexercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: I/O Exercise
layout: post
author: asherman
categories: post
---

Thanks for the help Michelle!

![Ubuntu Screenshot](http://farm8.staticflickr.com/7345/10030634034_5d19e2f02e.jpg)
18 changes: 18 additions & 0 deletions _posts/ashmbrown/2013-09-30-Input-Output-Exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: Input/Output In-Class Exercise
layout: post
author: abrown
categories: post
---
Greetings programmers-to-be,

I’ve attached my screenshots for today’s in-class assignment. Today was a bit of a struggle for me. I don’t think it helps that I have a nasty head cold that is also not allowing me to process information as well. Additionally, I get overwhelmed when it seems like others are picking this up way faster than I am. However, today I appreciated our discussion about breaking things into smaller pieces and taking it step-by-step. And I think step-by-step is also how I will slowly but surely will start to understand things. I need to do things several times before they click – so that means writing the same pieces of code and doing the same exercises over and over again.

Anyway, enough babbling on my part… here are my screenshots:

![input_output_number1](https://lh5.googleusercontent.com/-q86FrQvDtz4/UkoPno_B81I/AAAAAAAAAJ4/SbN259jD26U/w880-h495-no/python_1_inputoutput.jpg)

![input_output_number2](https://lh4.googleusercontent.com/-QBUr62iuAKg/UkoPrA4s1oI/AAAAAAAAAKA/S33WNPWI_4k/w880-h495-no/python_input_output_2.jpg)


-Ashley
Loading

0 comments on commit 1b12427

Please sign in to comment.