From 45c474af65104605e9faee472cadeb862a3040f3 Mon Sep 17 00:00:00 2001 From: "DESKTOP-N04EG04\\mghmu" Date: Fri, 20 Nov 2020 16:57:16 +0900 Subject: [PATCH 1/3] =?UTF-8?q?2017162021=20=EC=9D=98=EB=A3=8CIT=ED=95=99?= =?UTF-8?q?=EA=B3=BC=20=EB=AC=B8=EC=A7=80=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d27672e..7e7c6ad 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,59 @@ -# python-lotto-app +from flask import Flask, render_template, jsonify +import random -이건 로또 앱이에요! 로또번호 생성기에요 +app = Flask(__name__) + + +lotto_numbers = list(range(1,46)) + +@app.route("/") +def hello(): + + return render_template("index.html", variable=lotto) + +@app.route("/lotto",methods=['GET']) +def lotto(): + lotto = select_numbers(6) + return jsonify(lotto) + +def select_numbers(select_amount:int): + lotto = [1,2,3,4,5,6] + + ### 이곳을 같이 채워봐요 + + + ## example 1 + lotto = [] + for i in range(select_amount): + + while True: + select_num = random.randint(1, 45) + + is_duplicated = False + for num in lotto: + if select_num == num: + is_duplicated = True + break + + if is_duplicated: + continue + lotto.append(select_num) + break + + ## example 2 + ''' + candidate_numbers = lotto_numbers[:] + lotto = [] + for i in range(select_amount): + select_num = candidate_numbers.pop(random.randrange(len(candidate_numbers))) + lotto.append(select_num) + ''' + + ## example 3 + ''' + lotto = random.sample(lotto_numbers, select_amount) + ''' + return lotto + +if __name__ == "__main__": + app.run(host='0.0.0.0', port=8080) \ No newline at end of file From f06683ffe66dad9bc3a8962fa9f1a798fa28fc3c Mon Sep 17 00:00:00 2001 From: MoonJihee0203 <72717366+MoonJihee0203@users.noreply.github.com> Date: Fri, 20 Nov 2020 17:46:39 +0900 Subject: [PATCH 2/3] Delete README.md --- README.md | 59 ------------------------------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 7e7c6ad..0000000 --- a/README.md +++ /dev/null @@ -1,59 +0,0 @@ -from flask import Flask, render_template, jsonify -import random - -app = Flask(__name__) - - -lotto_numbers = list(range(1,46)) - -@app.route("/") -def hello(): - - return render_template("index.html", variable=lotto) - -@app.route("/lotto",methods=['GET']) -def lotto(): - lotto = select_numbers(6) - return jsonify(lotto) - -def select_numbers(select_amount:int): - lotto = [1,2,3,4,5,6] - - ### 이곳을 같이 채워봐요 - - - ## example 1 - lotto = [] - for i in range(select_amount): - - while True: - select_num = random.randint(1, 45) - - is_duplicated = False - for num in lotto: - if select_num == num: - is_duplicated = True - break - - if is_duplicated: - continue - lotto.append(select_num) - break - - ## example 2 - ''' - candidate_numbers = lotto_numbers[:] - lotto = [] - for i in range(select_amount): - select_num = candidate_numbers.pop(random.randrange(len(candidate_numbers))) - lotto.append(select_num) - ''' - - ## example 3 - ''' - lotto = random.sample(lotto_numbers, select_amount) - ''' - return lotto - -if __name__ == "__main__": - app.run(host='0.0.0.0', port=8080) \ No newline at end of file From fc4928b404ea92ba5c641c2b934623482abfbad8 Mon Sep 17 00:00:00 2001 From: "DESKTOP-N04EG04\\mghmu" Date: Fri, 20 Nov 2020 18:05:42 +0900 Subject: [PATCH 3/3] app.by --- app.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 92832af..6b94f70 100644 --- a/app.py +++ b/app.py @@ -20,7 +20,37 @@ def select_numbers(select_amount:int): ### 이곳을 같이 채워봐요 lotto = [1,2,3,4,5,6] - + ## example 1 + lotto = [] + for i in range(select_amount): + + while True: + select_num = random.randint(1, 45) + + is_duplicated = False + for num in lotto: + if select_num == num: + is_duplicated = True + break + + if is_duplicated: + continue + lotto.append(select_num) + break + + ## example 2 + ''' + candidate_numbers = lotto_numbers[:] + lotto = [] + for i in range(select_amount): + select_num = candidate_numbers.pop(random.randrange(len(candidate_numbers))) + lotto.append(select_num) + ''' + + ## example 3 + ''' + lotto = random.sample(lotto_numbers, select_amount) + ''' return lotto