Created
July 25, 2014 06:45
-
-
Save yunho0130/6390d44763d8035a415c to your computer and use it in GitHub Desktop.
Bit Computer Python lecture week 1 by Yunho Maeng
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
day1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" /> | |
</project> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<component name="InspectionProjectProfileManager"> | |
<settings> | |
<option name="PROJECT_PROFILE" value="Project Default" /> | |
<option name="USE_PROJECT_PROFILE" value="true" /> | |
<version value="1.0" /> | |
</settings> | |
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<component name="InspectionProjectProfileManager"> | |
<profile version="1.0" is_locked="false"> | |
<option name="myName" value="Project Default" /> | |
<option name="myLocal" value="false" /> | |
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true"> | |
<option name="ignoredIdentifiers"> | |
<value> | |
<list size="1"> | |
<item index="0" class="java.lang.String" itemvalue="dict.sort" /> | |
</list> | |
</value> | |
</option> | |
</inspection_tool> | |
</profile> | |
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.4.1 (C:\Python34\python.exe)" project-jdk-type="Python SDK" /> | |
</project> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectModuleManager"> | |
<modules> | |
<module fileurl="file://$PROJECT_DIR$/.idea/Week1.iml" filepath="$PROJECT_DIR$/.idea/Week1.iml" /> | |
<module fileurl="file://$PROJECT_DIR$/.idea/day1.iml" filepath="$PROJECT_DIR$/.idea/day1.iml" /> | |
</modules> | |
</component> | |
</project> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<component name="DependencyValidationManager"> | |
<state> | |
<option name="SKIP_IMPORT_STATEMENTS" value="false" /> | |
</state> | |
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="VcsDirectoryMappings"> | |
<mapping directory="" vcs="" /> | |
</component> | |
</project> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<module type="PYTHON_MODULE" version="4"> | |
<component name="NewModuleRootManager"> | |
<content url="file://$MODULE_DIR$" /> | |
<orderEntry type="inheritedJdk" /> | |
<orderEntry type="sourceFolder" forTests="false" /> | |
</component> | |
</module> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sum=0 | |
num1=3 | |
num2=4 | |
for i in range(3,7): | |
sum=sum+i | |
print(sum) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'BIT' | |
# global total | |
total=0 | |
def add(value) : #더하기 연산 | |
global total | |
total = total + value | |
return total | |
def sub(value) : #빼기 연산 | |
global total | |
total = total - value | |
return total | |
def multiply(value) : #곱하기 연산 | |
global total | |
total = total * value | |
return total | |
def divide(value) : #나누기 연산 | |
global total | |
total = total / value | |
return total | |
def calculator(): | |
inputFunction = input("") #기능:숫자로 입력 | |
print(inputFunction [0]) | |
# print(float(inputFunction [2:])) | |
if inputFunction[0] == "A": | |
total = add(float(inputFunction [2:])) | |
print(float(inputFunction [2:])) | |
elif inputFunction[0] == "S": | |
total = sub(float(inputFunction [2:])) | |
print(float(inputFunction [2:])) | |
elif inputFunction[0] == "M": | |
total = multiply(float(inputFunction [2:])) | |
print(float(inputFunction [2:])) | |
elif inputFunction[0] == "D": | |
total = divide(float(inputFunction [2:])) | |
print(float(inputFunction [2:])) | |
elif inputFunction[0] == "T": | |
global total | |
print(total) | |
elif inputFunction[0] == "X": | |
return 1 | |
def main(): #main 함수 정의하기 | |
print ("연산 할 기능과 숫자(기능:숫자)를 입력해 주세요(+:A, -:S, *:M, /:D, 총합:T, 종료:X)") | |
while True : | |
if calculator() == 1: | |
break | |
if __name__ =='__main__': | |
main() | |
""" | |
elif inputFuntion == "S": | |
inputNum = float(input("연산 할 수를 입력해 주세요")) | |
total = sub(inputNum) | |
elif inputFuntion == "M": | |
inputNum = float(input("연산 할 수를 입력해 주세요")) | |
total = multiply(inputNum) | |
elif inputFuntion == "D": | |
inputNum = float(input("연산 할 수를 입력해 주세요")) | |
total = divide(inputNum) | |
elif inputFuntion == "T": | |
print("총합은", total, "입니다.") | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Administrator' | |
# print(__name__) | |
def getArea(radius): | |
area = radius * radius * math.pi | |
return area | |
def main(): | |
print("main function") | |
firstArea = getArea(10) | |
secondArea = getArea(5) | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Administrator' | |
# 동전계산 프로그램 함수와 리스트를 사용해서 만들어보기. | |
# 리스트에 1000원권을 추가해도 코드의 수정이 필요 없을 것 | |
# 100원짜리만 있을 때 다른 주화는 물어보지 않는 것. 입금할 주화를 선택. 총계. | |
""" | |
c10=10 | |
c50=50 | |
c100=100 | |
c500=500 | |
""" | |
# calcValue (10) | |
total = 0 | |
coinValue = 0 | |
coinTable = [10, 50, 100, 500,1000] | |
length = len(coinTable) | |
def multipleVal (coinValue, coinNum): | |
return coinValue*coinNum | |
def choiceCoin (): | |
choice = int(input("입금할 주화의 번호를 선택해주세요 \n 1. 10원 2. 50원 3. 100원 4. 500원 5. 1000원 \n")) | |
if choice < 0: | |
print("값을 잘못입력하셨습니다. 프로그램을 종료합니다.") | |
elif choice > length: | |
print("값을 잘못입력하셨습니다. 프로그램을 종료합니다.") | |
else: | |
coinNum = int(input("갯수를 입력해주세요: ")) | |
return multipleVal(coinTable[choice-1],coinNum) | |
def myExit (): | |
print("종료하시겠습니까? 종료는 0번 계속은 1번을 입력하세요") | |
power = int(input()) | |
if power == 0: | |
print("종료하겠습니다 정산금액은 아래와 같습니다.") | |
print(total) | |
return 1 | |
else : | |
print("계속하겠습니다") | |
def main(): | |
while True: | |
global total | |
total = total+ choiceCoin() | |
if myExit() == 1: | |
break | |
if __name__ == '__main__': | |
main() | |
""" | |
while i<length | |
total = total+ multipleVal(coinTable[i],coinNum) | |
i += 1 | |
print (total) | |
choice = int(input("입금할 주화를 선택해주세요: ")) | |
""" | |
""" | |
while True: | |
total = total+ 1 | |
print("종료하시겠습니까? 종료는 0번을 입력하세요") | |
power = int(input()) | |
if power == 0: | |
print("종료하겠습니다") | |
break | |
else : | |
print("계속하겠습니다") | |
# coin = [c10Num,c50Num,c100Num,c500Num] | |
c10Num=int(input("10원짜리의 개수를 입력")) | |
c50Num=int(input("50원짜리의 개수를 입력")) | |
c100Num=int(input("100원짜리의 개수를 입력")) | |
c500Num=int(input("500원짜리의 개수를 입력")) | |
total=((coinValue[0]*c10Num)+(coinValue[1]*c50Num)+(coinValue[2]*c100Num)+(coinValue[3]*c500Num)) | |
print(total) | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Administrator' | |
# ▷ 단리 : S = A(1+rn) | |
# ▷ 복리 : S = S+A(1+r)ⁿ | |
# ( S : 원리금 합계 / A : 원금 / r : 이자율 / n : 기간) | |
total = 0 | |
def compound (): | |
money = float(input("원금을 입력: ")) | |
rate = float(input("이자율 입력: ")) | |
period = float(input("기간을 입력: ")) | |
global total | |
total += money * ((1 + rate) ** period) | |
print(total) | |
return total | |
def myExit (): | |
print("종료하시겠습니까? 종료는 0번 계속은 1번을 입력하세요") | |
power = int(input()) | |
if power == 0: | |
print("종료하겠습니다 정산금액은 아래와 같습니다.") | |
print(total) | |
return 1 | |
else : | |
print("계속하겠습니다") | |
def main(): | |
while True: | |
compound () | |
if myExit() == 1: | |
break | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Administrator' | |
# person = {'name':"홍길동", 'age':16} | |
# print(person.name) | |
# 어떠한 이름의 속성의 데이터를 입력받아서 추가. | |
person = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Administrator' | |
import random | |
class Member: | |
def __init__(self, name, money = 0): | |
# __init__ 클래스 초기값 설정. | |
# 반드시 name과 money를 가지게 하고 싶다. | |
# 0은 줘도 되고 안줘도 되는 값이 되었다. | |
self.name = name | |
self.money = money | |
class IcecreamSelector: | |
def __init__(self): | |
self.memberList = [] | |
def addMember(self, member): | |
self.memberList.append(member) | |
def printMemnber(self): | |
print(self.memberList) | |
# def selectOne(self): | |
# random.shuffle(self.memberList) | |
# return self.memberList | |
def selectMoney(self, info): | |
random.shuffle(self.memberList) | |
num = 0 | |
for choice in info: | |
memberObj = self.memberList[num] | |
memberObj.money = data | |
def printResult(self): | |
for member in self.memberList: | |
print(member.name + str(member.money)) | |
def main(): | |
selector = IcecreamSelector() | |
for i in range(5): | |
selector.addMember(input("멤버를 입력하세요:")) | |
selector.printMemnber() | |
# one = selector.selectOne() | |
# print("당첨!!") | |
# print(one[0]) | |
selector.printResult() | |
if __name__ == '__main__': | |
main() | |
# obj1.name = 'Hong gil dong' | |
# obj1['name'] = "Kim" | |
# print(obj1.name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Administrator' | |
a = 10 | |
b = 20 | |
c = 30 | |
print(a) | |
print(b) | |
""" | |
sentence = input("무슨 말을 하고 싶나요?") | |
print(sentence) | |
shoutNum = int(input("메아리 횟수를 입력하세요: ")) | |
shoutList = range(shoutNum) | |
for shout in shoutList: | |
print(str(shout+1)+"번째 메아리가 울려퍼집니다.") | |
print(sentence+"~"*shout) | |
# +"번째 메아리가 울려퍼집니다." | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Administrator' | |
# 1등 5000원 2등 3000원 3등은 심부름 해야하는 아이스크림 복불복게임. | |
# 조원들의 이름을 입력. 섞어.딕셔너리와 튜플, 딕셔너리와 리스트. 아이스크림 사는 프로그램. 딕셔너리를 이용. 이름과 결과를 담는다. 5명. 섞어요. 1등은 5천원 2등은 3천원 3등은 심부름. 절차지향으로 일단. | |
# 람다 식이라는 게 있다는 거. 아이스크림 만드는 프로그램에 적용. | |
import random | |
global totalPenalty | |
totalPenalty = [] | |
global totalPerson | |
totalPerson = [] | |
global dic | |
dic = [] | |
def add(*nums): | |
# 반복이 가능하다고 간주. | |
# list도 던지면 된다. | |
# 아스테리크는 파라미터 갯수를 여러개를 입력받을 때 사용한다. | |
for val in nums: | |
if val == 'X': | |
print("종료합니다.") | |
return | |
if val == 'O': | |
print("벌칙입력이 완료되었습니다.") | |
print("벌칙은"+str(totalPenalty)+"입니다.") | |
return 9 | |
totalPenalty.append(nums) | |
print(str(val)+"입력") | |
print("현재까지 DB: "+str(totalPenalty)) | |
def add2(*nums): | |
for val in nums: | |
if val == 'X': | |
print("종료합니다.") | |
return | |
if val == 'O': | |
print("참가자 입력이 완료되었습니다.") | |
print("참가자는"+str(totalPerson)+"입니다.") | |
return 9 | |
if len(totalPenalty) > len(totalPerson): | |
print("참가자 숫자가 적습니다. 참가자를 더 입력해주세요.") | |
continue | |
totalPerson.append(nums) | |
print(str(val)+"입력") | |
print("현재까지 DB: "+str(totalPerson)) | |
def main(): | |
while True: | |
condition = add(input("벌칙을 입력하세요. \n종료는 X, 입력완료는 O를 입력하세요: ")) | |
if condition == 9: | |
break | |
while True: | |
condition2 = add2(input("참가자를 입력하세요. \n종료는 X, 입력완료는 O를 입력하세요: ")) | |
if condition2 == 9: | |
break | |
""" | |
for i in range(inputNum): | |
inputName = input("이름을 입력해 주세요") #listA 에 사용자 입력값 추가 | |
inputHeight = int(input("키를 입력해 주세요")) | |
dic.append({'name':inputName,'penalty':inputHeight}) | |
""" | |
if __name__ == '__main__': | |
main() | |
""" | |
personList=[] #List 생성 | |
personList.append({'이름':'A', '결과':'O'}) # list에 Dic 넣기, Dic={} | |
personList.append({'이름':'B', '결과':'O'}) | |
personList.append({'이름':'C', '결과':'O'}) | |
personList.append({'이름':'D', '결과':'O'}) | |
personList.append({'이름':'E', '결과':'O'}) | |
target1=random.randint(0,100) % 5 | |
personList[target1]['결과'] = 'X' | |
print(personList) | |
""" | |
""" | |
# 순서대로 나와서 엔터를 눌러. x가 나오면 당첨 | |
target = random.randint(0,100) % 5 | |
print(target) | |
list = ['o','o','o','o','o'] | |
list[target] = 'x' | |
for item in list: | |
input("당황하지 말고 enter") | |
print(item) | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Administrator' | |
import math | |
list = [1,3,2,5,6,3,9,4,0] | |
target = 5 | |
list.sort(key= lambda x : math.fabs(x-target)) | |
print(list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Administrator' | |
# 로또를 만든다. 1.공을 뽑고 표본에서 지운다. 2.섞고shuffle 6개를 뽑아. 2.1. 데이터를 뽑아서 표본에서 지운다. 2.2. 데이터를 카피해서 뽑는다. 동전 프로그램이랑 결합. 거스름돈(과제) 리스트 데이터를 훼손하지 않고 6개 데이터를 추출. 뽑은 숫자가 정렬이 되어. | |
# 코드를 짤 때, 변하지 않는 것으로 짜야 정상. | |
# 로또 프로그램 함수형으로 바꾸는 것. | |
## 로또 일련번호를 생성. 가상의 서버와 통신. | |
## 가상의 서버에서 지난주 당첨번호를 받아와서 | |
import random | |
def putTheBall(): | |
ballList = list(range(1, 45)) | |
random.shuffle(ballList) | |
result = ballList[:6] | |
result.sort() | |
print(result) | |
def printResult(rest): | |
print("거스름돈은 아래와 같습니다.") | |
print(rest) | |
def calcRest(inputMoney, oneGame): | |
global rest | |
rest = inputMoney % oneGame | |
return rest | |
def defaultSetting(): | |
global oneGame | |
oneGame = 1000 | |
print("===== 비트 컴퓨터 로또 =====") | |
print("한 게임은 "+str(int(oneGame))+"원 입니다.") | |
global inputMoney | |
inputMoney = int(input("금액을 입력해주세요: ")) | |
gameOpt = input("게임종류를 입력해주세요. 오토는 A를 수동은 M을 : 입력해주세요: ") | |
gameNum = input("게임횟수를 입력해주세요: ") | |
return [inputMoney, gameOpt] | |
def repeatCalc(gameOpt): | |
if gameOpt == 'A': | |
rest = calcRest(inputMoney, oneGame) | |
autoGameNum = (inputMoney - rest) / oneGame | |
print("자동으로 총"+str(int(autoGameNum))+"게임 진행합니다.") | |
repeatNum = 0 | |
while repeatNum < autoGameNum: | |
putTheBall() | |
repeatNum += 1 | |
return rest | |
else: | |
print("자동으로 총"+str(int(gameOpt))+"게임 진행합니다.") | |
rest = inputMoney - oneGame*int(gameOpt) | |
for i in range(int(gameOpt)): | |
putTheBall() | |
return rest | |
def main(): | |
default = defaultSetting() | |
rest = repeatCalc(default[1]) | |
printResult(rest) | |
if __name__ == '__main__': | |
main() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Administrator' | |
global totalNum | |
totalNum = [] | |
def add(*nums): | |
# 반복이 가능하다고 간주. | |
# list도 던지면 된다. | |
# 아스테리크는 파라미터 갯수를 여러개를 입력받을 때 사용한다. | |
for val in nums: | |
totalNum.append(nums) | |
print(str(val)+"입력") | |
print("현재까지 DB: "+str(totalNum)) | |
def main(): | |
while True: | |
add(input("입력해봐: ")) | |
""" | |
print('main') | |
# add(1,2,3,4,6) | |
listObj = list(range(1,100,2)) | |
add(listObj) | |
tObj = (1,2,3,4,5) | |
add(tObj) | |
""" | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Administrator' | |
num1 = int (input("첫 번째 숫자를 입력하세요:")) | |
num2 = int (input("두 번째 숫자를 입력하세요:")) | |
total = 0 | |
# num1 = 5, num2 = 2 => 5+ 6 | |
i = 0 | |
while i < num2 : | |
total = total + num1 + i | |
i = i+1 | |
print ("토탈값:") | |
print (total) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Administrator' | |
import random | |
count = 1 | |
min=1 | |
max=100 | |
while True: | |
num=min+max | |
num=num>>1 | |
print(num) | |
print("정답입니까?") | |
userResp=input("정답보다크면H, 정답보다 작으면L, 정답이면O 를 입력하세요") | |
#만일 정답이면 break | |
if userResp=="H": | |
min=num+1 | |
count += 1 | |
if userResp=="L": | |
max=num-1 | |
count += 1 | |
if userResp=="O": | |
print(str(count)+"번째 정답을 맞췄습니다.") | |
break | |
else: | |
print("H,L,O 중 하나를 입력해 주세요") | |
""" | |
def getMidValue(min, max): | |
num=min+max | |
num=num>>1 | |
return num | |
def main(): | |
print("main function") | |
num = getMidValue(1,100) | |
print(getMidValue(1,100)) | |
print("정답입니까?") | |
userResp=input("정답보다크면H, 정답보다 작으면L, 정답이면O 를 입력하세요") | |
#만일 정답이면 break | |
while True: | |
if userResp=='H': | |
min=num+1 | |
getMidValue() | |
if userResp=='L': | |
max=num-1 | |
if userResp=='O': | |
print("정답입니다.") | |
break | |
else: | |
print("H,L,O 중 하나를 입력해 주세요") | |
continue | |
if __name__ == '__main__': | |
main() | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Administrator' | |
value1 = 0 | |
power = 0 | |
totalMoney = 0 | |
temp = 0 | |
total = 0 | |
def addValue(totalMoney): | |
value1 = int(input("금액의 증감을 입력하세요: ")) | |
totalMoney = totalMoney + value1 | |
print("총금액:"), | |
print(totalMoney) | |
return totalMoney | |
# print("총금액:") | |
# print(totalMoney) | |
# return totalMoney | |
while True: | |
totalMoney= addValue(totalMoney) | |
print("종료하시겠습니까? 종료는 0번을 입력하세요") | |
power = int(input()) | |
if power == 0: | |
print("종료하겠습니다") | |
break | |
# else : | |
else : | |
print("계속하겠습니다") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Administrator' | |
## 기능 단위가 아니라 사람 단위로 함수를 나눠봤습니다. | |
## 제가 단 주석은 #이 두 개에요 | |
## 태윤누나 코드 | |
def start(): | |
myName=input("이름을 입력하세요.:") | |
myTall=int(input("키를 입력하세요.:")) | |
print("내 이름은" + myName + "이고," + "키는" + str(myTall) + "입니다") | |
return [myName, myTall] | |
## 윤호 팀 코드 1 | |
def sort(dic, myInfo): | |
dic.sort(key= lambda obj: abs(myInfo[1]-obj['height'])) | |
print(myInfo[0]+"님의 키와 비슷한 순서대로 정렬하였습니다.") | |
print(dic) | |
return dic | |
## 은애 팀 코드 | |
## cf. 딕셔너리로 입력 받는 방식이 어떤 차이를 지니는지 print(dic)으로 확인하고 | |
## ',' 위치를 유심히 확인하세요. | |
def compareObj(): | |
# listName = [] #입력 받을 이름 List | |
# listHeight = [] #입력 받을 키 List | |
# dic = {'이름':listName, '키':listHeight} | |
inputNum = int(input("몇명의 키를 입력 하실건가요?")) | |
## 키는 정렬을 해야하기 때문에 인트값으로 형변환이 필요해요 | |
#일때 실행을 계속해 | |
inputNum = int(input("몇명의 키를 입력 하실건가요?")) | |
dic = [] | |
for i in range(inputNum): | |
inputName = input("이름을 입력해 주세요") #listA 에 사용자 입력값 추가 | |
inputHeight = int(input("키를 입력해 주세요")) | |
dic.append({'name':inputName,'height':inputHeight}) | |
# listHeight.append(inputHeight) | |
# for i in range(1): | |
return dic | |
# 윤호 팀 코드 2 | |
def main(): | |
myInfo = start() | |
dic = compareObj() | |
sort(dic, myInfo) | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Administrator' | |
import math | |
# a는 높이, | |
atreew = 150 | |
# atreeh = atreew * 0.5317 | |
print("math.tan((28/180.0)*math.pi)의 값 ") | |
print(math.tan((28/180.0)*math.pi)) | |
atreeh = atreew * math.tan((28/180.0)*math.pi) | |
print("A나무의 높이") | |
print(atreeh+1.8) | |
btreew = 100 | |
# btreeh = btreew * 0.6249 | |
print("math.tan((32/180.0)*math.pi)의 값") | |
print(math.tan((32/180.0)*math.pi)) | |
btreeh = btreew * math.tan((32/180.0)*math.pi) | |
print("B나무의 높이") | |
print(btreeh+1.8) | |
if atreeh > btreeh: | |
print("A나무의 높이가 더 큽니다.") | |
if atreeh == btreeh: | |
print("A나무와 B나무의 높이가 같습니다.") | |
# else: | |
if atreeh < btreeh: | |
print("B나무의 높이가 더 큽니다.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Administrator' | |
inputNum = input("현재 섭씨 온도는?\n") | |
print(type(inputNum)) | |
print (inputNum) | |
outputNum = (float(inputNum)*1.8)+32 | |
print("현재 화씨온도는") | |
print (outputNum) | |
print(type(outputNum)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment