モナーのパイソンでゴーゴー

湘南あたりの海辺より

(*´ω`) continue について

実行結果 ソース # 不必要なデーターはスルーする ages = [28, 50,'ひみつ', 8, 20, 78, 25, 22, 10,'無回答', 33] samples = list() for data in ages: if not isinstance(data, int): continue if data < 20 or data >= 30: continue samples.append(data)…

(*´ω`) 東京感染者最多60名以上

実行結果 ソース # 該当年齢を出す ages = [28, 50, 8, 20, 78, 25, 22, 10, 27, 33] num = 5 samples = list() for data in ages: if 20 <= data < 30: samples.append(data) if len(samples) == num: break print(samples) print(' ∧ ∧ 感染爆発の重大局面…

(*´ω`)夕べはうまくいかなかったのになあ今日はあっという間にできた 

実行結果 ソース # 平均点を求める count = 0 student_num = int(input('学生の数を入力してください>>')) score_list = list() while count < student_num: count += 1 score = int(input('{}人目の試験の得点を入力>>'.format(count))) score_list.append(…

(*´ω`)ひつじが・・・ムニャムニャ

実行結果 ソース is_awake = True count = 0 while is_awake == True: count += 1 print('ひつじが{}匹'.format(count)) key = input('もう眠りそうですか?(y/n)>>') if key == 'y': is_awake = False print('z...z...z....') print(' ∧ ∧ good job!')print…

(*´ω`)羊が3匹で寝てしまいました

実行結果 ソース count = 0 while count < 3: count += 1 print('ひつじが{}匹'.format(count)) print('z...z...z....') print(' ∧ ∧ good job!')print('( ゚Д゚)')print('海と猫が好き')

(*´ω`)マッタリしようよ

実行結果 ソース #トマトジュースも好きですよ name = input('あなたの名前を入力してください>>') print('{}さん、こんにちは'.format(name)) if name == 'モナー': print('モナーさんに会えて嬉しいです') food = input('{}さんの好きな食べ物を教えてくだ…

(*´ω`)60点以上100点未満は合格

実行結果 ソース score = int(input('試験の点数を入力>>')) if score >= 60 and score <= 100: print('合格') else: print('不合格') print(' ∧ ∧ good job!')print('( ゚Д゚)')print('海と猫が好き')

(*´ω`) スコアに科目がなければ追加し点数もいれる

実行結果 ソース # scoresに登録がない場合は科目と点数を登録する scores = {'network': 60,'database': 80, 'security': 50} key = input('追加する科目を入力してください>>') if key in scores: print('すでに登録済みです') else: data = int(input('得…

(*´ω`) Python は便利だなあ。

実行結果 ソース(ジュースを含む文字列はみな好き) #トマトジュースも好きですよ name = input('あなたの名前を入力してください>>') print('{}さん、こんにちは'.format(name)) food = input('{}さんの好きな食べ物を教えてください>>'.format(name)) if …

(*´ω`)60点以上は ’合格’ 。それ以外は ‘不合格’と表示する

