Find the difference in Python

import random

def main():

    # rnd = random.randint(50, 100)
    # rnd = random.random()
    count = 0
    postions = []

    problem = ""

    A = "Nu"
    B = "Me"

    for x in range(1, 11):
        for y in range(1, 11):

            if y % 10 == 0:
                print(A)
                problem += A + "\n"
            else:
                if random.random() < 0.1:
                    print(B, end="")
                    count = count + 1
                    problem += B

                    p = [x, y]
                    postions.append(p)
                else:
                    print(A, end="")
                    problem += A

    # print(count)
    # print(postions)
    # print("=======")
    # print(problem)


    print("--------------------")
    print("Answer ⬇︎")
    
    print("The number of "me" is{}Pieces".format(count))
    

    for a in postions:
        print(""Me" is{}line,{}Column".format(a[0], a[1]))

    with open("result.txt", "w") as f:
        f.write("Spot the difference quiz\n")
        f.write(problem)
        f.write("The number of "me" is{}Pieces\n".format(count))

        for a in postions:
            f.write(""Me" is{}line,{}Column\n".format(a[0], a[1]))

if __name__ == '__main__':
    main()

スクリーンショット 2020-10-12 13.31.58.png

The position and number of "me" will change randomly in columns of vertical x 10 and horizontal x 10.

Finally

It took a while because I did it to deepen my understanding, but I'm glad that it worked properly.

Recommended Posts

Find the difference in Python
Find the maximum Python
List find in Python
About the difference between "==" and "is" in python
Find the divisor of the value entered in python
Find the solution of the nth-order equation in python
[Python] Find the transposed matrix in a comprehension
python xlwings: Find the cell in the last row
Download the file in Python
Find permutations / combinations in Python
Let's find pi in Python
Find the maximum python (improved)
Find the part that is 575 from Wikipedia in Python
Find the Hermitian matrix and its eigenvalues in Python
Getting the arXiv API in Python
Difference between list () and [] in Python
Difference between == and is in python
Python in the browser: Brython's recommendation
Save the binary file in Python
Hit the Sesami API in Python
Get the desktop path in Python
Get the script path in Python
In the python command python points to python3.8
Implement the Singleton pattern in Python
Find the Levenshtein Distance with python
Hit the web API in Python
I wrote the queue in Python
Calculate the previous month in Python
Examine the object's class in python
Get the desktop path in Python
Get the host name in Python
Access the Twitter API in Python
The first step in Python Matplotlib
I wrote the stack in Python
Master the weakref module in Python
Find out the apparent width of a string in python
Python --Find out number of groups in the regex expression
Get the current date and time in Python, considering the time difference
Find the eigenvalues of a real symmetric matrix in Python
I just want to find the 95% confidence interval for the difference in population ratios in Python
Quadtree in Python --2
Find the maximum value python (fixed ver)
Python in optimization
Learn the design pattern "Prototype" in Python
CURL in python
Learn the design pattern "Builder" in Python
Load the remote Python SDK in IntelliJ
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Try using the Wunderlist API in Python
Check the behavior of destructor in Python
[Python] Solving the import problem due to the difference in entry points
Meta-analysis in Python
difference between statements (statements) and expressions (expressions) in Python
Try using the Kraken API in Python
Learn the design pattern "Observer" in Python
Learn the design pattern "Memento" in Python
Unittest in python
Find files like find on linux in Python