Уведомления

Группа в Telegram: @pythonsu

#1 Апрель 5, 2019 16:44:45

evgeniy2018123
Зарегистрирован: 2018-07-30
Сообщения: 13
Репутация: +  0  -
Профиль   Отправить e-mail  

РЕБЯТ ЛЕГКИЙ ВОПРОС надо проверить просто !!!!

Значит ребят вот задание и пример кода который поломан я ео зделал НО хочу чтобы проверили другие люди СПАСИБО зарнее)
Задание
Программа, приведенная ниже, реализует компьютерного
ассистента, который спрашивает у пользователя день, месяц
и год рождения, а затем выводить возраст в годах, месяцах и
днях. Это была бы очень крутая программа, но кто-то взломал нашу систему и внес изменения в код! В инструкции if
появились символы **, а переменная уже не хранит данные!
Исправьте все ошибки и неточности и запустите программу.
—–ПОЛОМАНЫЙ КОД ——

# Step 1
start import datetime
# Step 2
birth day = int(input("Day of birth: "))
birth month = int(input("Month of birth: "))
birth year = int(input("Year of birth: "))
day = int(datetime.date.today().day)
month = int(datetime.date.today().month)
year = int(datetime.date.today().year)
# Step 3
if * > **:
age = year - birth_year
then:
age = (year - birth_year) - 1
# Step 4
a = age
b = abs(month - birth_month)
c = abs(day - birth_day)
print("Your age: {a} years, {b} months, {c} days")
—-МОЙ ПОИДЕИ ПРАВИЛЬНЫЙ КОД—–
import datetime
# Step 2
birth_day = int(input("Day of birth: "))
birth_month = int(input("Month of birth: "))
birth_year = int(input("Year of birth: "))
day = int(datetime.date.today().day)
month = int(datetime.date.today().month)
year = int(datetime.date.today().year)
# Step 3

if year > birth_year:
age = year - birth_year
else:
age = (year - birth_year) - 1
# Step 4
a = age
b = abs(month - birth_month)
c = abs(day - birth_day)
print(f"Your age: {a} years, {b} months, {c} days")

Офлайн

#2 Апрель 11, 2019 11:22:30

Bogdan82
Зарегистрирован: 2019-04-11
Сообщения: 3
Репутация: +  0  -
Профиль   Отправить e-mail  

РЕБЯТ ЛЕГКИЙ ВОПРОС надо проверить просто !!!!

Homework
“”“
This is a list of functions that should be completed.
”“”

from typing import Any
from typing import List


class OurAwesomeException(Exception):
pass


def is_two_object_has_same_value(first: Any, second: Any) -> bool:
“”“
If @first and @second has same value should return True
In another case should return False
”“”
pass


def is_two_objects_has_same_type(first: Any, second: Any) -> bool:
“”“
If @first and @second has same type should return True
In another case should return False
”“”
pass


def is_two_objects_is_the_same_objects(first: Any, second: Any) -> bool:
“”“
If @first and @second has same type should return True
In another case should return False
”“”
pass


def multiple_ints(first_value: int, second_value: int) -> int:
“”“
Should calculate product of all args.
if first_value or second_value is not int should raise ValueError

Raises:
ValueError

Params:
first_value: value for multiply
second_value
Returns:
Product of elements
”“”
pass


def multiple_ints_with_conversion(first_value: Any, second_value: Any) -> int:
“”“
If possible to convert arguments to int value - convert and multiply them.
If it is impossible raise OurAwesomeException

Args:
first_value: number for multiply
second_value: number for multiply

Raises:
OurAwesomeException

Returns: multiple of two numbers.

Examples:
multiple_ints_with_conversion(6, 6)
>>> 36
multiple_ints_with_conversion(2, 2.0)
>>> 4
multiple_ints_with_conversion(”12“, 1)
>>> 12
try:
multiple_ints_with_conversion(”Hello“, 2)
except ValueError:
print(”Not valid input data“)
>>> ”Not valid input data“
”“”
pass


def is_word_in_text(word: str, text: str) -> bool:
“”“
If text contain word return True
In another case return False.

Args:
word: Searchable substring
text: Text for searching

Examples:
is_word_in_text(”Hello“, ”Hello word“)
>>> True
is_word_in_text(”Glad“, ”Nice to meet you “)
>>> False

”“”
pass


def some_loop_exercise() -> list:
“”“
Use loop to create list that contain int values from 0 to 12 except 6 and 7
”“”
pass


def remove_from_list_all_negative_numbers(data: List) -> list:
“”"
Use loops to solve this task.
You could use data.remove(negative_number) to solve this issue.
Also you could create new list with only positive numbers.
Examples:
remove_from_list_all_negative_numbers()
>>>
“”“
pass


def alphabet() -> dict:
”“”
Create dict which keys is alphabetic characters. And values their number in alphabet
Notes You could see an implementaion of this one in test, but create another one
Examples:
alphabet()
>>> {“a”: 1, “b”: 2 …}
“”"
pass

def simple_sort(data: List) -> List

  • :
    “”"
    Sort list of ints without using built-in methods.
    Examples:
    simple_sort()
    >>>
    Returns:
    “”"
    Pass
    Помогите пожалуста!

Отредактировано Bogdan82 (Апрель 11, 2019 11:24:25)

Офлайн

#3 Апрель 11, 2019 11:30:15

FishHook
От:
Зарегистрирован: 2011-01-08
Сообщения: 8312
Репутация: +  568  -
Профиль   Отправить e-mail  

РЕБЯТ ЛЕГКИЙ ВОПРОС надо проверить просто !!!!

Bogdan82
Что это?



Офлайн

#4 Апрель 14, 2019 14:18:12

Bogdan82
Зарегистрирован: 2019-04-11
Сообщения: 3
Репутация: +  0  -
Профиль   Отправить e-mail  

РЕБЯТ ЛЕГКИЙ ВОПРОС надо проверить просто !!!!

помогите з кодом

Офлайн

#5 Апрель 14, 2019 14:23:24

Bogdan82
Зарегистрирован: 2019-04-11
Сообщения: 3
Репутация: +  0  -
Профиль   Отправить e-mail  

РЕБЯТ ЛЕГКИЙ ВОПРОС надо проверить просто !!!!

не могу разобрать

Прикреплённый файлы:
attachment homework.py (3,2 KБ)

Офлайн

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version