Skip to content

Commit 2a728c9

Browse files
committed
Update tests/results/15 (python/:learn)
1 parent b45e955 commit 2a728c9

File tree

1 file changed

+11
-12
lines changed
  • tests/results

1 file changed

+11
-12
lines changed

tests/results/15

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,19 @@
2828
10.0 / 3 # => 3.3333333333333335
2929

3030
# Modulo operation
31-
7 % 3 # => 1
31+
7 % 3 # => 1
32+
# i % j have the same sign as j, unlike C
33+
-7 % 3 # => 2
3234

3335
# Exponentiation (x**y, x to the yth power)
3436
2**3 # => 8
3537

3638
# Enforce precedence with parentheses
37-
1 + 3 * 2 # => 7
39+
1 + 3 * 2 # => 7
3840
(1 + 3) * 2 # => 8
3941

4042
# Boolean values are primitives (Note: the capitalization)
41-
True # => True
43+
True # => True
4244
False # => False
4345

4446
# negate with not
@@ -104,7 +106,7 @@
104106
"This is a string."
105107
'This is also a string.'
106108

107-
# Strings can be added too! But try not to do this.
109+
# Strings can be added too
108110
"Hello " + "world!" # => "Hello world!"
109111
# String literals (but not variables) can be concatenated without using '+'
110112
"Hello " "world!" # => "Hello world!"
@@ -118,10 +120,9 @@
118120
# You can also format using f-strings or formatted string literals (in Python 3.6+)
119121
name = "Reiko"
120122
f"She said her name is {name}." # => "She said her name is Reiko"
121-
# You can basically put any Python statement inside the braces and it will be output in the string.
123+
# You can basically put any Python expression inside the braces and it will be output in the string.
122124
f"{name} is {len(name)} characters long." # => "Reiko is 5 characters long."
123125

124-
125126
# None is an object
126127
None # => None
127128

@@ -151,7 +152,6 @@
151152

152153
# Simple way to get input data from console
153154
input_string_var = input("Enter some data: ") # Returns the data as a string
154-
# Note: In earlier versions of Python, input() method was named as raw_input()
155155

156156
# There are no declarations, only assignments.
157157
# Convention is to use lower_case_with_underscores
@@ -484,7 +484,7 @@
484484

485485
with open('myfile2.txt', "r+") as file:
486486
 contents = json.load(file) # reads a json object from a file
487-
print(contents) 
487+
print(contents)
488488
# print: {"aa": 12, "bb": 21}
489489

490490

@@ -751,9 +751,8 @@
751751
 # Call the static method
752752
 print(Human.grunt()) # => "*grunt*"
753753

754-
 # Cannot call static method with instance of object
755-
 # because i.grunt() will automatically put "self" (the object i) as an argument
756-
 print(i.grunt()) # => TypeError: grunt() takes 0 positional arguments but 1 was given
754+
 # Static methods can be called by instances too
755+
 print(i.grunt()) # => "*grunt*"
757756

758757
 # Update the property for this instance
759758
 i.age = 42
@@ -898,7 +897,7 @@
898897

899898
 def __init__(self, *args, **kwargs):
900899
 # Typically to inherit attributes you have to call super:
901-
 # super(Batman, self).__init__(*args, **kwargs) 
900+
 # super(Batman, self).__init__(*args, **kwargs)
902901
 # However we are dealing with multiple inheritance here, and super()
903902
 # only works with the next base class in the MRO list.
904903
 # So instead we explicitly call __init__ for all ancestors.

0 commit comments

Comments
 (0)