загружаю доработанное дз по джейсону без инам
This commit is contained in:
parent
bca8f3814e
commit
fe6cb7b8c1
|
@ -0,0 +1 @@
|
||||||
|
main.py
|
|
@ -4,7 +4,7 @@
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Python 3.11 (13082023 ДЗ по фигурам JSON)" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="Python 3.12 (13082023 ДЗ по фигурам JSON)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (13082023 ДЗ по фигурам JSON)" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (13082023 ДЗ по фигурам JSON)" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
|
@ -31,19 +31,24 @@ def create_shape(json):
|
||||||
|
|
||||||
|
|
||||||
def generate_shape():
|
def generate_shape():
|
||||||
|
max_length = 100
|
||||||
types = ['square', 'circle', 'rectangle']
|
types = ['square', 'circle', 'rectangle']
|
||||||
rnd = random.randint(0, len(types) - 1)
|
colors = ['red', 'green', 'blue', 'yellow', 'black', 'white']
|
||||||
shape_type = types[rnd]
|
|
||||||
|
type_index = random.randint(0, len(types) - 1)
|
||||||
|
shape_type = types[type_index]
|
||||||
|
|
||||||
if shape_type == 'circle':
|
if shape_type == 'circle':
|
||||||
obj = Circle(rnd)
|
obj = Circle(random.randint(1, max_length))
|
||||||
elif shape_type == 'square':
|
elif shape_type == 'square':
|
||||||
obj = Square(rnd)
|
obj = Square(random.randint(1, max_length))
|
||||||
elif shape_type == 'rectangle':
|
elif shape_type == 'rectangle':
|
||||||
obj = Rectangle(rnd, rnd)
|
obj = Rectangle(random.randint(1, 100), random.randint(1, max_length))
|
||||||
else:
|
else:
|
||||||
raise TypeError(f'Происходит что-то непонятное')
|
raise TypeError(f'Происходит что-то непонятное')
|
||||||
obj.color = 'unknown'
|
|
||||||
return obj
|
color_index = random.randint(0, len(colors) - 1)
|
||||||
|
obj.color = colors[color_index]
|
||||||
|
|
||||||
|
|
||||||
def json_to_python(filename):
|
def json_to_python(filename):
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue