Skip to content

lesson 6#5

Open
tchka wants to merge 1 commit intolesson_5from
lesson_6
Open

lesson 6#5
tchka wants to merge 1 commit intolesson_5from
lesson_6

Conversation

@tchka
Copy link
Copy Markdown
Owner

@tchka tchka commented Jun 2, 2020

No description provided.

Copy link
Copy Markdown

@Dzhoker1 Dzhoker1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Оставил комментарии по коду

# Посчитать четные и нечетные цифры натурального числа.
import random
import sys
from _collections import deque
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_ лишнее


def func(a, odd=0, even=0, memory=0):
if a // 10 == 0:
memory += sys.getsizeof(a)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ручной сбор. Хороший вариант, но ломает основной код.

odd += 1
print(f'Во введенном числе нечетных цифр: {odd}, четных цифр: {even}')
print(
f'Var2. Allocated memory size: {sys.getsizeof(number2) + calculate_zise(number_as_list) + calculate_zise(odd) + calculate_zise(even)}')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А вот и более крутые решения. Класс!

odd += 1
print(f'Во введенном числе нечетных цифр: {odd}, четных цифр: {even}')
print(
f'Var2. Allocated memory size: {sys.getsizeof(number3) + calculate_zise(number_as_deque) + calculate_zise(odd) + calculate_zise(even)}')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Наверное вы хотели написать Var3. )))
Обращайте внимание на детали. И помните, чем чаще новичок копирует код, тем дольше он будет новичком.
Пишите с нуля, чтобы стать профи.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants