You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

codingnow

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codingnow - pypi Package Compare versions

Comparing version
0.1.47
to
0.1.48
+144
codingnow/learning/coding/Chapters/chapter_03.py
import random
# Black 30 \033[30m
# Red 31 \033[31m
# Green 32 \033[32m
# Yellow 33 \033[33m
# Blue 34 \033[34m
# White 37 \033[37m
# 초기화 0 \033[0m (반드시 끝에 넣어줘야 다음 줄에 영향이 없음)
class Chapter_03:
chapter = 3
step = 1
step_min = 1
step_max = 1
title = "간단한 게임 : 숫자 맞추기"
number_lower = 1
number_upper = 100
correct = 0
guide_line_max = 50
operation = ['up', 'down','정답']
current_operation = '없음'
is_return_operation = False
answer_limit_count = 10
answer_count = 0
def __init__(self):
print("\033[32m=" * self.guide_line_max)
print("코딩 테스트 - Chapter 3: 간단한 게임 : 숫자 맞추기")
print("설명: 입력한 숫자보다 크면 'up', 작으면 'down', 같으면 '정답'이 출력됩니다.")
print(f"출력되는 값 : {self.operation}")
print(f"현재 챕터는 총 {self.step_max} 단계입니다.")
print()
print("사용법:")
print(" 1. lower = coding.get_option('lower') # 하위값")
print(" 2. upper = coding.get_option('upper') # 상위값")
print(" 3. if coding.answer(answer) == False: # 정답을 맞추거나 제한횟수를 넘으면 False 반환")
print(" 4. result =coding.get() # 현재 결과 값 반환 ('up', 'down', '정답')")
print("=" * self.guide_line_max,end='')
print("\033[0m",end='')
print("\n"*1)
print("\033[34m",end='')
print("=" * self.guide_line_max,end='')
print("\033[0m")
def start(self):
if self.step < self.step_min or self.step > self.step_max:
print(f"잘못된 단계를 입력했습니다. {self.step_min} ~ {self.step_max}.")
return
print("\033[34m",end='')
print(f"[{self.step} 단계] ",end='')
print("\033[0m")
self.problem_idx = 0
self.number_upper = (self.step) * 100
self.correct = random.randint(self.number_lower, self.number_upper)
self.answer_limit_count = 10
self.answer_count = 0
self.is_return_operation = True
print("\033[34m",end='')
print(f"[문제 설명] 주어진 숫자를 맞추세요. 숫자는 {self.number_lower} 부터 {self.number_upper} 사이입니다.")
print("=" * self.guide_line_max,end='')
print("\033[0m")
def get(self):
return self.current_operation
def get_operation(self):
return self.current_operation
def answer(self, answer):
self.answer_count += 1
print(f"\n\033[31m[결과 확인] 입력 값: {answer} 시도횟수 : {self.answer_count}\033[0m")
print(f"정답 값: {self.correct}")
# print()
if answer == self.correct:
print("\033[31m정답!!\033[0m")
print()
self.step += 1
if self.step > self.step_max:
print("축하합니다! 모든 단계를 완료했습니다.")
self.step = self.step_max
print("=" * self.guide_line_max)
print()
return False
else:
print("\033[34m",end='')
print("=" * self.guide_line_max,end='')
print("\033[0m")
# print(f"다음 단계로 이동합니다. Step: {self.step}")
self.next()
# print()
return False
elif self.answer_count >= self.answer_limit_count:
print(f"\n\033[31m답안 시도 횟수 초과!! 정답은 {self.correct} 입니다.\033[0m")
print("=" * self.guide_line_max)
print()
return False
elif answer < self.correct:
self.current_operation = 'up'
print("\033[33mup\033[0m")
print("=" * self.guide_line_max)
print()
return True
else:
self.current_operation = 'down'
print("\033[33mdown\033[0m")
print("=" * self.guide_line_max)
print()
return True
def next(self):
if self.step <= self.step_max:
self.start()
else:
print("이미 마지막 단계입니다.")
def print_options(self):
print("\033[33m",end='')
print()
print("[옵션 정보]")
print(f" * operation (현재결과) : {self.current_operation}")
print(f" * lower (하위값): {self.number_lower}")
print(f" * upper (상위값): {self.number_upper}",end='')
print("\033[0m")
def get_option(self, cmd):
if cmd == 'operation':
return self.current_operation
elif cmd == 'lower':
return self.number_lower
elif cmd == 'upper':
return self.number_upper
else:
return None
+1
-1
Metadata-Version: 2.1
Name: codingnow
Version: 0.1.47
Version: 0.1.48
Summary: A simple example Python package

@@ -5,0 +5,0 @@ Home-page: https://github.com/cflab2017/codingnow_py

@@ -66,2 +66,3 @@ LICENSE

codingnow/learning/coding/Chapters/chapter_02.py
codingnow/learning/coding/Chapters/chapter_03.py
codingnow/learning/coding/example/__init__.py

@@ -68,0 +69,0 @@ codingnow/learning/coding/example/Chapter_01/__init__.py

@@ -31,2 +31,9 @@ import random

print(f"현재 챕터는 총 {self.step_max} 단계입니다.")
print()
print("사용법:")
print(" 1. result = coding.get() # 생성된 문제값을 순서대로 반환, 반환값이 없으면 'END' 반환")
print(" 2. if coding.answer(answer) == False: # 틀리거나 모든 문제를 통과하면 False 반환")
print(" 3. coding.print_options() # 사용가능한 옵션 정보 출력")
print(" 4. value = coding.get_option(cmd) # 옵션값 반환 (cmd: operation, length)")
print("=" * self.guide_line_max,end='')

