Skip to content

Commit 1040614

Browse files
committed
Add python, add docs on commiting to python
1 parent 65e5e20 commit 1040614

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

CodeHS/3/5/9/recipe.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
This program made by Joe S
3+
"""
4+
5+
servings = -1
6+
shopping_list = ["mixed greens", "blueberries", "walnuts"]
7+
8+
object_list = []
9+
10+
class ingredient():
11+
def __init__(self, name, qty):
12+
self.name = name
13+
self.qty = qty
14+
def list_total(self):
15+
print("Total ounces of " + self.name + ": " + str(float(self.qty) * servings))
16+
17+
for listitem in shopping_list:
18+
print("Enter ingredient 1: " + str(listitem))
19+
object_list.append(ingredient(listitem, input("Ounces of " + str(listitem) + ": ")))
20+
21+
servings = float(input("Enter total number of servings: "))
22+
print("")
23+
for item in object_list:
24+
item.list_total()

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
A repo for adding in your example python code to assist or impress others! :3
33

44
Rules for adding:
5-
Please first create your own branch, then create a pull request from your branch, into the master branch, you can request reviews from certain people, but this is not necessary, people will review your pull request ASAP.
5+
Please first create your own branch, then create a pull request from your branch, into the master branch, you can request reviews from certain people, but this is not necessary, people will review your pull request ASAP.
6+
7+
File Structure:
8+
Please arrange your CodeHS examples nested in folders based off unit, so for example, lesson number `3.4.5` would be `/CodeHS/3/4/5/my_python_program.py`

0 commit comments

Comments
 (0)