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
34 changes: 34 additions & 0 deletions hometask1/task1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python
# nevl 2021

if __name__ == '__main__':
# variables
test_int = 1
test_float = 1.1
test_str = 'String'
test_bool = True
test_list = [1, 2]
test_tuple = (3, 4)
test_dict = {
"first": 1,
"second": 2
}

# print section
print(test_int)
print(test_float)
print(test_str)
print(test_bool)
print(test_list)
print(test_tuple)
print(test_dict)

# input section
tmp_str = input('Write string: ')
print(tmp_str, type(tmp_str))
tmp_int = input('Write integer: ')
print(tmp_int, type(tmp_int))
tmp_float = input('Write float: ')
print(tmp_float, type(tmp_float))

print('Done')
18 changes: 18 additions & 0 deletions hometask1/task2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python
# nevl 2021

if __name__ == '__main__':
# fetch count of seconds and check for number
while True:
tmp = input('Input seconds: ')
try:
tmp = int(tmp)
break
except:
print('Input not a number')

# calculate time
hours = tmp // 3600
minutes = (tmp - (hours * 3600)) // 60
seconds = tmp % 60
print(f'{hours:02}:{minutes:02}:{seconds:02}')
24 changes: 24 additions & 0 deletions hometask1/task3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python
# nevl 2021

if __name__ == '__main__':
# fetch number and check
while True:
tmp = input('Input number: ')
try:
tmp = int(tmp)
if tmp < 0 or tmp > 9:
print('Enter only one symbol.')
continue
else:
break
except:
print('Not a number. Try again.')
continue

# make new numbers in strings
s2 = f'{tmp}'*2
s3 = f'{tmp}'*3

# calculate
print(tmp + int(s2) + int(s3))
25 changes: 25 additions & 0 deletions hometask1/task4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python
# nevl 2021

if __name__ == '__main__':
# fetch number and check
while True:
tmp = input('Input number: ')
try:
tmp = int(tmp)
if tmp <= 0:
print('Input positive number.')
continue
break
except:
print('Input not a number')

# find the biggest number
number = 0
while tmp > 0:
t = tmp % 10
if t > number:
number = t
tmp //= 10

print(f'The biggest number is: {number}')
45 changes: 45 additions & 0 deletions hometask1/task5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env python
# nevl 2021

def is_number(str):
try:
tmp = float(str)
if tmp <= 0:
print('Input positive number.')
return True
except:
print('Input not a number')
return False

if __name__ == '__main__':
# fetch proceeds
while True:
proceeds = input('Input proceeds: ')
if is_number(proceeds):
break

# fetch costs
while True:
costs = input('Input costs: ')
if is_number(costs):
break

# check financial results
profit = float(proceeds) - float(costs)
financial_results = 'profit' if profit > 0 else 'loss'
print(f'Financial results are {financial_results}')

# profitability of proceeds
if profit > 0:
profitability_of_proceeds = profit / float(proceeds)
print(f'Profitability of proceeds = {profitability_of_proceeds}')

# number of employees
while True:
number_of_employees = input('Input number of employees: ')
if is_number(number_of_employees):
break

# profit per employee
profit_per_employee = profit / float(number_of_employees)
print(f'Profit {profit_per_employee} per employee.')
33 changes: 33 additions & 0 deletions hometask1/task6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python
# nevl 2021

def is_int(str):
try:
tmp = int(str)
if tmp <= 0:
print('Input positive number.')
return True
except:
print('Input not a number')
return False

if __name__ == '__main__':
# fetch proceeds
while True:
a = input('Input a: ')
if is_int(a):
break

# fetch costs
while True:
b = input('Input b: ')
if is_int(b):
break

count = 1
distance = float(a)
while distance < int(b):
distance += distance * 0.1
count += 1

print(count)