Python 1 - #1
Conversation
brianilles
left a comment
There was a problem hiding this comment.
Excellent job completing the two day project on day 1. I'll leave this PR open if you'd like to continue working on stretch.
| @@ -1 +1,2 @@ | |||
| # Print "Hello, world!" to your terminal No newline at end of file | |||
| # Print "Hello, world!" to your terminal | |||
| print("Hello, world!") No newline at end of file | |||
There was a problem hiding this comment.
It all starts with a hello world :)
|
|
||
| # YOUR CODE HERE No newline at end of file | ||
| # YOUR CODE HERE | ||
| print(2 ** 65536) |
There was a problem hiding this comment.
What happens in the JS console?
| # Finally, print the same thing using an f-string No newline at end of file | ||
| print("x is {}, y is {:.2f}, z is {}".format(x,y,z)) | ||
| # Finally, print the same thing using an f-string | ||
| print(f"x is {x}, y is {y:.2f}, z is {z}") No newline at end of file |
There was a problem hiding this comment.
Excellent use of all three print implementations. Which is your fav?
| def print_tuple(t) : | ||
| print(t) | ||
| t = (1, 2, 5, 7, 99) | ||
| print_tuple(t) # Prints 1 2 5 7 99, one per line |
There was a problem hiding this comment.
We'd like to print each value in the tuple on a separate line. How can we change this to accomplish that?
|
|
||
| for j in range(10): | ||
| y.append(j**3) | ||
| print(y) |
There was a problem hiding this comment.
Excellent work. How can we refactor this to be a List Comprehension?
|
|
||
| # YOUR CODE HERE | ||
|
|
||
| def f2(*args) : |
There was a problem hiding this comment.
Excellent! What operator in JS is *args like?
|
|
||
| # YOUR CODE HERE | ||
|
|
||
| with open('foo.txt') as f: |
There was a problem hiding this comment.
Great use of with open(). I pretty much use this exclusively for file IO as the file doesn't need to be explicitly closed.
| for a in a: | ||
| y.append(a.upper()) | ||
| y = [q.upper() for q in a] | ||
|
|
No description provided.