Skip to content

CS_26 Introduction to Python TL-Brian Illes - #2

Open
karsevar wants to merge 8 commits into
masterfrom
mason-karsevar2
Open

karsevar wants to merge 8 commits into
masterfrom
mason-karsevar2

Conversation

@karsevar

Copy link
Copy Markdown
Owner

No description provided.

@brianilles
brianilles self-requested a review February 13, 2020 16:42

@brianilles brianilles left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on the first 2 days. Will keep this PR open in case you are considering the stretch assignment

Comment thread src/00_hello.py
@@ -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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It all starts with a hello world :)

Comment thread src/01_bignum.py

# YOUR CODE HERE No newline at end of file
# YOUR CODE HERE
print(2**65536) No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens in the JS console?

Comment thread src/02_datatypes.py

# YOUR CODE HERE No newline at end of file
# YOUR CODE HERE
print(str(x) + y) No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we do int(y) or str(x), what is this called?

Comment thread src/03_modules.py
# Print out the command line arguments in sys.argv, one per line:
# YOUR CODE HERE
for argument in sys.argv:
print(argument)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and readable!

Comment thread src/04_printing.py
print("x is {0}, y is {1:1.2f}, z is \"{2}\"".format(x, y, z))

# Finally, print the same thing using an f-string
print(f"x is {x}, y is {round(y, 2)}, z is \"{z}\"")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent use of all three print implementations. Which is your fav?

Comment thread src/08_comprehensions.py

# What do you need between the square brackets to make it work?
y = []
y = [even for even in x if int(even) % 2 == 0]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best I've seen yet! even for even really makes this readable.

Comment thread src/10_functions.py

return True

return False

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid! One thing you may see others do is return n%2 == 0 which will return a Boolean itself. Either way is valid of course.

Comment thread src/11_args.py
# sum. Google for "python arbitrary arguments" and look for "*args"

# YOUR CODE HERE
def f2(*args):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! What operator in JS is *args like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants