[PYTHON] Strengthen with code test ⑦

To next time

This time, if you know the standard input method, you can do it. There is also a device to find the divisor.

C19

code

python


input_line = input()

def divs(x):
    return [d for d in range(1, x + 1) if x % d == 0]

for i in range(int(input_line)):
    input_int = input()
    
    result = divs(int(input_int))
   
    N = result[-1]
    S = sum(result[0:-1])
    score = N-S
    
    if score == 0:
        print("perfect")
    elif score == 1:
        print("nearly")
    else:
        print("neither")

Recommended Posts

Strengthen with code test ⑦
Strengthen with code test ⑨
Strengthen with code test ③
Strengthen with code test ⑤
Strengthen with code test ④
Strengthen with code test ②
Strengthen with code test ①
Strengthen with code test ⑧
Strengthen with code test ⑨
Primality test with Python
Primality test with python
[Memo] Test code summary
Hamming code with numpy
In-house test code culture starting with just one person
Get country code with python
Python with VS Code (Windows 10)
Test embedded software with Google Test
Unit test flask with pytest
Test standard output with Pytest
PyCharm test code automatic generation
Test code for evaluating decorators
Debug Python with VS Code
Load test Websocket with Locust
Check the code with flake8
Document Python code with Doxygen
Test Driven Development with Django Part 3
Decrypt the QR code with CNN
Java with Visual Studio Code (Part 2)
Test Driven Development with Django Part 4
Test Driven Development with Django Part 6
Classify "Wine" with TensorFlow MLP code
Test Driven Development with Django Part 2
test
Unit test log output with python
Write selenium test code in python
Try running Jupyter with VS Code
It was with Nintendo's Code Puzzle
Test Driven Development with Django Part 1
Install python with mac vs code
Test Driven Development with Django Part 5
Controlling test reruns with Luigi + pytest
Automatic sample test case & manual input value test execution with VS Code with AtCoder
Python code to train and test with Custom Vision of Cognitive Service
[Python] Super easy test with assert statement
Stress Test with Locust written in Python
Test Python non-functional programs with GitLab CI
Image classification with Keras-From preprocessing to classification test-
WebUI test with Python2.6 + Selenium 2.44.0 --profile setting
Isn't it okay to write test code?
Generate Japanese test data with Python faker
Test Driven Development Startup with PySide & Pytest
Post Test 3 (Working with PosgreSQL in Python)
Create documentation and test code using doctest.testfile ()
Pass PYTHONPATH in 1 minute with VS Code
Display Japanese graphs with VS Code + matplotlib
How to do portmanteau test with python
Integrating with setuptools / python setup.py test / pytest-runner
Test automation starting with L-Chika (3) Oscilloscope integration
VS Code Pylint is annoying with import! !! !! !!
Automate Facebook App Testing with Facebook Test Users
python setup.py test the code using multiprocess