I made a competitive programming glossary with Python

table of contents

  1. Development environment
  2. Glossary code
  3. Explanation
  4. References

1. Development environment

MacOS Big Sur 11.0.1 I'm running it in Spyder. In a terminal or command prompt before running this program

pip install pyttsx3

Please write and install pyttsx. This allows you to use the reading function. If you run pyttsx even if you have it installed on a website such as Paiza,

At the terminal, command prompt
pip install pyttsx3
Please write and install pyttsx3.
This program cannot be run without installation.

Message will appear. Please execute it with an editor or Spyder.

2. Glossary code

from webbrowser import open
from sys import exit
try:
    import pyttsx3
except:
    print("At the terminal, command prompt\npip install pyttsx3\Write n and install pyttsx3.")
    print("This program cannot be run without installation.")
    exit()
    
def ask(S):
    
    while True:
        n = input(str(S)+"(Y/N)\n>>>")
        if n == "Y" or n == "N":
            break
    return n

def settei():
    
    a = {}
    n = "a"
    print("Start the initial setup.")
    n = ask("Do you want to read aloud?")
    a["read"] = n
    if n == "Y":
        print("Please be careful about the volume")
    return a
    

def read(ph):
    
    engine = pyttsx3.init()
    voices = engine.getProperty('voices')
    engine.setProperty("voice", voices[18].id)
    engine.say(ph)
    engine.runAndWait()
    

    
n = "a"
atcoder = ["AC","WJ","TLE","Contestant","Competitive programming","WA","MLE","OLE","IE","RE"]#Terminology that can be jumped to the Atcoder glossary
paiza = ["paiza","paiza learning","EN:TRY","Paiza new graduate"]#Terminology that can be jumped to paiza glossary


