From 4f682b0bb13724d5477b4b54edf29a972141c63b Mon Sep 17 00:00:00 2001 From: Vadym Samoilenko Date: Tue, 26 Nov 2024 18:07:16 +0000 Subject: [PATCH] Hometask 3 added --- .idea/codeStyles/codeStyleConfig.xml | 5 ++ .idea/misc.xml | 5 ++ .idea/prettier.xml | 6 ++ .idea/watcherTasks.xml | 25 ++++++ Hometask 2.py | 15 ++-- Hometask3.py | 55 ++++++++++++++ main.py | 110 +++++++++------------------ pyproject.toml | 14 ++++ 8 files changed, 153 insertions(+), 82 deletions(-) create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/prettier.xml create mode 100644 .idea/watcherTasks.xml create mode 100644 Hometask3.py create mode 100644 pyproject.toml diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 1d3ce46..3c33bf2 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,11 @@ + diff --git a/.idea/prettier.xml b/.idea/prettier.xml new file mode 100644 index 0000000..b0ab31a --- /dev/null +++ b/.idea/prettier.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/watcherTasks.xml b/.idea/watcherTasks.xml new file mode 100644 index 0000000..cad9754 --- /dev/null +++ b/.idea/watcherTasks.xml @@ -0,0 +1,25 @@ + + + + + + + + \ No newline at end of file diff --git a/Hometask 2.py b/Hometask 2.py index 1f860c3..743fd67 100644 --- a/Hometask 2.py +++ b/Hometask 2.py @@ -35,11 +35,11 @@ num_str = 125 num_str = str(num_str) message = "Hi, my name is Python!" -message = message.replace('y', '0').replace('i', '1') +message = message.replace("y", "0").replace("i", "1") split_test = "This is a split test" -split_list = split_test.split(' ') -string_join = ' '.join(split_list) +split_list = split_test.split(" ") +string_join = " ".join(split_list) length_of_string_join = len(string_join) @@ -52,6 +52,7 @@ list_append = [1, 2, 3] list_append.append(4) list_append.append(5) + list_extend = [4, 5, 6] list_extend.extend([7, 8, 9]) @@ -64,9 +65,9 @@ print(list_extend) print(index_of_6) print(length_of_list_append) -dict_test = {'car': 'Toyota', 'price': 4900, 'where': 'EU'} -print(dict_test['car']) -print(dict_test['where']) +dict_test = {"car": "Toyota", "price": 4900, "where": "EU"} +print(dict_test["car"]) +print(dict_test["where"]) keys = dict_test.keys() values = dict_test.values() @@ -74,4 +75,4 @@ print(keys) print(values) items = dict_test.items() -print(items) \ No newline at end of file +print(items) diff --git a/Hometask3.py b/Hometask3.py new file mode 100644 index 0000000..905dc39 --- /dev/null +++ b/Hometask3.py @@ -0,0 +1,55 @@ +initial_password = "password123" +user_password = "password123" + +if user_password == initial_password: + print("Ви увійшли в систему") +else: + print("Неправильний пароль") + +day_number = 3 + +if day_number == 1: + print("Понеділок") +elif day_number == 2: + print("Вівторок") +elif day_number == 3: + print("Середа") +elif day_number == 4: + print("Четвер") +elif day_number == 5: + print("П'ятниця") +elif day_number == 6: + print("Субота") +elif day_number == 7: + print("Неділя") +else: + print("Неправильний номер дня тижня") + +number = 5 +for i in range(1, 11): + print(f"{number} * {i} = {number * i}") + +numbers = [1, 2, 3, 4, 5] +sum_of_numbers = sum(numbers) +print(f"Сума чисел: {sum_of_numbers}") + +factorial_number = 5 +factorial = 1 +for i in range(1, factorial_number + 1): + factorial *= i +print(f"Факторіал числа {factorial_number}: {factorial}") + +for i in range(1, 51): + if i % 2 == 0: + print(i) + +start = 10 +end = 50 + +for num in range(start, end + 1): + if num > 1: + for i in range(2, int(num**0.5) + 1): + if num % i == 0: + break + else: + print(num) diff --git a/main.py b/main.py index 1f860c3..f7282f6 100644 --- a/main.py +++ b/main.py @@ -1,77 +1,37 @@ -my_string = "Hello, World!" -my_integer = 42 -my_float = 3.14 -my_bool = True -my_list = [1, 2, 3, 4, 5] -my_dict = {"key1": "value1", "key2": "value2"} -my_tuple = (1, 2, 3) -my_none = None +user_1 = { + "name": "Tom", + "age": 25, + "balance": 10000, + "currency": "USD", + "status": "true", +} +user_2 = { + "name": "John", + "age": 17, + "balance": 5000, + "currency": "EUR", + "status": "false", +} +user_3 = { + "name": "Karine", + "age": 30, + "balance": 100000, + "currency": "UAH", + "status": "true", +} -num1 = 10 -num2 = 20 -print(num1 < num2) +lis_of_currency = ["USD", "EUR", "UAH", "GBP"] -str1 = "apple" -str2 = "banana" -print(str1 == str2) - -bool1 = True -bool2 = False -print(bool1 and bool2) - -list1 = [1, 2, 3] -list2 = [1, 2, 3] -print(list1 == list2) - -dict1 = {"key1": "value1", "key2": "value2"} -dict2 = {"key1": "value1", "key2": "value2"} -print(dict1 == dict2) - -tuple1 = (1, 2, 3) -tuple2 = (1, 2, 3) -print(tuple1 == tuple2) - -num_str = 125 -num_str = str(num_str) - -message = "Hi, my name is Python!" -message = message.replace('y', '0').replace('i', '1') - -split_test = "This is a split test" -split_list = split_test.split(' ') -string_join = ' '.join(split_list) - -length_of_string_join = len(string_join) - -print(num_str) -print(message) -print(string_join) -print(length_of_string_join) - -list_append = [1, 2, 3] -list_append.append(4) -list_append.append(5) - -list_extend = [4, 5, 6] -list_extend.extend([7, 8, 9]) - -index_of_6 = list_extend.index(6) - -length_of_list_append = len(list_append) - -print(list_append) -print(list_extend) -print(index_of_6) -print(length_of_list_append) - -dict_test = {'car': 'Toyota', 'price': 4900, 'where': 'EU'} -print(dict_test['car']) -print(dict_test['where']) - -keys = dict_test.keys() -values = dict_test.values() -print(keys) -print(values) - -items = dict_test.items() -print(items) \ No newline at end of file +if user_1["name"] and user_1["age"] >= 18 and user_1["status"]: + if user_1["balance"] >= 10000 and user_1["currency"] in lis_of_currency: + print( + f"Welcome to our service! You can create your binance account, welcome {user_1['name']}!" + ) + elif user_1["balance"] >= 1000 and user_1["currency"] in lis_of_currency: + print("You needmore money to create an account") + else: + print("You can't create an account") +elif user_1["name"] == "": + print("Please, write your name in your account description") +elif user_1["age"] < 18: + print("You are too young") diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d60489d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,14 @@ +[tool.black] +line-length = 88 # Максимальная длина строки +target-version = ["py313"] # Указание версии Python 3.13 +skip-string-normalization = false # Принудительное использование двойных кавычек +include = '\.pyi?$' # Форматировать только .py и .pyi файлы +exclude = ''' +/( + \.git + | \.venv + | build + | dist + | __pycache__ +)/ +''' # Исключить определённые директории или файлы \ No newline at end of file