Hometask 3 added

This commit is contained in:
Vadym Samoilenko 2024-11-26 18:07:16 +00:00
parent 099deb9f5e
commit 4f682b0bb1
8 changed files with 153 additions and 82 deletions

5
.idea/codeStyles/codeStyleConfig.xml generated Normal file
View file

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

5
.idea/misc.xml generated
View file

@ -1,6 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="cmdArguments" value="-l 80 -t py313 -S" />
<option name="enabledOnReformat" value="true" />
<option name="enabledOnSave" value="true" />
<option name="executionMode" value="BINARY" />
<option name="pathToExecutable" value="/Library/Frameworks/Python.framework/Versions/3.13/bin/black" />
<option name="sdkName" value="Python 3.13" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.13" project-jdk-type="Python SDK" />

6
.idea/prettier.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PrettierConfiguration">
<option name="myRunOnSave" value="true" />
</component>
</project>

25
.idea/watcherTasks.xml generated Normal file
View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectTasksOptions">
<TaskOptions isEnabled="true">
<option name="arguments" value="$FilePathRelativeToProjectRoot$" />
<option name="checkSyntaxErrors" value="true" />
<option name="description" />
<option name="exitCodeBehavior" value="ERROR" />
<option name="fileExtension" value="py" />
<option name="immediateSync" value="true" />
<option name="name" value="Python" />
<option name="output" value="" />
<option name="outputFilters">
<array />
</option>
<option name="outputFromStdout" value="false" />
<option name="program" value="black" />
<option name="runOnExternalChanges" value="true" />
<option name="scopeName" value="Current File" />
<option name="trackOnlyRoot" value="false" />
<option name="workingDir" value="" />
<envs />
</TaskOptions>
</component>
</project>

View file

@ -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)
print(items)

55
Hometask3.py Normal file
View file

@ -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)

110
main.py
View file

@ -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)
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")

14
pyproject.toml Normal file
View file

@ -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__
)/
''' # Исключить определённые директории или файлы