diff options
author | Divay Prakash <divayprakash@users.noreply.github.com> | 2020-02-02 15:13:28 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-02 15:13:28 +0530 |
commit | 8eb11a89a7fc84dde15544c6f7ec99a8f44b0c9f (patch) | |
tree | 7605022884b652f7acf879328887a9d191d3ef58 /python3.html.markdown | |
parent | ab5a1953e77288ca27bd7b4c931d8bb2e79a9966 (diff) | |
parent | f80889ed47ae42ca4ea2b8118e2b3c48c37eeb9c (diff) |
Merge branch 'master' into master
Diffstat (limited to 'python3.html.markdown')
-rw-r--r-- | python3.html.markdown | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/python3.html.markdown b/python3.html.markdown index 6e8d2460..f69ffb14 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -16,8 +16,6 @@ Python was created by Guido van Rossum in the early 90s. It is now one of the mo languages in existence. I fell in love with Python for its syntactic clarity. It's basically executable pseudocode. -Feedback would be highly appreciated! You can reach me at [@louiedinh](http://twitter.com/louiedinh) or louiedinh [at] [google's email service] - Note: This article applies to Python 3 specifically. Check out [here](http://learnxinyminutes.com/docs/python/) if you want to learn the old Python 2.7 ```python @@ -58,11 +56,12 @@ Note: This article applies to Python 3 specifically. Check out [here](http://lea 2**3 # => 8 # Enforce precedence with parentheses +1 + 3 * 2 # => 7 (1 + 3) * 2 # => 8 # Boolean values are primitives (Note: the capitalization) -True -False +True # => True +False # => False # negate with not not True # => False @@ -138,20 +137,6 @@ b == a # => True, a's and b's objects are equal # You can find the length of a string len("This is a string") # => 16 -# .format can be used to format strings, like this: -"{} can be {}".format("Strings", "interpolated") # => "Strings can be interpolated" - -# You can repeat the formatting arguments to save some typing. -"{0} be nimble, {0} be quick, {0} jump over the {1}".format("Jack", "candle stick") -# => "Jack be nimble, Jack be quick, Jack jump over the candle stick" - -# You can use keywords if you don't want to count. -"{name} wants to eat {food}".format(name="Bob", food="lasagna") # => "Bob wants to eat lasagna" - -# If your Python 3 code also needs to run on Python 2.5 and below, you can also -# still use the old style of formatting: -"%s can be %s the %s way" % ("Strings", "interpolated", "old") # => "Strings can be interpolated the old way" - # You can also format using f-strings or formatted string literals (in Python 3.6+) name = "Reiko" f"She said her name is {name}." # => "She said her name is Reiko" @@ -394,6 +379,9 @@ filled_set | other_set # => {1, 2, 3, 4, 5, 6} 2 in filled_set # => True 10 in filled_set # => False +# Make a one layer deep copy +filled_set = some_set.copy() # filled_set is {1, 2, 3, 4, 5} +filled_set is some_set # => False #################################################### |