mirror of
https://github.com/ada-dmitry/python_ada.git
synced 2026-09-24 01:10:25 +00:00
added many files
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Employee():
|
||||||
|
|
||||||
|
def __init__(self, first_name, last_name, salary_of_year):
|
||||||
|
self.first_name = first_name
|
||||||
|
self.last_name = last_name
|
||||||
|
self.salary_of_year = salary_of_year
|
||||||
|
|
||||||
|
def give_raise(self, increment_of_salary=5000):
|
||||||
|
self.salary_of_year += increment_of_salary
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import unittest
|
||||||
|
from task11 import Employee
|
||||||
|
|
||||||
|
|
||||||
|
class TestEmployee(unittest.TestCase):
|
||||||
|
'''Класс для тестирования класса Employee'''
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.my_employee = Employee('Renal', 'Gayazov', 30000)
|
||||||
|
|
||||||
|
def test_give_default_raise(self):
|
||||||
|
self.my_employee.give_raise()
|
||||||
|
self.assertEqual(self.my_employee.salary_of_year, 35000)
|
||||||
|
|
||||||
|
def test_give_custom_raise(self):
|
||||||
|
self.my_employee.give_raise(9000)
|
||||||
|
self.assertEqual(self.my_employee.salary_of_year, 39000)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
5
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
def fact(x):
|
||||||
|
if(x==1):
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
return x*fact(x-1)
|
||||||
|
|
||||||
|
class FactTest(unittest.TestCase):
|
||||||
|
'''Проверка функции факториала'''
|
||||||
|
|
||||||
|
def test_5_fact(self):
|
||||||
|
ans = fact(5)
|
||||||
|
self.assertEqual(ans, 120)
|
||||||
|
|
||||||
|
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import json
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
def input_digit():
|
||||||
|
try:
|
||||||
|
with open('answer.json') as f:
|
||||||
|
x = json.load(f)
|
||||||
|
print(f'Ваше любимое число: {x}')
|
||||||
|
except FileNotFoundError:
|
||||||
|
x = int(input('Введите ваше любимое число: '))
|
||||||
|
with open('answer.json', 'w') as f:
|
||||||
|
json.dump(x, f)
|
||||||
|
|
||||||
|
|
||||||
|
def output_digit():
|
||||||
|
with open('answer.json') as f:
|
||||||
|
x = json.load(f)
|
||||||
|
print(f'Ваше любимое число: {x}')
|
||||||
|
|
||||||
|
input_digit()
|
||||||
|
|
||||||
|
output_digit()
|
||||||
|
|
||||||
|
class InputTest(unittest.TestCase):
|
||||||
|
'''Тесты для функции ввода с клавиатуры'''
|
||||||
|
def test_
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
|
with open('hub\data.json') as f:
|
||||||
|
data = json.load(f)
|
||||||
|
|
||||||
|
print(data["events_data"][0]['id'])
|
||||||
File diff suppressed because one or more lines are too long
+16
-1
@@ -1 +1,16 @@
|
|||||||
print("Hello, World!")
|
class restaurant():
|
||||||
|
def __init__(self, restaurant_name, cuisine_type):
|
||||||
|
self.restaurant_name = restaurant_name
|
||||||
|
self.cuisine_type = cuisine_type
|
||||||
|
|
||||||
|
def describe_restaurant(self):
|
||||||
|
print(f'{self.restaurant_name.title()}, {self.cuisine_type.title()}')
|
||||||
|
|
||||||
|
def open_rest(self):
|
||||||
|
print(f'Ресторан {self.restaurant_name.title()} открыт!')
|
||||||
|
|
||||||
|
rest = restaurant('Mish', 'rus')
|
||||||
|
|
||||||
|
rest.describe_restaurant()
|
||||||
|
|
||||||
|
rest.open_rest()
|
||||||
|
|||||||
Reference in New Issue
Block a user