Saturday 10 March 2012

python_02

昨日のと同様に.
入試についてはここでのコメントはそぐわないと思ふ.

python 書き散らすだけ.
あ,ただ作ってみた:
「ラテン語第一変化名詞の gen.sing.を入力してそれぞれの格・数で出力するどんくさいぷろぐらむ」
 まあ基本は if と while の使い方をやりたかっただけ.実用性はあまりない.
python は tab が崩れると 死ぬのでお気をつけて.転載云々はやめてください云々.

repeat = 1;
while(repeat):
    nom_sing = raw_input("Input Nominative Singular.\n\t");
    if(nom_sing[-1] == "a"):
        repeat = 0;
        print "I SHALL ASSUME IT DECLINES IN 1ST DECLENTION.";
        stem = nom_sing[0:len(nom_sing)-1];
        gen_sing = stem + "ae";
        dat_sing = stem + "ae";
        acc_sing = stem + "am";
        abl_sing = stem + "a";
        nom_pl   = stem + "ae";
        gen_pl   = stem + "ae";
        dat_pl   = stem + "arum";
        acc_pl   = stem + "as";
        abl_pl   = stem + "is";
        print stem;print nom_sing;
        print "case : \t singular \t  plural";
        print "nom  : \t", nom_sing, "\t\t ", nom_pl;
        print "gen  : \t", gen_sing, "\t ", gen_pl;
        print "dat  : \t", dat_sing, "\t ", dat_pl;
        print "acc  : \t", acc_sing, "\t ", acc_pl;
        print "dat  : \t", dat_sing, "\t ", dat_pl;
    else:
        print "THIS DOES NOT SEEM TO BE A 1ST-DECLENTION NOUN.PLEASE INPUT AGAIN.";

  出力はなんとなく位置行ごとに print を使ってみた.意味はない.
あと nominative のところだけ \t 2ついれないと体裁が狂うのが謎.

exporting to files- 断片.
>>> test = file("export_test_2.txt","a");
>>> test.write("this ");
>>> a = "is a pen. \t and tabs \n next line.";
>>> test.writelines(a);
>>> test.close();
>>> quit()

 makes a text file :
this is a pen.      and tabs
 next line.
このへん正書法(?)とは違う気もするので勉強しないと.
四行目は test.write(a); とかではうまくいかなかった.

No comments:

Post a Comment