diff --git a/Hello.py b/Hello.py new file mode 100644 index 0000000..8eb74cf --- /dev/null +++ b/Hello.py @@ -0,0 +1 @@ +print('Hello world') \ No newline at end of file diff --git a/Lesson_1/.idea/.gitignore b/Lesson_1/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Lesson_1/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Lesson_1/.idea/Lesson_1.iml b/Lesson_1/.idea/Lesson_1.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/Lesson_1/.idea/Lesson_1.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Lesson_1/.idea/inspectionProfiles/profiles_settings.xml b/Lesson_1/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/Lesson_1/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/Lesson_1/.idea/misc.xml b/Lesson_1/.idea/misc.xml new file mode 100644 index 0000000..a4652f3 --- /dev/null +++ b/Lesson_1/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Lesson_1/.idea/modules.xml b/Lesson_1/.idea/modules.xml new file mode 100644 index 0000000..a04d3c7 --- /dev/null +++ b/Lesson_1/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Lesson_1/.idea/vcs.xml b/Lesson_1/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Lesson_1/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Lesson_1/info.py b/Lesson_1/info.py new file mode 100644 index 0000000..94e3a87 --- /dev/null +++ b/Lesson_1/info.py @@ -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/ diff --git a/Lesson_1/task_1.py b/Lesson_1/task_1.py new file mode 100644 index 0000000..33c38c9 --- /dev/null +++ b/Lesson_1/task_1.py @@ -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) diff --git a/Lesson_1/task_2.py b/Lesson_1/task_2.py new file mode 100644 index 0000000..043e18f --- /dev/null +++ b/Lesson_1/task_2.py @@ -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)) diff --git a/Lesson_1/task_3.py b/Lesson_1/task_3.py new file mode 100644 index 0000000..e7a3517 --- /dev/null +++ b/Lesson_1/task_3.py @@ -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) diff --git a/Lesson_1/task_4.py b/Lesson_1/task_4.py new file mode 100644 index 0000000..1474b41 --- /dev/null +++ b/Lesson_1/task_4.py @@ -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}') diff --git a/Lesson_1/task_5.py b/Lesson_1/task_5.py new file mode 100644 index 0000000..3ebe687 --- /dev/null +++ b/Lesson_1/task_5.py @@ -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.') diff --git a/Lesson_1/task_6.py b/Lesson_1/task_6.py new file mode 100644 index 0000000..3c8bbac --- /dev/null +++ b/Lesson_1/task_6.py @@ -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') \ No newline at end of file