Skip to content

Commit

Permalink
Correct format according to flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
Ignacio Avas committed May 4, 2017
1 parent 9259c42 commit 2bf9b40
Show file tree
Hide file tree
Showing 22 changed files with 34 additions and 29 deletions.
4 changes: 2 additions & 2 deletions py101/classes/README.es.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Una clase básica se ve como sigue:
self.name = name

def print_name(self):
print("Hola {{}}".format(self.name))
print("Hola {}".format(self.name))

La función especial "__init__" se llama cuando se crea un objeto Persona.
Pueded definir y asignar variables que se usan dentro del objeto Persona
Expand Down Expand Up @@ -75,7 +75,7 @@ un programa que imprima las líneas "Vehicle cost is 12000" y "Vechicle cost is
self.cost = cost

def description(self):
return "Vehicle cost is {{}}".format(self.cost)
return "Vehicle cost is {}".format(self.cost)

# Tu código va aquí

4 changes: 2 additions & 2 deletions py101/classes/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ A basic class would look something like this:
self.name = name

def print_name(self):
print("Hello {{}}".format(self.name))
print("Hello {}".format(self.name))

The special "__init__" function is called when a Person object is created.
It can define and assigne variables inside a created Person object. For
Expand Down Expand Up @@ -73,7 +73,7 @@ program that prints the lines "Vechicle cost is 12000" and "Vechicle cost is
self.cost = cost

def description(self):
return "Vehicle cost is {{}}".format(self.cost)
return "Vehicle cost is {}".format(self.cost)

# your code goes here

2 changes: 1 addition & 1 deletion py101/classes/SOLUTION.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
self.cost = cost

def description(self):
return "Vehicle cost is {{}}".format(self.cost)
return "Vehicle cost is {}".format(self.cost)

