added many files

This commit is contained in:
ada-dmitry
2024-02-29 15:12:40 +03:00
parent 5a686b0f92
commit 09c84971a9
11 changed files with 101 additions and 1 deletions
Binary file not shown.
+12
View File
@@ -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
+21
View File
@@ -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()
+1
View File
@@ -0,0 +1 @@
5
+17
View File
@@ -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()
+1
View File
@@ -0,0 +1 @@
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+26
View File
@@ -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_
+6
View File
@@ -0,0 +1,6 @@
import json
with open('hub\data.json') as f:
data = json.load(f)
print(data["events_data"][0]['id'])
+1
View File
File diff suppressed because one or more lines are too long
+16 -1
View File
@@ -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()
View File