diff --git a/basic/1_variable.py b/basic/1_variable.py index d15e504..6faffa9 100644 --- a/basic/1_variable.py +++ b/basic/1_variable.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + ''' 문단주석 ''' @@ -13,7 +15,7 @@ print(type(stock_earning)) # str 은 문자 -stock_name = "문자입니다." +stock_name = "aaa" print("stock_name : %s" % stock_name) print(type(stock_name)) diff --git a/basic/2_math.py b/basic/2_math.py index bb6f4b3..3aec166 100644 --- a/basic/2_math.py +++ b/basic/2_math.py @@ -1,11 +1,14 @@ +# -*- coding: utf-8 -*- + ''' 덧셈, 뺄셈, 곱셈, 나눗셈 ''' -#int 더하기 +#기본 값 세팅 stock_price1 = 1000 stock_price2 = 2000 +#int 더하기 stock_price_total = stock_price1 + stock_price2 print("%s" % stock_price_total) diff --git a/basic/3_0_conditional_statements.py b/basic/3_0_conditional_statements.py new file mode 100644 index 0000000..2f4823c --- /dev/null +++ b/basic/3_0_conditional_statements.py @@ -0,0 +1,7 @@ +cnt=0 + +if cnt == 30: + print("number 1") + +print("number 2") + \ No newline at end of file diff --git a/basic/3_1_conditional_statements for.py b/basic/3_1_conditional_statements for.py new file mode 100644 index 0000000..d52fa58 --- /dev/null +++ b/basic/3_1_conditional_statements for.py @@ -0,0 +1,8 @@ +count = 0 +for i in range(0, 10): + count = count + 1 + +print(count) + +for i, value in enumerate(['kium', 'samsung', 'kakao']): + print("%s is numeric, %s is value" % (i,value)) \ No newline at end of file diff --git a/basic/3_2_conditional_statements_while.py b/basic/3_2_conditional_statements_while.py new file mode 100644 index 0000000..981f3f3 --- /dev/null +++ b/basic/3_2_conditional_statements_while.py @@ -0,0 +1,9 @@ + +cnt = 0 +repeat_boolean = True +while repeat_boolean: + print("%s while statement is running" % cnt) + cnt = cnt+1 + if cnt == 30: + repeat_boolean = False + print("the end") diff --git a/basic/4_1_tuple.py b/basic/4_1_tuple.py new file mode 100644 index 0000000..a3142b9 --- /dev/null +++ b/basic/4_1_tuple.py @@ -0,0 +1,18 @@ + +# like a javascript array +# tuple is not able to add or update +a_tuple = {"kiumn","daesin", "kakao"} +print(a_tuple) + +a_len = len(a_tuple) +print(a_len) + +a_type = type(a_tuple) +print(a_type) + +for value in a_tuple: + print(value) + +for index, value in enumerate(a_tuple): + print("%s is index, %s is value" % (index, value)) + diff --git a/basic/4_2_list.py b/basic/4_2_list.py new file mode 100644 index 0000000..0684c1d --- /dev/null +++ b/basic/4_2_list.py @@ -0,0 +1,14 @@ +a_list = ["list1", "list2", "list3"] + +print(a_list) + +for index,value in enumerate(a_list): + print("%s, %s" %(index,value)) + + +a_list = ["a_list1", "a_list2", "a_list3"] +b_list = ["b_list1", "b_list2"] + +a_list.append(b_list) + +print(a_list) \ No newline at end of file diff --git a/basic/4_3_dictionary.py b/basic/4_3_dictionary.py new file mode 100644 index 0000000..974a392 --- /dev/null +++ b/basic/4_3_dictionary.py @@ -0,0 +1,36 @@ +# like a map of JAVA +a_dict = {"key 1" : "value 1" + ,"key 2" : "value 2" + ,"key 3" : "value 3"} + +print(type(a_dict)) +print(a_dict) +print(a_dict['key 1']) + +for key in a_dict: + print('%s is key. %s is value.' % (key, a_dict[key])) + +a_dict.update({"key 4" : "value 4", "key 5" : "value 5"}) +print(a_dict) + +for value in a_dict.keys(): + print("value : %s" % value) + if value == "key 1": + print("222222222222222222222") + elif value == "key 2": + print("33333333333333333333") + else: + print("44444444444444444444") + + +#like a map inner map of JAVA +b_dict = {"bkey 1" : + {"bkey 11" : "bvalue11" + ,"bkey 12" : "bvalue122" + } + } + +print(b_dict) +print(b_dict['bkey 1']['bkey 12']) + +