car1 = Vehicle(12000)
car2 = Vehicle(5999.99)
Expand Down
2 changes: 1 addition & 1 deletion py101/conditions/README.es.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Python provee las sentencias "if", que consisten de una expressión booleana (Tr
if y == 0:
print('El divisor no debe ser 0')
else:
print('El resultado es {{}}'.format(x/y))
print('El resultado es {}'.format(x/y))

Las sentencias if pueden ser anidadas, permitiendo ejecutar código más complejo.

Expand Down
2 changes: 1 addition & 1 deletion py101/conditions/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Python provides the "if" statements, consisting of a boolean expression followed
if y == 0:
print('divisor y should not be zero')
else:
print('Result is {{}}'.format(x/y))
print('Result is {}'.format(x/y))

If statements can be nested allowing more complex logic to be executed:

Expand Down
2 changes: 1 addition & 1 deletion py101/dictionaries/README.es.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ diccionario se usa la siguiente sintaxis.
.. sourcecode:: python

for name in ages:
print("Edad de {{}} es {{}}".format(name, ages[name]))
print("Edad de {} es {}".format(name, ages[name]))

El ejemplo va a imprimir algo similar a:

Expand Down
4 changes: 2 additions & 2 deletions py101/dictionaries/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using a key, which is any type of object, for example strings
instead of using its index to address it.

For example, a database of phone numbers could be stored using a dictionary
like this:
like this: {}

.. sourcecode:: python

Expand Down Expand Up @@ -35,7 +35,7 @@ Dictionaries can be iterated over. To iterate over the dictionary keys, use
.. sourcecode:: python

for name in ages:
print("Age of {{}} is {{}}".format(name, ages[name]))
print("Age of {} is {}".format(name, ages[name]))

The previous example will print something similar to

Expand Down
1 change: 0 additions & 1 deletion py101/dictionaries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def tearDown(self):
def runTest(self):
"""Makes a simple test of the output"""


code = compile(self.candidate_code, self.file_name, 'exec', optimize=0)

self.assertIn('print_only_even_keys',
Expand Down
6 changes: 3 additions & 3 deletions py101/formatting/README.es.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Formateo de Strings
-------------------

El método str.format() de la clase string puede ser utilizado para hacer substitución de variables y formateo de valores. Esto permite concatenar elementos juntos dentro de una cadena usando formateo posicional. Funciona introduciendo uno o más campos de reemplazo, definidos como pares de corchetes ({{}}) en uan cadena y llamando a la operación format:
El método str.format() de la clase string puede ser utilizado para hacer substitución de variables y formateo de valores. Esto permite concatenar elementos juntos dentro de una cadena usando formateo posicional. Funciona introduciendo uno o más campos de reemplazo, definidos como pares de corchetes ({}) en uan cadena y llamando a la operación format:

.. sourcecode:: python

print('Hello {{}}. How are you?'.format('Josh'))
print('Hello {}. How are you?'.format('Josh'))
# prints out 'Hello Josh. How are you?

En el ejemplo anterior el valor de 'Josh' se reemplaza donde estaba el par de corchetes.
Expand All @@ -14,7 +14,7 @@ Se pueden usar múltiples pares de corchetes si se desea hacer más de un reempl

.. sourcecode:: python

print('Hello {{}}. Do you like {{}}?'.format('Anne', 'Pizza'))
print('Hello {}. Do you like {}?'.format('Anne', 'Pizza'))
# prints 'Hello Anne. Do you like Pizza?'

Challenge
Expand Down
6 changes: 3 additions & 3 deletions py101/formatting/README.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
String Formatting
-----------------

Python's format() operation of the string class allows to do variable substitutions and value formatting. This allows to concatenate elements together within a string through positional formatting. It work by putting in one or more replacement fields or placeholders, defined by a pair of curly braces ({{}}), into a string and calling the format() operation:
Python's format() operation of the string class allows to do variable substitutions and value formatting. This allows to concatenate elements together within a string through positional formatting. It work by putting in one or more replacement fields or placeholders, defined by a pair of curly braces ({}), into a string and calling the format() operation:

.. sourcecode:: python

print('Hello {{}}. How are you?'.format('Josh'))
print('Hello {}. How are you?'.format('Josh'))
# prints out 'Hello Josh. How are you?

In the previous example places the value of Josh into the string where the curly braces were.

Multiple pairs of curly braces can be used to do multiple substitutions.

.. sourcecode:: python
print('Hello {{}}. Do you like {{}}?'.format('Anne', 'Pizza'))
print('Hello {}. Do you like {}?'.format('Anne', 'Pizza'))
# prints 'Hello Anne. Do you like Pizza?'

Challenge
Expand Down
2 changes: 1 addition & 1 deletion py101/formatting/SOLUTION.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.. sourcecode:: python

print('Talk is {{}}. Show me the {{}}.'.format('cheap', 'code'))
print('Talk is {}. Show me the {}.'.format('cheap', 'code'))
4 changes: 2 additions & 2 deletions py101/functions/README.es.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Las funciones también pueden recibir argumentos: variables que se pasan desde e
.. sourcecode:: python

def decir_hola_con_nombre(name):
print("Hola {{}}".format(name))
print("Hola {}".format(name))
print("¿Cómo estás?")

Las funciones también pueden retornar un valor al invocador, usando la palabra clave "return", por ejemplo:
Expand Down Expand Up @@ -44,7 +44,7 @@ Definir una función solo le da un nombre, especifica los parámetros que se van

result = hacer_division(2343, 22)
decir_hola_con_nombre("Alex")
print("Resultado es {{}}".format(result))
print("Resultado es {}".format(result))

Desafío
---------
Expand Down
4 changes: 2 additions & 2 deletions py101/functions/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Functions may also receive arguments (variables passed from the caller to the fu
.. sourcecode:: python

def say_hello_with_name(name):
print("Hello {{}}".format(name))
print("Hello {}".format(name))
print("How are you?")

Also they may return a value to the caller, using "return" keyword. For example:
Expand Down Expand Up @@ -45,7 +45,7 @@ Defining a function only gives it a name, specifies the parameters that are to b

result = make_division(2343, 22)
say_hello_with_name("Alex")
print("Result is {{}}".format(result))
print("Result is {}".format(result))

Challenge
---------
Expand Down
2 changes: 1 addition & 1 deletion py101/loops/README.es.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Los bucles for tienen la habilidad de iterar sobre los items de cualquier secuen
.. sourcecode:: python
ingredients = ['banana', 'manzana', 'mango']
for ingredient in ingredients:
print('Ingrediente actual: {{}}'.format(ingredient))
print('Ingrediente actual: {}'.format(ingredient))

for some_char in 'Python':
print(some_char)
Expand Down
2 changes: 1 addition & 1 deletion py101/loops/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The for loops have the ability to iterate over the items of any sequence, such a
.. sourcecode:: python
ingredients = ['banana', 'apple', 'mango']
for ingredient in ingredients:
print('Current ingredient: {{}}'.format(ingredient))
print('Current ingredient: {}'.format(ingredient))

for some_char in 'Python':
print(some_char)
Expand Down
1 change: 1 addition & 0 deletions tests/solutions/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def __init__(self, cost):
def description(self):
return "Vehicle cost is {}".format(self.cost)


car1 = Vehicle(12000)
car2 = Vehicle(5999.99)

Expand Down
5 changes: 3 additions & 2 deletions tests/solutions/dictionaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ def print_only_even_keys(some_dict):
if some_dict[key] % 2 == 0:
print(key)

print_only_even_keys({ 'Alfred': 28, 'Mary': 29 })
print_only_even_keys({ 'Alfred': 31, 'Mary': 29 })

print_only_even_keys({'Alfred': 28, 'Mary': 29})
print_only_even_keys({'Alfred': 31, 'Mary': 29})
2 changes: 1 addition & 1 deletion tests/solutions/formatting.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
s = 'Talk is {}. Show me the {}.'.format('cheap', 'code');
s = 'Talk is {}. Show me the {}.'.format('cheap', 'code')
print(s)
2 changes: 2 additions & 0 deletions tests/solutions/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ def print_even(upper_bound):
for number in range(upper_bound+1):
if number % 2 == 0 and number > 1:
print(number)


print_even(100)
2 changes: 1 addition & 1 deletion tests/solutions/lists.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
languages = ["ADA", "Pascal", "Fortran", "Smalltalk"];
languages = ["ADA", "Pascal", "Fortran", "Smalltalk"]
print(languages)
3 changes: 2 additions & 1 deletion tests/solutions/loops.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
for number in range(100):
if number % 2 == 1: print(number)
if number % 2 == 1:
print(number)
1 change: 1 addition & 0 deletions tests/test_story.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
def get_solution_path(solution_name):
return path.join(path.dirname(__file__), 'solutions', solution_name)


adventures = [
AdventureData(
py101.introduction,
Expand Down

0 comments on commit 2bf9b40

Please sign in to comment.