mirror of
https://github.com/ada-dmitry/python_ada.git
synced 2026-09-24 01:10:25 +00:00
26 lines
666 B
Python
26 lines
666 B
Python
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_ |