[PYTHON] Qiita (1) How to write a code name

2015-09-09 qiita> How to write code name (check with csharp)> csharp: Write testScript.cs instead of testScript.cs https://qiita.com/7of9/items/c3d413a41fd959bac69c#comment-345b621cad4d6db874fa

I will try various things.

For comparison, the citation source has not changed.

c language

Program change (3) Endian confirmation program, 64bit added (C language). https://qiita.com/kaizen_nagoya/items/f55112ca74936fd30fcb

endian3.c


#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>

int main (int argc, char **argv)
{
    union
    {
	uint64_t b8	; // 8byte
        uint32_t b4 [2] ; // 4byte x 2 
        uint16_t b2 [4] ; // 2byte × 4 
        uint8_t b1 [8] ;  // 1byte × 8 
    } bytes ;

    bytes.b8 = 0x123456789ABCDEF0 ;
    printf ("bytes.b8: %16" PRIX64 "\n", bytes.b8);
    printf ("bytes.b4: %08" PRIX32 ", %08" PRIX32 " \n", bytes.b4[0], bytes.b4[1]) ;
    printf ("bytes.b2: %04" PRIX16 ", %04" PRIX16 ", %04" PRIX16 ", %04" PRIX16 " \n", bytes.b2[0], bytes.b2[1], bytes.b2[2], bytes.b2[3]) ;
    printf ("bytes.b1: %02" PRIX8 ", %02" PRIX8 ", %02" PRIX8 ", %02" PRIX8 ", %02" PRIX8 ", %02" PRIX8 ", %02" PRIX8 ", %02" PRIX8 " \n", bytes.b1[0], bytes.b1[1], bytes.b1[2], bytes.b1[3], bytes.b1[4], bytes.b1[5], bytes.b1[6], bytes.b1[7]) ;
    return 0 ;
}

python

Program change (1) I tried running "I want to win with Hyakunin Isshu with Python" with docker https://qiita.com/kaizen_nagoya/items/f8297f544fcbf4787f2a

hyaku_main.py


#! /usr/bin/env python
# -*- coding: utf-8 -*-
import random
import pandas as pd
 
 
def load():
    return pd.read_csv("Hyakunin Isshu.csv")
 
 
def loop(simo, kami):
    while True:
        k = 99  # 1~It's a number of 99. You can decide the range up to.
        n = random.randint(0, k)  #Decide the number to sing
        i = 0
 
        while True:
            j = 1
            simo_n = simo[n]
            kami_n = kami[n]
 
            print("【", j, "Question] The phrase below is", simo_n, "\n")
 
            s = input()
            if s == "end":  #end is the end
                break
 
            if kami_n == s:  #If the answer is correct, the next loop
                print("Is the correct answer!\n")
                break
            else:
                print("Incorrect ...\n")
                print("rear", 1, "Give times chance")
                if len(kami_n) != 0:
                    print("The first letter of the above phrase is", kami_n[0])
                    print(len(kami_n), "It is a character.")
                else:
                    print("It is one character.\n")
 
                s = input()
                if s == "end":
                    break
                if kami_n == s:
                    print("Is the correct answer")
                    print(simo_n, "The correct answer is", kami_n, "was.\n")
                else:
                    print("Incorrect\n")
                    print(simo_n, "The correct answer is", kami_n, "was.\n")
 
                break
 
        j += 1
        if s == "end":
            break
 
 
def main():
    df = load()  #Data reading
 
    kami = df["Up"]
    simo = df["under"]
 
    #Rule explanation
    print("[Special training for chizuchizu]\n")
    print("【rule】")
    print("I will write the lower phrase (fixed character), so please answer the fixed character of the upper phrase.")
    print("If you want to quit, say "end"!\n")
 
    loop(simo, kami)
 
 
if __name__ == "__main__":
    main()  #Run

dockerfile

dockerfile does not display the file name if it is only dockerfile. dockerfile: Make it a dockerfile.

docker (11) docker file I made it https://qiita.com/kaizen_nagoya/items/5139c4e1eb8d86a8ed15

dockerfile


From ubunt
MAINTAINER @kaizen_nagoya
WORKDIR /root
ENV HOME /root
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    wget \
    git \
    libssl-dev \
    libbz2-dev \
    libsqlite3-dev \
    libreadline-dev \
    zlib1g-dev \
    libasound2-dev \
    libxss1 \
    libxtst6 \
    gdebi
RUN wget -O vscode-amd64.deb https://go.microsoft.com/fwlink/?LinkID=760868
RUN yes | gdebi vscode-amd64.deb
RUN rm vscode-amd64.deb
RUN alias python='python3'

Recommended Posts

Qiita (1) How to write a code name
How to write a Python class
How to code a drone using image recognition
How to write a ShellScript Bash for statement
How to write a named tuple document in 2020
[Go] How to write or call a function
How to write a ShellScript bash case statement
XPath Basics (2) -How to write XPath
How to call a function
How to write a list / dictionary type of Python3
How to hack a terminal
How to make a Python package using VS Code
[Python] How to write a docstring that conforms to PEP8
Write code to Unit Test a Python web app
How to create a kubernetes pod from python code
After all, how much should I write a Qiita article?
How to write a test for processing that uses BigQuery
I'll never forget how to write a shell script, don't forget! !!
How to write a metaclass that supports both python2 and python3
How doi may be useful when asking how to write code?
How to make a Japanese-English translation
How to put a symbolic link
How to write soberly in pandas
Flask reuse How to write html
How to make a slack bot
How to create a Conda package
Write standard output to a file
Code to randomly generate a score
How to make a crawler --Advanced
How to make a recursive function
How to create a virtual bridge
How to make a deadman's switch
How to create a Dockerfile (basic)
[Blender] How to make a Blender plugin
How to delete a Docker container
How to write Docker base image
How to write Django1.9 environment-independent wsgi.py
How to make a crawler --Basic
How to run TensorFlow 1.0 code in 2.0
Notes on how to write requirements.txt
How to create a config file
How to write code to access python dashDB on Bluemix or local
How to set Jupytext nicely when managing code as a team
How to write a docstring to create a named tuple document with sphinx
How to split and save a DataFrame
How to build a sphinx translation environment
How to create a git clone folder
How to set optuna (how to write search space)
How to add a package with PyCharm
[Python] How to make a class iterable
How to draw a graph using Matplotlib
python notes: Modularization: __name__ == How to use'__main__'
[Python] How to convert a 2D list to a 1D list
How can I write a good program?
Isn't it okay to write test code?
How to write Python document comments (Docstrings)
How to remove end-of-line code (CR) [^ M]
[Colab] How to copy a huge dataset
[Python] How to invert a character string
How to install a package using a repository
[Ubuntu] How to execute a shell script