0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

自作アプリ No.1, No.2 (2個)

Posted at

No.1 簡単に作れるおみくじアプリ

omikuji.py
# coding:utf-8

# おみくじアプリ

import random                                     # ライブラリの取り込み

x = random.randint(1,101)                         # 1 ~ 100 までの数値がランダムでxに入る

print("選ばれた数字が"+ str(x) +"なので")           # strでxを囲むことによって数値を文字列に変換している。

if  91 < x < 100:                                 # x が 【 92 ~ 99 】
    print("大凶")

elif 81 < x <= 91:                                # x が 【 82 ~ 91 】
    print("")

elif 41 < x <= 81:                                # x が 【 42 ~ 81 】
    print("")

elif 1 < x <= 41:                                 # x が 【 2 ~ 41  】   
    print("中吉")

elif x == 1 or x == 100:                          # x が 【 1 or 100 】  
    print("大吉")

No.2 簡易的なロト7の数字を選んでくれるアプリ

loto7.py
# coding:utf-8

# ランダムな数字を7つ選んで小さい順から表示

import random

number = list(range(1,38))               # 1から37までが入っている箱を生成

number7 = random.sample(number, 7)      # 数字を7つ取り出す

number7.sort()                           # 数字を小さい順に整理

print(number7)                          # 結果表示


list(range(1,38))やrandom.sample(number, 7)の

38, 7の数字を変更することでロト6などにも対応可能。

0
0
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?