l = {"Atcoder":'''Solved! I want to deliver to the world.

AtCoder is the world's premier competitive programming site.
Compete in real-time online contests,
3,You can challenge over 000 past questions at any time.
'''
,"paiza":'''

With skill check
Programming ability diagnosis
Visualize skill levels in 6 levels by checking programming skills with a cumulative total of 2 million exams.
'''
,"paiza learning":'''

paiza learning is an online programming introductory learning content using videos.
In the programming course, Java, Python, Ruby, PHP, C language, SQL, JavaScript, HTML+Published courses such as CSS. You can learn efficiently with a video of about 3 minutes each and exercises corresponding to each chapter.
'''
,"EN:TRY":'''

EN:TRY (entry) is a completely new form of coding career change service that allows you to write a code and proceed to an interview / casual interview without document screening.
Development practice is posted mainly on job offers that can be challenged even if you are inexperienced! For example, "I want to become an IT engineer from where I am inexperienced!"
We will fulfill your desire to gain more full-scale development experience!
'''
,"Paiza new graduate":'''

paiza writes a code and proceeds to an interview / casual interview without document screening.
It is a completely new form of coding job hunting service. Interviews are possible if you write the code in a field or language that you do not have practical experience with!

'''
,"Qiita":'''

"Qiita" is an open information sharing community specializing in programming that allows you to share knowledge and improve your skills.
Since its release on September 16, 2011, the number of access users has steadily increased, and it has become a service accessed by more than 2.5 million users. About 200 new information is posted every day, and more than 170,000 posts are collected.
(Both the number of access users and the number of posts are as of the end of September 2016.)
'''
,"note.nkmk.me":'''

Various programming information(Algorithms, how to use functions, etc.)There is a convenient site.
For example, the site below is a summary of functions that can solve mathematics up to high school.
https://note.nkmk.me/python-mathematics/
'''
,"Naohiro Takahashi":'''

Born in Tokyo. He graduated from Komaba Junior and Senior High School attached to Tsukuba University, Faculty of Environment and Information Studies, Keio University, and completed the master's program at Keio University Graduate School of Media and Governance.[3]。
While attending university, he won the 3rd place in the world in the algorithm category of the Imagine Cup 2008, a programming contest sponsored by Microsoft.[2][4][5][6][7]。
Currently, besides a programmer, he runs a company called AtCoder that organizes programming contests.[8]。
In the past, ITmedia had a serialization called "The Strongest and Fastest Algorithm Training Course"[2]。
'''
,"Atcoder color":'''

See this site for instructions.
http://chokudai.hatenablog.com/entry/2019/02/11/155904
'''
,"Python":'''

A scripting language developed by Guido van Rossum.
It has the feature that it is easy to modularize the program (it can be written in other languages) and incorporate it into other programs.
In addition, the rules regarding how to write the source code are strict, and it is considered that the source code will be easy to read by following the rules. Although it was a popular language in Europe and the United States, it did not have a complete system for handling Japanese.
Currently, it supports Unicode character string operations, and Japanese character strings can also be operated. Often used to develop web applications.
'''
,"C++":'''

C++(Sea Plus Plus) is one of the general-purpose programming languages. It is commonly called "Shipura" or "Shipura" among Japanese speakers.
While inheriting the functions and features of the C language from which it was derived, multiple programming paradigms such as procedural programming, data abstraction, object-oriented programming, and generic programming are combined to improve expressiveness and efficiency.[2]。
It can be used as a low-level language for lower layers that directly handles hardware such as C, or as a high-level language for upper layers for developing complex application software.
It is an important principle of language design that it does not require a low-level language other than assembly language and that it does not require time and space costs for unused functions.[3][4]。
C++AT in 1983&Published by Bjarne Stroustrup, a computer scientist at Bell Labs. The development environment has also been introduced on various platforms.
Since 1998, ISO and IEC have jointly standardized language specifications and template libraries, and then the standards have been revised in 2003, 2011, 2014, and 2017.
The latest standard as of 2019 is `` ISO/IEC 14882:2017 "commonly known as" C++17 ".
'''
,"Standard input":'''

A program running on UNIX can receive data from the keyboard by issuing a read request to standard input.
The file pointer is assigned to stdin and the file descriptor is assigned 0.
Instead of receiving data from the keyboard, you can receive data from a file as standard input.
Such an operation is called a redirect.
A program running on UNIX is implicitly assigned to standard input, standard output, and standard error output.
'''
,"AC":'''

That's the correct answer. It passed all the tests prepared by the operation and was judged to be the correct program.
'''
,"WJ":'''

The submitted program is waiting for a judge.
'''
,"Contestant":'''
Contest participants.
'''
,"Competitive programming":'''

It is a competition to see how accurate and quick a program can be created for a given problem.
'''
,"TLE":'''

The program did not finish within the execution time specified in the problem.(Wrong answer)
'''
,"WA":'''

It's a wrong answer. The output of the submitted program is incorrect.
'''
,"MLE":'''

The memory limit specified in the problem has been exceeded.
'''
,"OLE":'''

Output size exceeds the limit specified in the problem.
'''
,"IE":'''

An internal error, that is, a judge system error.
'''
,"RE":'''

An error occurred while running the program. There is an error that could not be detected at compile time.Caused by stack overflow, division by zero, etc..
'''
}

sannkou = ["Website"
           ,"https://note.nkmk.me/python-dict-keys-values-items/","https://increments.co.jp/products/qiita/"
           ,"https://paiza.jp/guide/career","https://paiza.jp/guide/student"
           ,"https://paiza.jp/guide/en_try","https://paiza.jp/guide/works"
           ,"https://note.nkmk.me/python-mathematics/","https://ja.wikipedia.org/wiki/Competitive programming"
           ,"https://ja.wikipedia.org/wiki/Naohiro Takahashi","http://chokudai.hatenablog.com/entry/2019/02/11/155904"
           ,"http://chokudai.hatenablog.com","https://tonari-it.com/python-webbrowser-open/"
           ,"https://ja.wikipedia.org/wiki/C%2B%2B","https://atcoder.jp/contests/abc074/glossary?lang=ja"
           ,"https://code-graffiti.com/anaconda-navigator-does-not-start/","https://miyukimedaka.com/2020/06/16/0145-speech-synthesis/"
           ,"\n dictionary","ASCII.jp Digital Glossary","IT Glossary Binary"]