@@ -33,0 +40,0 @@ print("\033[0m",end='')

@@ -32,2 +32,9 @@ import random

print(f"현재 챕터는 총 {self.step_max} 단계입니다.")
print()
print("사용법:")
print(" 1. result = coding.get() # 생성된 문제값을 순서대로 반환, 반환값이 없으면 'END' 반환")
print(" 2. if coding.answer(answer) == False: # 틀리거나 모든 문제를 통과하면 False 반환")
print(" 3. coding.print_options() # 사용가능한 옵션 정보 출력")
print(" 4. value = coding.get_option(cmd) # 옵션값 반환 (cmd: operation, length)")
print("=" * self.guide_line_max,end='')

@@ -34,0 +41,0 @@ print("\033[0m",end='')

from codingnow.learning.coding.Chapters.chapter_01 import *
from codingnow.learning.coding.Chapters.chapter_02 import *
from codingnow.learning.coding.Chapters.chapter_03 import *

@@ -18,2 +19,5 @@ class CodingTest:

self.instance.start()
if self.chapter == 3:
self.instance = Chapter_03()
self.instance.start()
else:

@@ -20,0 +24,0 @@ print("해당 챕터는 준비중입니다.")

@@ -5,10 +5,9 @@ import os

problem = CodingTest()
problem.start(chapter=1)
coding = CodingTest()
coding.start(chapter=1)
# a = problem.get()
# b = problem.get()
# a = coding.get()
# b = coding.get()
# c = a + b
# problem.answer(c)
# coding.answer(c)

@@ -5,9 +5,9 @@ import os

problem = CodingTest()
problem.start(chapter=1)
coding = CodingTest()
coding.start(chapter=1)
a = problem.get()
b = problem.get()
# op = problem.get()
op = problem.get_option('operation')
a = coding.get()
b = coding.get()
# op = coding.get()
op = coding.get_option('operation')

@@ -27,2 +27,2 @@ if op == '+':

problem.answer(c)
coding.answer(c)

@@ -5,4 +5,4 @@ import os

coding_test = CodingTest()
coding_test.start(chapter=1)
coding = CodingTest()
coding.start(chapter=1)

@@ -16,3 +16,3 @@ while True:

while True:
value = coding_test.get()
value = coding.get()

@@ -38,4 +38,4 @@ if value == 'END':

answer = values[0] % values[1]
result = coding_test.answer(answer)
result = coding.answer(answer)
if result:

@@ -42,0 +42,0 @@ continue

@@ -5,4 +5,4 @@ import os

coding_test = CodingTest()
coding_test.start(chapter=1)
coding = CodingTest()
coding.start(chapter=1)

@@ -15,3 +15,3 @@ while True:

while True:
value = coding_test.get()
value = coding.get()

@@ -30,3 +30,3 @@ if value == 'END':

result = coding_test.answer(answer)
result = coding.answer(answer)
if result:

@@ -33,0 +33,0 @@ continue

@@ -5,12 +5,11 @@ # import os

problem = CodingTest()
problem.start(chapter=2)
coding = CodingTest()
coding.start(chapter=2)
coding.print_options()
problem.print_options()
oop = problem.get_option('operation')
oop = coding.get_option('operation')
print('oop:', oop)
length = problem.get_option('length')
length = coding.get_option('length')
print('length:', length)

@@ -5,8 +5,8 @@ # import os

problem = CodingTest()
problem.start(chapter=2)
coding = CodingTest()
coding.start(chapter=2)
#최대 값
a = problem.get()
b = problem.get()
a = coding.get()
b = coding.get()

@@ -18,8 +18,7 @@ if a > b:

problem.answer(c)
coding.answer(c)
#최소 값
a = problem.get()
b = problem.get()
a = coding.get()
b = coding.get()
if a < b:

@@ -30,8 +29,8 @@ c = a

problem.answer(c)
coding.answer(c)
#짝수개수
a = problem.get()
b = problem.get()
a = coding.get()
b = coding.get()

@@ -43,8 +42,8 @@ cnt = 0

cnt += 1
problem.answer(cnt)
coding.answer(cnt)
#짝수개수
a = problem.get()
b = problem.get()
a = coding.get()
b = coding.get()

@@ -56,15 +55,15 @@ cnt = 0

cnt += 1
problem.answer(cnt)
coding.answer(cnt)
#합계
a = problem.get()
b = problem.get()
a = coding.get()
b = coding.get()
c = a + b
problem.answer(c)
coding.answer(c)
#평균
a = problem.get()
b = problem.get()
a = coding.get()
b = coding.get()
c = a + b
c = c / 2
problem.answer(c)
coding.answer(c)

@@ -5,4 +5,4 @@ # import os

problem = CodingTest()
problem.start(chapter=2)
coding = CodingTest()
coding.start(chapter=2)

@@ -14,3 +14,3 @@ while True:

while True:
value = problem.get()
value = coding.get()
if value == 'END':

@@ -38,3 +38,3 @@ break

result = problem.answer(answer)
result = coding.answer(answer)
if result:

@@ -41,0 +41,0 @@ continue

Metadata-Version: 2.1
Name: codingnow
Version: 0.1.47
Version: 0.1.48
Summary: A simple example Python package

@@ -5,0 +5,0 @@ Home-page: https://github.com/cflab2017/codingnow_py

@@ -5,3 +5,3 @@ from setuptools import setup, find_packages

name='codingnow',
version='0.1.47',
version='0.1.48',
author='codingnow',

@@ -8,0 +8,0 @@ author_email='codingnow@naver.com',