kristofer / TastyHint2.md
0 喜欢
0 派生
1 文件
最后活跃于
If we have thought about this:
tasks = {} # creates an empty dictionary
tasks['Buy Milk'] = 'not yet'
tasks['Start Lab'] = 'completed'
kristofer / TastyHint1.md
0 喜欢
0 派生
1 文件
最后活跃于
Remember start very small and build outward.
Hint 1
If you haven't already decided how to start...
This is the tasks
variable.
Tasty class.
kristofer / Some Bad Habits in Python
0 喜欢
0 派生
1 文件
最后活跃于
One More List of Bad Habits
Also, be aware that some of these things are not actually related to Python but are considered to be bad practices in most of the languages (like Java).
- No comments is bad — people forget and you should comment your code. Describe why not how. Explain the intent behind the code.
- Too many comments is also bad — you should feel the border line at column 80.
- No abstractions is bad — they didn’t develop Python for you to write Assembly-style wall of code with no functions and/or classes. Copy-pasting your code is bad — use functions when you
kristofer / dict-count.py
0 喜欢
0 派生
1 文件
最后活跃于
a sample of frequency counting words from a list, in good and bad styles
1 | # You need to write a loop that counts the occurrences of each word in a list. |
2 | # |
3 | # Consider, if you had a big str that was a text, like say: https://zcw.guru/kristofer/hamlet |
4 | # |
5 | # strive to be "pythonic" in your code expressions, okay? |
6 | |
7 | colors = ["red", "green", "blue", "green", "red", "green"] |
8 | |
9 | # Not Pythonic Code |
10 | d = {} |
kristofer / Hamlet by Shake-speare
0 喜欢
0 派生
1 文件
最后活跃于
1 | THE TRAGEDY OF HAMLET, PRINCE OF DENMARK |
2 | |
3 | |
4 | by William Shakespeare |
5 | |
6 | |
7 | |
8 | Dramatis Personae |
9 | |
10 | Claudius, King of Denmark. |
kristofer / BugReporter (java)
0 喜欢
0 派生
1 文件
最后活跃于
cool class from https://github.com/RohitAwate/Everest/blob/master/BugReporter/src/BugReporter.java
1 | /* |
2 | * Copyright 2018 Rohit Awate. |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
kristofer / Memoization: Let’s Be Efficient, Shall We?
0 喜欢
0 派生
1 文件
最后活跃于
Ever ask the same question over and over? Annoying, right? That’s what your computer thinks too.
1 | # example of memoization in python for fibonacci |
2 | |
3 | # Memoization: Let’s Be Efficient, Shall We? |
4 | # Ever worry about recursion and the stack and so on... |
5 | # Ever ask the same question over and over? |
6 | # Annoying, right? That’s what your computer thinks too. |
7 | # Memoization fixes this by storing results so you don’t have to repeat expensive calculations. |
8 | def fib(n, memo={}): |
9 | if n in memo: |
10 | return memo[n] |