settings = settei()
while True:
    while True:
        n = input("What are you doing?\n000 End 001 Glossary 002 Glossary 100 How to use 101 References 102 Settings 500 Attention\n>>>")
        try:
            n = int(n)
            break
        except:
            print("Please enter an integer")
            pass
    
    if n == 0:
        break
    
    elif n == 1:
        while True:
            s = input("Which word to look up?\n>>>")
            try:
                x = l[s]
                print(x)
                if settings["read"] == "Y":
                    read(x)
                if s == "Naohiro Takahashi":
                    print("There is also a chokudai blog written by Naodai.")
                    while True:
                        y = input("Do you want to open?(Y/N)\n>>>")
                        if y == "Y" or y == "N":
                            break
                    if y == "Y":
                        open("http://chokudai.hatenablog.com")
                        break
                    else:
                        print("Please answer with Y or N.(Y if yes,If No, N)")
                
                elif s == "Atcoder":
                    while True:
                        y = input("Do you want to open the Atcoder site?(Y/N)\n>>>")
                        if y == "Y" or y == "N":
                            break
                        else:
                            print("Please answer with Y or N.(Y if yes,If No, N)")
                    if y == "Y":
                        open("https://atcoder.jp/home")
                        break
                    
                elif s in paiza:
                    while True:
                        y = input("Do you want to open paiza's site?(Y/N)\n>>>")
                        if y == "Y" or y == "N":
                            break
                        else:
                            print("Please answer with Y or N.(Y if yes,If No, N)")
                    if y == "Y":
                        open("https://paiza.jp")
                        break
                
                elif s == "C++":
                    while True:
                        y = input("This site was taken from wikipedia.\n Do you want to open Wikipedia?(Y/N)\n>>>")
                        if y == "Y" or y == "N":
                            break
                    if y == "Y":
                        open("https://ja.wikipedia.org/wiki/C%2B%2B")
                        break
                    
                elif s in atcoder:
                    while True:
                        y = input("This site is taken from the Atcoder glossary.\Do you want to open nAtcoder?(Y/N)\n>>>")
                        if y == "Y" or y == "N":
                            break
                    if y == "Y":
                        open("https://atcoder.jp/contests/abc074/glossary?lang=ja")
                        break
                
                elif s == "Standard input":
                    while True:
                        y = input("There is a Python standard input summary. Do you want to open?(Y/N)\n>>>")
                        if y == "Y" or y == "N":
                            break
                    if y == "Y":
                        open("https://qiita.com/zenrshon/items/c4f3849552348b3dbe67")
                        break
                
                if y == "N" or y == "Y":
                    break
                
                    
            except:
                print(s+"Is not included in the terminology.")
                if ask("Do you want to search Yahoo?") == "Y":
                    open("https://search.yahoo.co.jp/search?p="+s+"&fr=top_ga1_sa&ei=UTF-8&ts=20826&aq=-1&oq=&at=&ai=5989b88a-191c-4cca-857f-f555e6ba52cb")
                pass
    
    elif n == 2:
        print("\n~~Terminology list~~")
        for i in l:
            print(i)
        
    elif n == 100:
        print('''                       <How to use>
First, "What do you do??Please enter the number of the operation you want to do.
A list of terms and references is displayed.''')
        print("By the way, the input responded even with double-byte numbers.")
        print("By the way, you can enter the input(Example)000>>>0 002>>>2")
    
    elif n == 101:
        print("\n~~List of references~~")
        print("\n".join(sannkou))
        
    elif n == 102:
        settings = settei()
        
    elif n == 500:
        print("Note")
        print("This word(catch copy)Is not only the one that the author thought, but also the one that was posted on other sites.(It is included in the references.)")
        print("Also, it may not contain sentences that are common to other terms.")

3. Program description

1. import statement

First,

