Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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.

16 changes: 16 additions & 0 deletions Lesson_1/info.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/
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')
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)
20 changes: 20 additions & 0 deletions Lesson_2/task_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Пользователь вводит месяц в виде целого числа от 1 до 12.
# Сообщить, к какому времени года относится месяц (зима, весна, лето, осень).
# Напишите решения через list и dict.

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 the Winter season")
elif a == 3 or a == 4 or a == 5:
print("Your choiсe is the Spring season")
elif a == 6 or a == 7 or a == 8:
print("Your choiсe is the Summer season")
elif a == 9 or a == 10 or a == 11:
print("Your choiсe is the Autumn season")
else:
print("You made a mistake. Try again!")