Skip to content

Commit b1f7335

Browse files
committedOct 7, 2021
day4_이론 끝
1 parent 6b2852b commit b1f7335

File tree

5 files changed

+99
-1
lines changed

5 files changed

+99
-1
lines changed
 

‎calculator.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def plus(a, b):
2+
return a+b

‎day1_12.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# 모듈 import 하기
2+
# 모듈의 쓸만한 일부만 import 할 수도 있다. 이게 낫다.
3+
from math import ceil
4+
#import math # 수학 기능 모아둔 모듈
5+
6+
# 모듈에서 가져올 함수의 이름을 바꿀 수도 있다.
7+
# from math import ceil as sexy_upper 이런식으로
8+
9+
print(ceil(1.2)) # 값을 올림해주는 ceil
10+
#print(math.fabs(-1.2)) # 절대값 출력
11+

‎day1_12_2.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from calculator import plus #이런식으로 다른 파일에서 정의된 기능을 import 할 수 있다.
2+
3+
print(plus(1,2))

‎day1_8.py

+31
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,35 @@ def remove_x(day_list,day):
3737

3838

3939

40+
# def is_on_list(a_list=[], word=""):
41+
# return word in a_list
42+
43+
# def get_x(a_list=[], index=0):
44+
# return a_list[index]
45+
46+
# def add_x(a_list=[], word=""):
47+
# a_list.append(word)
48+
49+
# def remove_x(a_list=[], word=""):
50+
# a_list.remove(word)
51+
52+
# # \/\/\/\/\/\/\ DO NOT TOUCH AREA \/\/\/\/\/\/\ #
53+
54+
# days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
55+
56+
# print("Is Wed on 'days' list?", is_on_list(days, "Wed"))
57+
58+
# print("The fourth item in 'days' is:", get_x(days, 3))
59+
60+
# add_x(days, "Sat")
61+
# print(days)
62+
63+
# remove_x(days, "Mon")
64+
# print(days)
65+
66+
67+
# # /\/\/\/\/\/\/\ END DO NOT TOUCH AREA /\/\/\/\/\/\/\ #
68+
69+
70+
4071

‎homework2.py

+52-1
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,55 @@ def delete_from_dict(dict, *word):
152152
print('\nget_from_dict(my_english_dict, "kimchi"):')
153153
get_from_dict(my_english_dict, "kimchi")
154154

155-
# \/\/\/\/\/\/\ END DO NOT TOUCH \/\/\/\/\/\/\
155+
# \/\/\/\/\/\/\ END DO NOT TOUCH \/\/\/\/\/\/\
156+
157+
158+
# def add_to_dict(a_dict, word="", definition=""):
159+
# if type(a_dict) is not dict:
160+
# print("You need to send a dictionary. You sent:", type(a_dict))
161+
# elif word == '' or definition == '':
162+
# print("You need to send a word and a definition.")
163+
# else:
164+
# if word in a_dict:
165+
# print(f"{word} is already on the dictionary. Won't add.")
166+
# else:
167+
# a_dict[word] = definition
168+
# print(word,"has been added.")
169+
170+
171+
# def get_from_dict(a_dict, word=""):
172+
# if type(a_dict) is not dict:
173+
# print("You need to send a dictionary. You sent:", type(a_dict))
174+
# elif word == '':
175+
# print("You need to send a word to search for.")
176+
# else:
177+
# if word not in a_dict:
178+
# print(f"{word} was not found in this dict.")
179+
# else:
180+
# print(f"{word}: {a_dict[word]}")
181+
182+
183+
# def update_word(a_dict, word="", definition=""):
184+
# if type(a_dict) is not dict:
185+
# print("You need to send a dictionary. You sent:", type(a_dict))
186+
# elif word == "" or definition == "":
187+
# print("You need to send a word and a definition to update.")
188+
# else:
189+
# if word not in a_dict:
190+
# print(f"{word} is not on the dict. Can't update non-existing word.")
191+
# else:
192+
# a_dict[word] = definition
193+
# print(word, "has been updated to:", definition)
194+
195+
196+
# def delete_from_dict(a_dict, word=""):
197+
# if type(a_dict) is not dict:
198+
# print("You need to send a dictionary. You sent:", type(a_dict))
199+
# elif word == "":
200+
# print("You need to specify a word to delete.")
201+
# else:
202+
# if word not in a_dict:
203+
# print(f"{word} is not in this dict. Won't delete.")
204+
# else:
205+
# del a_dict[word]
206+
# print(f"{word} has been deleted.")

0 commit comments

Comments
 (0)
Please sign in to comment.