from webbrowser import open
from sys import exit
try:
    import pyttsx3
except:
    print("At the terminal, command prompt\npip install pyttsx3\Write n and install pyttsx3.")
    print("This program cannot be run without installation.")
    exit()

This is importing the library to open the WEB page and judge whether the reading function can be done.

2. Function

def ask(S):

    while True:
        n = input(str(S)+"(Y/N)\n>>>")
        if n == "Y" or n == "N":
            break
    return n

def settei():

    a = {}
    n = "a"
    print("Start the initial setup.")
    n = ask("Do you want to read aloud?")
    a["read"] = n
    if n == "Y":
        print("Please be careful about the volume")
    return a


def read(ph):

    engine = pyttsx3.init()
    voices = engine.getProperty('voices')
    engine.setProperty("voice", voices[18].id)
    engine.say(ph)
    engine.runAndWait()


These are a function that keeps as S (character string) until you answer "Y" or "N", a default function, and a read-aloud function, respectively.

3. Dictionary

atcoder = ["AC","WJ","TLE","Contestant","Competitive programming","WA","MLE","OLE","IE","RE"]#Terminology that can be jumped to the Atcoder glossary
paiza = ["paiza","paiza learning","EN:TRY","Paiza new graduate"]#Terminology that can be jumped to paiza glossary


l = {"Atcoder":'''Solved! I want to deliver to the world.

AtCoder is the world's premier competitive programming site.
Compete in real-time online contests,
3,You can challenge over 000 past questions at any time.
'''
,"paiza":'''

With skill check
Programming ability diagnosis
Visualize skill levels in 6 levels by checking programming skills with a cumulative total of 2 million exams.
'''
,"paiza learning":'''

paiza learning is an online programming introductory learning content using videos.
In the programming course, Java, Python, Ruby, PHP, C language, SQL, JavaScript, HTML+Published courses such as CSS. You can learn efficiently with a video of about 3 minutes each and exercises corresponding to each chapter.
'''
,"EN:TRY":'''

EN:TRY (entry) is a completely new form of coding career change service that allows you to write a code and proceed to an interview / casual interview without document screening.
Development practice is posted mainly on job offers that can be challenged even if you are inexperienced! For example, "I want to become an IT engineer from where I am inexperienced!"
We will fulfill your desire to gain more full-scale development experience!
'''
,"Paiza new graduate":'''

paiza writes a code and proceeds to an interview / casual interview without document screening.
It is a completely new form of coding job hunting service. Interviews are possible if you write the code in a field or language that you do not have practical experience with!

'''
,"Qiita":'''

"Qiita" is an open information sharing community specializing in programming that allows you to share knowledge and improve your skills.
Since its release on September 16, 2011, the number of access users has steadily increased, and it has become a service accessed by more than 2.5 million users. About 200 new information is posted every day, and more than 170,000 posts are collected.
(Both the number of access users and the number of posts are as of the end of September 2016.)
'''
,"note.nkmk.me":'''

Various programming information(Algorithms, how to use functions, etc.)There is a convenient site.
For example, the site below is a summary of functions that can solve mathematics up to high school.
https://note.nkmk.me/python-mathematics/
'''
,"Naohiro Takahashi":'''

Born in Tokyo. He graduated from Komaba Junior and Senior High School attached to Tsukuba University, Faculty of Environment and Information Studies, Keio University, and completed the master's program at Keio University Graduate School of Media and Governance.[3]。
While attending university, he won the 3rd place in the world in the algorithm category of the Imagine Cup 2008, a programming contest sponsored by Microsoft.[2][4][5][6][7]。
Currently, besides a programmer, he runs a company called AtCoder that organizes programming contests.[8]。
In the past, ITmedia had a serialization called "The Strongest and Fastest Algorithm Training Course"[2]。
'''
,"Atcoder color":'''

See this site for instructions.
http://chokudai.hatenablog.com/entry/2019/02/11/155904
'''
,"Python":'''

A scripting language developed by Guido van Rossum.
It has the feature that it is easy to modularize the program (it can be written in other languages) and incorporate it into other programs.
In addition, the rules regarding how to write the source code are strict, and it is considered that the source code will be easy to read by following the rules. Although it was a popular language in Europe and the United States, it did not have a complete system for handling Japanese.
Currently, it supports Unicode character string operations, and Japanese character strings can also be operated. Often used to develop web applications.
'''
,"C++":'''

C++(Sea Plus Plus) is one of the general-purpose programming languages. It is commonly called "Shipura" or "Shipura" among Japanese speakers.
While inheriting the functions and features of the C language from which it was derived, multiple programming paradigms such as procedural programming, data abstraction, object-oriented programming, and generic programming are combined to improve expressiveness and efficiency.[2]。
It can be used as a low-level language for lower layers that directly handles hardware such as C, or as a high-level language for upper layers for developing complex application software.
It is an important principle of language design that it does not require a low-level language other than assembly language and that it does not require time and space costs for unused functions.[3][4]。
C++AT in 1983&Published by Bjarne Stroustrup, a computer scientist at Bell Labs. The development environment has also been introduced on various platforms.
Since 1998, ISO and IEC have jointly standardized language specifications and template libraries, and then the standards have been revised in 2003, 2011, 2014, and 2017.
The latest standard as of 2019 is `` ISO/IEC 14882:2017 "commonly known as" C++17 ".
'''
,"Standard input":'''

A program running on UNIX can receive data from the keyboard by issuing a read request to standard input.
The file pointer is assigned to stdin and the file descriptor is assigned 0.
Instead of receiving data from the keyboard, you can receive data from a file as standard input.
Such an operation is called a redirect.
A program running on UNIX is implicitly assigned to standard input, standard output, and standard error output.
'''
,"AC":'''

That's the correct answer. It passed all the tests prepared by the operation and was judged to be the correct program.
'''
,"WJ":'''

The submitted program is waiting for a judge.
'''
,"Contestant":'''
Contest participants.
'''
,"Competitive programming":'''

It is a competition to see how accurate and quick a program can be created for a given problem.
'''
,"TLE":'''

The program did not finish within the execution time specified in the problem.(Wrong answer)
'''
,"WA":'''

It's a wrong answer. The output of the submitted program is incorrect.
'''
,"MLE":'''

The memory limit specified in the problem has been exceeded.
'''
,"OLE":'''

Output size exceeds the limit specified in the problem.
'''
,"IE":'''

An internal error, that is, a judge system error.
'''
,"RE":'''

An error occurred while running the program. There is an error that could not be detected at compile time.Caused by stack overflow, division by zero, etc..
'''
}