実行結果 ソース score = int(input('試験の点数を入力してください>>')) if score >= 60: print('合格') print('よくがんばりましたね') else: print('不合格') print('追試を受けてください') print(' ∧ ∧ you are genius')print('( ゚Д゚)')print('海と猫が…

(*´ω`) 

実行結果 ソース #私も好きですよ name = input('あなたの名前を入力してください>>') print('{}さん、こんにちは'.format(name)) food = input('{}さんの好きな食べ物を教えてください>>'.format(name)) if food == 'カレー': print('素敵です。カレーは最…

(*´ω`)

実行結果 ソース #私も好きですよ name = input('あなたの名前を入力してください>>') print('{}さん、こんにちは'.format(name)) food = input('{}さんの好きな食べ物を教えてください>>'.format(name)) print('私も{}が好きですよ'.format(food)) print(' …

(*´Д`) 共通部分を見つけるよ。

# 趣味の共通点 member_hobbies = { '松田' : {'apple','peach','lemon'}, '浅木' : {'orange','banana','peach'} } common_hobbies = member_hobbies['松田'] & member_hobbies['浅木'] print(common_hobbies) print(' ∧ ∧ New corona, pandemic')print('( …

# 点数管理 scores = [70,80,55] print(scores)print(scores[0]) print('要素数は{}'.format(len(scores)))print('合計は{}'.format(sum(scores))) print(' ∧ ∧ good job!')print('( ゚Д゚)')print('海と猫が好き')

SUM関数

# 点数管理 scores = [88,90,95] total = sum(scores) avg = total / 3 print('合計点は{},平均点は{}'.format(total,avg)) print(' ∧ ∧ good job!')print('( ゚Д゚)')print('海と猫が好き')

# 点数管理 network = 88database = 95security = 90 total = network + database + security avg = total / 3 print('合計点は{}'.format(total))print('平均点は{}'.format(avg)) print(' ∧ ∧ good job!')print('( ゚Д゚)')print('海と猫が好き')

# 割り勘計算 price = int(input('料金を入力>>'))number = int(input('人数を入力>>'))payment = int(price / number)print('お支払いは{}円です'.format(payment)) print(' ∧ ∧ good job!')print('( ゚Д゚)')print('海と猫が好き')

円の直径と円周

"""自己紹介プログラム作成者:小林モナー作成日:20200229 """# 円の直径と円周の求め方 print('半径が3cmの円の直径は')dia = 3 * 2print(dia) print('円の円周の長さは')print(dia * 3.14) print(' ∧ ∧ It is hard to come every day')print('( ゚Д゚)')…

python も始めたよ

"""自己紹介プログラム作成者:小林モナー作成日:20200229 """# コメント print(' ∧ ∧ It is hard to come every day') print('( ゚Д゚)')print('猫が好き')

A割るBの商と余り

#include <stdio.h>int main(void){int na,nb; puts("二つの整数を入力してください。");printf("整数A:"); scanf("%d", &na);printf("整数B:"); scanf("%d", &na); printf("AをBで割ると%dあまり%dです。\n", na/nb,na%nb); printf(" \n");printf(" ∧ ∧ It's hard to</stdio.h>…

Thank you again!

#include <stdio.h>int main(void){ printf(" \n");printf(" ∧ ∧ Thank you again! \n");printf(" ( ゚Д゚) \n");return 0;}</stdio.h>

警報回数をして鳴らす 関数

#include <stdio.h> /* kansu1 */ void put_chars(int ch, int n) { while (n-- > 0) putchar(ch);} /* kansu2 */ void put_chars_ln(int ch, int n){ put_chars(ch, n); putchar('\n');} /* kansu3 */ void alert(int n) { put_chars('\a', n); } int main(void){ in</stdio.h>…

関数

#include <stdio.h> /* kansu */ int buy(int x, int y){ int z; printf("%d万円と%d万円の車を買いました。\n", x, y); z = x + y; return z;} int main(void) { int num1, num2, sum; printf("いくらの車を買いますか? \n"); scanf("%d", &num1); printf("いくらの</stdio.h>…

コイン投げゲーム

#include <stdio.h>#include <string.h>#include <time.h>#include <stdlib.h> int main(void){ int you;int coin;char muki[][10] = {" ","表","裏"}; srand(time(NULL)); printf("表は1、裏は2、終了は他の値を入力してください。 \n"); while(1){ coin = rand() % 2 + 1; printf("コインを投げ</stdlib.h></time.h></string.h></stdio.h>…

文字を逆さに表示する

#include <stdio.h>#include <string.h> int main(void){ int i, n;char a[] = "DOG";char b[10]; n = strlen(a); for(i = n-1; i >= 0; i--) b[n-1-i] = a[i]; b[n] = '\0'; printf("%s \n逆さから読むと\n%s\n", a, b); printf(" good job! \n \a");printf(" ∧ ∧___ \n");pri</string.h></stdio.h>…

ファイルに書き込んでディスプレイに表示する

実に見事なことであるな。実力がついてきたね。 #include <stdio.h>#define NUM 30 int main(void){ FILE *fp; char a[] = " ∧ ∧ \n ( ゚Д゚) nice play!", s[30]; /* write */ fp = fopen("abc.txt", "w"); if (fp == NULL) return 1; fprintf(fp, "%s", a); fclose(fp</stdio.h>…

恭子のおっぱい プログラム

恭子の + おっぱい =恭子のおっぱい なのだ。 #include <stdio.h> int main(void){ int i = 0, j = 0; char a[20] = "Kyokono", b[] = "oppai"; printf("%s + %s = ", a, b); while(a[i] != '\0') i++; while(b[j] != '\0'){ a[i] = b[j]; i++; j++; } a[i] = '\0';</stdio.h>…

*paとは paに格納されているものを指す

#include <stdio.h> int main(void) {int a,b;int *pA; a = 5;b = 10; pA = &a; printf("a %d \n",a);printf("a pA %p \n", pA);printf("a *pA %d \n", *pA);printf("\n"); pA = &b; printf("b %d \n", b);printf("b pA %p \n", pA);printf("b *pA %d \n ", *pA); /* </stdio.h>…

ポインタ

今日は風邪でもひいたか体の調子がいまいちだったなあ。 #include <stdio.h> int main(void){ int a; int *pA; a = 5; pA = &a; printf("a %d \n" , a); printf("a adress %p \n", &a); printf("a pA %p \n", pA); printf(" \n"); printf("今だ!2ゲットォーーー!!\n");pr</stdio.h>…

a のポインタはaのメモリ上のアドレスという意味

#include <stdio.h> int main(void) { int a; a = 5; printf("a %d \n" , a); printf("a point %p \n", &a); printf(" ∧∧ / ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ \n");printf(" ( ゚Д゚) < &a とはa のアドレスという意味 \n");printf(" ⊂ つ | \n");printf("~( つノ \____</stdio.h>…