Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4b7b70c
Hello world (python)
PaLoLegych Feb 14, 2022
f33b103
connection test
PaLoLegych Feb 18, 2022
f4fd7e8
The solution of the first task was added
PaLoLegych Feb 18, 2022
5e96983
The solution of the second task was added
PaLoLegych Feb 18, 2022
28c8e8d
A small deign revision
PaLoLegych Feb 18, 2022
63a3758
The result of the task 3
PaLoLegych Feb 19, 2022
8230f6d
Added some changes in "print()"
PaLoLegych Feb 19, 2022
dddf7ed
Работает, но очень коряво. Нужно разбираться.
PaLoLegych Feb 19, 2022
87b1ad0
The result of the task 5
PaLoLegych Feb 19, 2022
9557362
The code was edited (mistakes correction).
PaLoLegych Feb 20, 2022
55ada12
The results of the task 6
PaLoLegych Feb 20, 2022
22aa221
The first version of the code. Wanted to write a code with a request …
PaLoLegych Feb 21, 2022
bb13d78
The first version of the code. It is not clear why the last digit in …
PaLoLegych Feb 22, 2022
13b5afc
The first version of the code. I didn’t figure out how to make both a…
PaLoLegych Feb 22, 2022
8ec2618
Some changes have been made to the code.
PaLoLegych Feb 24, 2022
d6c8f8f
Some changes have been made to the code (added the list).
PaLoLegych Feb 24, 2022
4c37412
Simple code.
PaLoLegych Feb 24, 2022
806e43a
Added some changes.
PaLoLegych Feb 24, 2022
aba8902
The first variant of the code. There is some bugs (need to think).
PaLoLegych Feb 24, 2022
4650e4c
Added some changes.
PaLoLegych Feb 24, 2022
6b6173f
Added some changes.
PaLoLegych Feb 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print('Hello world')
3 changes: 3 additions & 0 deletions Lesson_1/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Lesson_1/.idea/Lesson_1.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Lesson_1/.idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Lesson_1/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Lesson_1/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Lesson_1/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Lesson_1/task_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Поработайте с переменными, создайте несколько, выведите на экран.
# Запросите у пользователя некоторые числа и строки и сохраните в переменные,
# затем выведите на экран.
a = 10
b = 45.23
c = a + b
d = a - b
x = c / d
print(a)
print(b)
print(c)
print(d)
print(x)

name = input('Please, enter your name: ')
print("Hi, %s!" % name)
i = int(input('Please, enter a random number: '))
a = i + i * i
print('Thank you very much. The answer is: %d' %a)
8 changes: 8 additions & 0 deletions Lesson_1/task_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Пользователь вводит время в секундах.
# Переведите время в часы, минуты, секунды и выведите в формате чч:мм:сс.
# Используйте форматирование строк.
Interval = int(input('Please, enter the time interval in seconds: '))
H = Interval // 3600
M = (Interval - H * 3600) // 60
S = Interval - (H * 3600 + M * 60)
input('If your time interval is equal to %d than the current time is: ' % (Interval) + '%02d:%02d:%02d' % (H, M, S))
11 changes: 11 additions & 0 deletions Lesson_1/task_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Узнайте у пользователя число n.
# Найдите сумму чисел n + nn + nnn.
# Например, пользователь ввёл число 3.
# Считаем 3 + 33 + 333 = 369.

n = int(input('Please, enter a random value = '))
x = str(n)
nn = x + x
nnn = x + x + x
cal = n + int(nn) + int(nnn)
print('Based on your value: %d ' % n + 'the result of the calculation is = %d' % cal)
14 changes: 14 additions & 0 deletions Lesson_1/task_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Пользователь вводит целое положительное число.
# Найдите самую большую цифру в числе.
# Для решения используйте цикл while и арифметические операции.
val = int(input('Please, enter positive value: '))
max_val = val % 10
num = val
while num > 0:
dgt = num % 10
if dgt > max_val:
max_val = dgt
if max_val == 9:
break
num = num // 10
print(f'The largest digit in {val} is = {max_val}')
18 changes: 18 additions & 0 deletions Lesson_1/task_5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Запросите у пользователя значения выручки и издержек фирмы.
# Определите, с каким финансовым результатом работает фирма.
# Например, прибыль — выручка больше издержек,
# или убыток — издержки больше выручки. Выведите соответствующее сообщение.
# Если фирма отработала с прибылью, вычислите рентабельность выручки. Э
# то отношение прибыли к выручке. Далее запросите численность сотрудников
# фирмы и определите прибыль фирмы в расчёте на одного сотрудника.

rev = float(input('Please enter revenue of the company: '))
cos = float(input('Please enter costs of the company: '))
inc = rev - cos
if inc > 0:
print('The company is profitable.')
print(f'Return on revenue is: {inc / rev: .2f}')
staff = int(input('Please enter the number of employees:'))
print(f'Profit per employee is: {rev / staff: .2f}')
else:
print('The company is unprofitable.')
15 changes: 15 additions & 0 deletions Lesson_1/task_6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Спортсмен занимается ежедневными пробежками.
# В первый день его результат составил a километров.
# Каждый день спортсмен увеличивал результат
# на 10% относительно предыдущего. Требуется определить номер дня,
# на который результат спортсмена составит не менее b километров.
# Программа должна принимать значения параметров a и b и
# выводить одно натуральное число — номер дня.

