weather-app-shecodes's Introduction
weather-app-shecodes's People
weather-app-shecodes's Issues
Project Feedback
Generic Intro:
Hi there! I heard that you hadn't received feedback for the Python project, so I'm working my way through each repo and adding some quick feedback. I'm aware that you've continued learning and growing your Python skills, so please feel free to ignore advice that I give that is old news to you!
That repo uses only syntax that we demonstrated in class (although some of the patterns I've used might be new). I've also added a branch that uses a piece of more advanced syntax called "list comprehensions" here, in case you'd like to see some new syntax.
Customised Feedback
Hi Rachel! This looks really good! I love your use of list comprehensions, and your logic is very clean and clear.
Built-in Functions
Your calculate_mean
function is good - you could have also used the sum()
and len()
functions here to simplify the code a little, but your solution works just fine.
"Implicit Else"
I see that you're using a guard clause in the loop for your load_data_from_csv
function, to skip empty lines in the csv. In general, guard clauses are a great idea, and your logic here is once again completely correct. In this case, you could slightly simplify your code by using the if
statement to check the opposite condition, and not specifying any behaviour where there is no data, like so:
def load_data_from_csv(csv_file):
data = []
with open(csv_file, 'r', newline='') as csv_file:
reader = csv.reader(csv_file)
next(reader)
for item in reader:
# we check to see if there IS data
# instead of checking if there is NOT
if item:
row_list = [item[0], int(item[1]), int(item[2])]
data.append(row_list)
return data
This pattern is called "implicit else", because by not including an else
block, we implicitly tell the interpreter to do nothing in that case.
This is mostly a stylistic choice, though. Your use of continue
is still a great solution. :)
Redundant pass
Statements
It's a good idea to remove the pass
statements from functions once you've defined their behaviour. pass
is just a "placeholder" that allows us to write functions that don't do anything, without causing a syntax error. It's not causing any problems in your code, because the return
statement automatically ends a function's execution, but taking those pass
statements out makes the code easier to read.
The enumerate
Function
Your use of range
is a good solution for find_min/max
. Just to offer you a different option that you might find useful, check out enumerate
.
Normally when we use a for
loop on an iterable object like a list, we just get access to each value in the list in turn. That's great, but sometimes we want to know both what the value is, AND it's position in the list. enumerate
gives us that information. Here's how it works:
# WITHOUT enumerate
for element in ['a', 'b', 'c']:
print(f"Element = {element}")
# output:
# "Element = a"
# "Element = b"
# "Element = b"
# WITH enumerate
for index, element in enumerate(['a', 'b', 'c']):
print(f"Element {index} = {element}")
# output:
# "Element 0 = a"
# "Element 1 = b"
# "Element 2 = c"
This is a super handy one for the find_min
and find_max
functions!
Otherwise, no notes. This is a great response to the project!!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.