Add latest project and new docs.

This commit is contained in:
Josh Mudge 2018-12-20 17:31:30 -07:00
parent 23329f8275
commit 4aaf387c89
2 changed files with 68 additions and 0 deletions

View File

@ -211,6 +211,34 @@ is the passed argument and thus what is used for a result:
Creating a spreadsheet called Applications with 10 rows.
```
## Returning Stuff
You can return stuff like this to store for later:
```
def addfour(number, cow):
addedfour = number + 4
cat = number - 4
return addedfour, cat # All returned arguments must be on the same return call.
```
I'll make it add four to 456
```
yo, cow = addfour(456)
print ("456 + 4 equals " + str(yo) )
```
```
460
```
You can also do this with multiple arguments:
```
x_squared, y_squared = square_point(1, 3)
```
# Fun Projects
Design a shop using Ex7 and Ex9 as a frame:

View File

@ -0,0 +1,40 @@
train_mass = 22680
train_acceleration = 10
train_distance = 100
bomb_mass = 1
def f_to_c(f_temp):
c_temp = (f_temp - 32) * 5/9
return c_temp
f100_in_celsius = f_to_c(100)
#print(f100_in_celsius)
def c_to_f(c_temp):
f_temp = (c_temp * (9/5) + 32)
return f_temp
c0_in_fahrenheit = c_to_f(0)
#print(c0_in_fahrenheit)
def get_force(mass, acceleration):
return mass * acceleration
train_force = get_force(train_mass, train_acceleration)
#print(train_force)
print("The GE train supplies " + str(train_force) + " Newtons of force.")
def get_energy(mass, c = 3*10**8):
return mass * c*c
bomb_energy = get_energy(bomb_mass)
print("A 1kg bomb supplies " + str(bomb_energy) + " Joules")
def get_work(mass, acceleration, distance):
return get_force(mass, acceleration) * distance
train_work = get_work(train_mass, train_acceleration, train_distance)
print("The GE train does " + str(train_work) + " Joules of work over " + str(train_distance) + " meters.")