a = int(input('Please enter the current distance value '))
b = int(input('Please enter the distance you would like to run '))
ad = 1 # ad = amount of the days
while a < b:
a = 1.1 * a
ad += 1
print(f'If you increase your distance by 10% you will be able to run2 {b} km in {ad} days')
3 changes: 3 additions & 0 deletions Lesson_2/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Lesson_2/.idea/Lesson_2.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Lesson_2/.idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Lesson_2/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Lesson_2/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Lesson_2/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions Lesson_2/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This is a sample Python script.

# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ 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 ⌘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/
8 changes: 8 additions & 0 deletions Lesson_2/task_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Создать список и заполнить его элементами различных типов данных.
# Реализовать скрипт проверки типа данных каждого элемента.
# Использовать функцию type() для проверки типа.
# Элементы списка можно не запрашивать у пользователя, а указать явно, в программе.

main_list = [56, 3.76, False, "Hello", ('2', 'a', '6'), ['b', '3', 'c'], {'123': 'key-1', '321': 'key-2'}]
for i in main_list:
print(f'{i} is {type(i)}')
22 changes: 22 additions & 0 deletions Lesson_2/task_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Для списка реализовать обмен значений соседних элементов.
# Значениями обмениваются элементы с индексами 0 и 1, 2 и 3 и т. д.
# При нечётном количестве элементов последний сохранить на своём месте.
# Для заполнения списка элементов нужно использовать функцию input().

list_init = input('Please, enter the values separated by spaces: ').split()
print(list_init)
if len(list_init) % 2 == 0:
i = 0
while i < len(list_init):
el = list_init[i]
list_init[i] = list_init[i + 1]
list_init[i + 1] = el
i += 2
else:
i = 0
while i < len(list_init) - 1:
el = list_init[i]
list_init[i] = list_init[i + 1]
list_init[i + 1] = el
i += 2
print(list_init)
21 changes: 21 additions & 0 deletions Lesson_2/task_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Пользователь вводит месяц в виде целого числа от 1 до 12.
# Сообщить, к какому времени года относится месяц (зима, весна, лето, осень).
# Напишите решения через list и dict.

m_list = ['Winter', 'Spring', 'Summer', 'Autumn']
m_dict = {1: 'January', 2: 'February', 3: 'March',
4: 'April', 5: 'May', 6: 'June',
7: 'July', 8: 'August', 9: 'September',
10: 'October', 11: 'November', 12: 'December'}
num_m = int(input('Please enter a month number from 1 to 12: '))
a = num_m
if a == 1 or a == 2 or a == 12:
print('Your choiсe is', m_dict.get(num_m), 'it is', m_list[0], 'season')
elif a == 3 or a == 4 or a == 5:
print('Your choiсe is', m_dict.get(num_m), 'it is', m_list[1], 'season')
elif a == 6 or a == 7 or a == 8:
print('Your choiсe is', m_dict.get(num_m), 'it is', m_list[2], 'season')
elif a == 9 or a == 10 or a == 11:
print('Your choiсe is', m_dict.get(num_m), 'it is', m_list[3], 'season')
else:
print("You made a mistake. Try again!")
11 changes: 11 additions & 0 deletions Lesson_2/task_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Пользователь вводит строку из нескольких слов, разделённых пробелами.
# Вывести каждое слово с новой строки. Строки нужно пронумеровать.
# Если слово длинное, выводить только первые 10 букв в слове.

my_str = input('Please enter some text with spaces between words: ')
value = my_str.split()
for i, el in enumerate(value):
if len(el) > 10:
el = el[0:10:1]
print(i, el)

22 changes: 22 additions & 0 deletions Lesson_2/task_5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Реализовать структуру «Рейтинг», представляющую собой набор натуральных чисел,
# который не возрастает. У пользователя нужно запрашивать новый элемент рейтинга.
# Если в рейтинге существуют элементы с одинаковыми значениями, то новый элемент
# с тем же значением должен разместиться после них.
# Подсказка. Например, набор натуральных чисел: 7, 5, 3, 3, 2.
# Пользователь ввёл число 3. Результат: 7, 5, 3, 3, 3, 2.
# Пользователь ввёл число 8. Результат: 8, 7, 5, 3, 3, 2.
# Пользователь ввёл число 1. Результат: 7, 5, 3, 3, 2, 1.
# Набор натуральных чисел можно задать сразу в коде, например, my_list = [7, 5, 3, 3, 2].

my_list = [8, 8, 7, 5, 3, 3, 2, 1, 1]
print(my_list)
num = int(input('Please enter a number (enter 000 to Exit): '))
while num != 000:
i = 0
for el in my_list:
if num > el:
break
i += 1
my_list.insert(i, num)
print(my_list)
num = int(input('Please enter a number: '))