Skip to content

Commit fe426fd

Browse files
committed
2 parents 4c6d5b7 + 2ba0e1a commit fe426fd

File tree

7 files changed

+64
-143
lines changed

7 files changed

+64
-143
lines changed

1_beginner/chapter3/practice/challenge.py renamed to 1_beginner/chapter3/practice/change.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,23 @@
55
66
For example, if someone has $4.62, the program would print the following:
77
8-
4 dollars 2 quarters 1 dime 0 nickels 2 cents
8+
4 dollars
9+
2 quarters
10+
1 dime
11+
0 nickels
12+
2 cents
913
1014
The starting code is given.
1115
1216
Note: This is a challenge problem! Do not feel bad or disheartned if you can't
1317
solve it. We will go over it next class.
1418
'''
1519

16-
num_cents = int(float(input("How many dollars do you have: ")) * 100)
20+
CENTS_PER_DOLLAR = 100
1721

18-
# What do you do next. Write code here
22+
num_cents = int(
23+
float(input("How many dollars do you have: $"))
24+
* CENTS_PER_DOLLAR
25+
)
26+
27+
# What do you do next? Write code here

1_beginner/chapter3/solutions/challenge.py

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
'''
2+
Write code that takes, as input, the number of dollars a person has
3+
(a floating number), and outputs how much they have
4+
in dollars, quarters, dimes, nickels and pennies.
5+
6+
For example, if someone has $4.62, the program would print the following:
7+
8+
4 dollars
9+
2 quarters
10+
1 dime
11+
0 nickels
12+
2 cents
13+
14+
The starting code is given.
15+
16+
Note: This is a challenge problem! Do not feel bad or disheartned if you can't
17+
solve it. We will go over it next class.
18+
'''
19+
20+
CENTS_PER_DOLLAR = 100
21+
CENTS_PER_QUARTER = 25
22+
CENTS_PER_DIME = 10
23+
CENTS_PER_NICKEL = 5
24+
25+
# prompt user for dollars and convert it to cents
26+
num_cents = int(
27+
float(input("How many dollars do you have: $"))
28+
* CENTS_PER_DOLLAR
29+
)
30+
31+
# calculate change and display it
32+
dollars = num_cents // CENTS_PER_DOLLAR
33+
remaining = num_cents % CENTS_PER_DOLLAR
34+
print(dollars, " dollars")
35+
36+
quarters = remaining // CENTS_PER_QUARTER
37+
remiaining = remaining % CENTS_PER_QUARTER
38+
print(quarters, " quarters")
39+
40+
dimes = remaining // CENTS_PER_DIME
41+
remiaining = remaining % CENTS_PER_DIME
42+
print(dimes, " dimes")
43+
44+
nickels = remaining // CENTS_PER_NICKEL
45+
remiaining = remaining % CENTS_PER_NICKEL
46+
print(nickels, " nickels")
47+
48+
cents = remaining
49+
print(cents, " cents")

1_beginner/chapter3/solutions/cylinder_volume.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
PI = 3.14
77
height = float(input('Height of cylinder: '))
88
radius = float(input('Radius of cylinder: '))
9-
volume = 3.14 * radius ** 2 * height
9+
volume = PI * radius ** 2 * height
1010
print("The volume of the cylinder is", volume)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DELETE THIS FILE!!!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DELET THIS FILE!!!

README.md

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -42,100 +42,3 @@ Under each chapter, source code is further divided by category:
4242
3. `solutions` - solutions to practice exercises
4343

4444
The practice template file has the same name as the corresponding solution file.
45-
46-
# Practice Problem Guidelines
47-
Please follow the following guidelines when creating or finding practice problems. We expect all problems submitted by teachers to maintain the highest quality! (You can also read these guidelines on every repository’s README.md.)
48-
49-
If you have questions, send a message to #questions on the teachers Discord.
50-
51-
## Follow good programming style.
52-
### Install Linters
53-
This will save you time because when you submit a pull request (PR) on GitHub, we check for good programming style. Your PR will not be approved unless it passes those style checks. Also, linters basically enforce all of the style rules that we discuss below, so you basically can just skip to the next section (Follow the C4T practice and solution problem format).
54-
55-
* Java: Install checkstyle (SonarLint recommended as well)
56-
* Python: Install flake8 (pylint recommended as well)
57-
* HTML/CSS: Install SonarLint (recommended)
58-
59-
This should go without saying, but actually use the linters! If you see errors/problems/warnings, address them, don’t ignore them and keep going!
60-
61-
**Note:** We highly recommend that you use [Visual Studio Code](https://code.visualstudio.com/download), because it has a lot of useful extensions you can install with a few clicks (including the linters mentioned above). It also has great Version Control System (VCS) integration and extensions.
62-
63-
### Whitespace
64-
* Indent properly.
65-
* Make sure there are spaces between binary operators, parentheses, curly braces, etc. when applicable. (For method/function calls, there should not be a space between the method/function name and the parentheses.)
66-
* For HTML, attributes should not have spaces between the attribute name, equal sign, and attribute value
67-
* Leave empty lines where appropriate to increase readability
68-
69-
### Naming
70-
* Name files so that they are representative of what the program is about. File names are also the name of the practice problem.
71-
* Avoid naming files after concepts, like “Arrays.java”
72-
* Java: Use class naming conventions to name files. For example, HelloWorld.java rather than helloWorld.java or hello_world.java or something else
73-
* Python: Use snake case to name files. For example, hello_world.py rather than HelloWorld.py or helloWorld.py or something else
74-
* Name variables/methods/functions descriptively, and follow your language’s conventions.
75-
* Java: camelCase for regular variables, snake case (and uppercase) for constants
76-
* Python: Snake case for regular variables, snake case (and uppercase) for constants
77-
78-
### Reduce complexity
79-
* If a line of code is very long, separate it into 2+ lines (e.g. for long lists/arrays, long print statements, etc.)
80-
* Add comments to explain parts of your code
81-
* Break up the program into methods/functions if applicable and if the students have learned about methods/functions at that point in time.
82-
83-
## Follow the C4T practice and solution problem format.
84-
* Make sure you put the file(s) in the right directories.
85-
* All code filed under “practice” should be templates.
86-
* Templates may include things like an empty class and main method.
87-
* They must include a multi-line comment with the title of the practice problem AND the full instructions for the problem.
88-
* All code filed under “solutions” should be solutions.
89-
* Solutions should include the practice problem title AND full instructions at the top of the file (exact same comment as in the practice template file) and then a (possible) solution to the problem.
90-
* The practice template and solution should have the same file name.
91-
* Java: Make sure that you have the correct package statement as the first line of your code.
92-
93-
## Testing
94-
* Thoroughly test your solution. Make sure it works as intended.
95-
* Try to break your program! Don’t just give input you know will work.
96-
* Hundreds of students and ~50 teachers could potentially see and use your work. Please make sure that it works!
97-
98-
## Check the content.
99-
* Make sure that the problem is doable for the skill level of your students.
100-
* Check Thinkific to see if the concepts that you need to solve the problem have been covered already.
101-
* Be aware of how long your own class takes on other practice problems.
102-
* Practice problems shouldn’t take several hours/days.
103-
104-
## Cite your sources.
105-
* If you are using data or practice problems from somewhere other than yourself, you MUST cite your sources.
106-
* Providing a link to the original is usually sufficient if you found the problem online.
107-
* If you found it in a book, cite the full title and author.
108-
109-
## Submit practice problem(s).
110-
111-
### Option 1: Use GitHub
112-
***Note 1:** If you choose option 1, we assume you know basic Git, e.g. committing, pushing, pulling, branching, merging, etc. If you want to learn the basic Git you need to contribute, we recommend watching [this entire playlist.](https://www.youtube.com/watch?v=3RjQznt-8kE&list=PL4cUxeGkcC9goXbgTDQ0n_4TBzOO0ocPR&index=1)*
113-
114-
***Note 2:** If you want an overview of the Pull Request (PR) workflow we are using, read these articles.*
115-
116-
1. Send your GitHub username to a Curriculum Development member and ask them to add you as an outside collaborator on the repository or repositories that you want to contribute to.
117-
2. Clone or fork the official C4T repository.
118-
* All repositories can be found here: https://github.com/code-for-tomorrow
119-
* [How to Clone](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository)
120-
* [How to Fork](https://help.github.com/en/github/getting-started-with-github/fork-a-repo)
121-
3. Work on the practice problems locally.
122-
* If you cloned the repo, make sure you create and checkout a new branch. **DO NOT MAKE EDITS ON THE MASTER BRANCH.**
123-
* If you forked the repo, you’re free to work on the master branch or make your own branches (though that is kinda unnecessary).
124-
* [Git Branches Tutorial](https://www.atlassian.com/git/tutorials/using-branches)
125-
4. Push your local branch to remote.
126-
* [How to Push](https://help.github.com/en/github/using-git/pushing-commits-to-a-remote-repository)
127-
5. Make a pull request to merge your branch with the master branch of the official C4T repo.
128-
* Make sure that the title of your pull request is descriptive but concise.
129-
* In the description part of your pull request, you should specify the following:
130-
* Your full name (if it’s not clear from your GitHub profile)
131-
* Chapter # and section name that this problem should go under (for example, Ch. 1 Intro to Python, Section: Comments)
132-
* [How to Create a Pull Request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request)
133-
6. Mention @Curriculum Development on the Teachers Discord that you’ve submitted a PR.
134-
7. Monitor the status of your Pull Request on GitHub.
135-
* It’s possible that the Curriculum Development team will Request Changes, in which case you will need to commit those changes before your PR will be approved and merged into the official master branch.
136-
137-
### Option 2: Use the Google Form
138-
Submit a problem [here](https://forms.gle/hDWrPRG3HuAgUdCJ9) if you don’t have a GitHub account.
139-
140-
141-
**Thank you teachers for following these guidelines and helping us build a problem base!**

0 commit comments

Comments
 (0)