From 20327a031a52a7bb93e6ef5053c86c308b7a44c9 Mon Sep 17 00:00:00 2001 From: denis-on Date: Wed, 16 Feb 2022 12:05:12 +0300 Subject: [PATCH] task-01 ok --- less-01/main.py | 16 ---------------- less-01/task-01.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 16 deletions(-) delete mode 100644 less-01/main.py create mode 100644 less-01/task-01.py diff --git a/less-01/main.py b/less-01/main.py deleted file mode 100644 index 5596b44..0000000 --- a/less-01/main.py +++ /dev/null @@ -1,16 +0,0 @@ -# This is a sample Python script. - -# Press Shift+F10 to execute it or replace it with your code. -# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. - - -def print_hi(name): - # Use a breakpoint in the code line below to debug your script. - print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint. - - -# Press the green button in the gutter to run the script. -if __name__ == '__main__': - print_hi('PyCharm') - -# See PyCharm help at https://www.jetbrains.com/help/pycharm/ diff --git a/less-01/task-01.py b/less-01/task-01.py new file mode 100644 index 0000000..56ddfaf --- /dev/null +++ b/less-01/task-01.py @@ -0,0 +1,38 @@ +# 1. Поработайте с переменными, создайте несколько, выведите на экран. +# Запросите у пользователя некоторые числа и строки +# и сохраните в переменные, затем выведите на экран. + +one = 'раз' +two = 'два' +thre = 3 +four = 4 +five = 5.0 + +print(f'{one} {two} {thre} {four} {five} или так') +print('%s %s %03d %f %.2f' % (one,two,thre,four,five) ) + +ans = input("Привет! пообщаемся?(*/N) ") # проверяем только отрицательный ответ + +while True: + if ans.lower() == "n": + print('Жаль :( ну пока') + break + print('Ура я "копм"') + name = input("А как тебя зовут? ") + + while True: # можно и проверочку сделать как вариант + try: + num = int(input("Напиши целое число от 1 до 10: ")) # на целое не проверяем. + except ValueError: + print("Это не число, попробуйте снова.") + else: + break + + print('') + even = 'не четное' if num % 2 else 'четное' + print('Молодец {} ты ввел(а) число {} и оно {}'.format(name.title(),num,even)) + + ans = input("Ещё разок?(*/N) ") + print('-'*15) + print('\n'*2) +