Rules
Rules
Wrong Х
a = 'John'
AGE = 11
DateBirth = 2010
Correct V
name = 'John'
age = 11
date_birth = 2010
Spaces should be placed before and after the following operators: =, ==, <, >, !=, <>, <=,
>=, in, not in, is, is not, and, or, not
Spaces must be placed after commas
There is no need to put spaces between equals in function arguments.
Wrong Х
def eating(fruit):
print(‘Om-Nom-nom’+fruit)
fruit='plum'
fruits=['apple','orange','banana','pineapple']
if fruitinfruits:
eating(fruit = fruit)
Correct V
def eating(fruit):
print(‘Om-Nom-nom’ + fruit)
fruit = 'plum'
if fruit in fruits:
eating(fruit=fruit)
Indent
For a command to be executed inside of for, if, def, и etc., you must add an indent,
before that command, using the Tab key:
if 5 > 3:
print(‘more’)
Wrong Х
spase
Correct V
←
Tab
Empty lines
Wrong Х
import random
class MyClass:
def __init__(self):
def say_hello(self):
def my_func():
i = random.randint(1, 100)
return i
myclass = MyClass()
Correct V
.
.
import random
class MyClass:
def __init__(self):
.
self.name = 'My name'
def say_hello(self):
.
.
return 'hello world'
def my_func():
i = random.randint(1, 100)
.
.
return i
myclass = MyClass()
+7 (958) 580-25-77