This contains the words and their meanings. The meaning is quoted from various sites. Among them, [paiza]

4. Processing of while statement

while True:
    while True:
        n = input("What are you doing?\n000 End 001 Glossary 002 Glossary 100 How to use 101 References 102 Settings 500 Attention\n>>>")
        try:
            n = int(n)
            break
        except:
            print("Please enter an integer")
            pass

Receive input of what to do. It also determines if the input is an integer. When n (input) is not an integer

n = int(n)

Since an error occurs in, except processing (output "Please enter an integer" and do nothing) will be performed.

5. Conditional branch

   if n == 0:
        break

When

    elif n == 100:
        print('''                       <How to use>
First, "What do you do??Please enter the number of the operation you want to do.
A list of terms and references is displayed.''')
        print("By the way, the input responded even with double-byte numbers.")
        print("By the way, you can enter the input(Example)000>>>0 002>>>2")

    elif n == 101:
        print("\n~~List of references~~")
        print("\n".join(sannkou))

    elif n == 102:
        settings = settei()

    elif n == 500:
        print("Note")
        print("This word(catch copy)Is not only the one that the author thought, but also the one that was posted on other sites.(It is included in the references.)")
        print("Also, it may not contain sentences that are common to other terms.")

This allows you to see references, cautions, and usage. Also, when n = 0, it can be terminated (utilization of break statement). Also, the usage is aligned in the middle (executed and adjusted).

4. References

Website

How to write Markdown ... How to create a table of contents with in-page links in Markdown Markdown Notation Cheat Sheet

Meaning of terms and how to write code ...

paiza https://paiza.jp/guide/career https://paiza.jp/guide/student https://paiza.jp/guide/en_try https://paiza.jp/guide/works note.nkmk.me https://note.nkmk.me/python-mathematics/ https://note.nkmk.me/python-dict-keys-values-items/ Wikipedia https://ja.wikipedia.org/wiki/ Competitive programming https://ja.wikipedia.org/wiki/ Naohiro Takahashi https://ja.wikipedia.org/wiki/C%2B%2B

chokudai's blog

http://chokudai.hatenablog.com/entry/2019/02/11/155904 http://chokudai.hatenablog.com https://miyukimedaka.com/2020/06/16/0145-speech-synthesis/ Qiita https://increments.co.jp/products/qiita/ https://help.qiita.com/ja/articles/qiita-edit https://qiita.com/tsunasandot/items/d0972fb3bfc0d4156b34#1-Introduction

Other

https://tonari-it.com/python-webbrowser-open/ https://atcoder.jp/contests/abc074/glossary?lang=ja https://code-graffiti.com/anaconda-navigator-does-not-start/

dictionary

ASCII.jp Digital Glossary IT Glossary Binary

Book

What are you doing?
000 End 001 Glossary 002 Glossary 100 How to use 101 References 102 Settings 500 Attention
>>>

I got an idea from a book about the format (sorry, I forgot which book).

Recommended Posts

I made a competitive programming glossary with Python
I made a fortune with Python.
I made a daemon with Python
I made a character counter with Python
Competitive programming with python
I made a Hex map with Python
I made a roguelike game with Python
I made a simple blackjack with Python
I made a configuration file with Python
I made a neuron simulator with Python
I made a weather forecast bot-like with Python.
I made a GUI application with Python + PyQt5
I made a Twitter fujoshi blocker with Python ①
[Python] I made a Youtube Downloader with Tkinter.
I made a bin picking game with Python
I made a Mattermost bot with Python (+ Flask)
I made blackjack with python!
I made a python text
I made blackjack with Python.
I made wordcloud with Python.
I made a Twitter BOT with GAE (python) (with a reference)
I made a Christmas tree lighting game with Python
I made a net news notification app with Python
I made a Python3 environment on Ubuntu with direnv.
I made a LINE BOT with Python and Heroku
I made a Line-bot using Python!
I made a simple typing game with tkinter in Python
I made a package to filter time series with python
I made a simple book application with python + Flask ~ Introduction ~
I made a puzzle game (like) with Tkinter in Python
Competitive programming with python Local environment settings
I made a payroll program in Python!
I drew a heatmap with seaborn [Python]
I tried a functional language with Python
What I did with a Python array
I made a life game with Numpy
I made a stamp generator with GAN
After studying Python3, I made a Slackbot
I made a WEB application with Django
I made a library to easily read config files with Python
I made a package that can compare morphological analyzers with Python
I made a Nyanko tweet form with Python, Flask and Heroku
I made a lot of files for RDP connection with Python
[Python] I made an image viewer with a simple sorting function.
I made a shuffle that can be reset (reverted) with Python
I made a poker game server chat-holdem using websocket with python
I made a segment tree with python, so I will introduce it
I made a stamp substitute bot with line
I made a python dictionary file for Neocomplete
I tried competitive programming
〇✕ I made a game
I made a tool to automatically browse multiple sites with Selenium (Python)
3. 3. AI programming with Python
I want to make a game with Python
Procedure for creating a LineBot made with Python
Competitive programming diary python 20201213
Python programming with Atom
I made a simple Bitcoin wallet with pycoin
Competitive programming diary python 20201220
I made a LINE Bot with Serverless Framework!
I tried to discriminate a 6-digit number with a number discrimination application made with python