본문 바로가기

Category87

4. Function [Def] Def(ine) The purpose of using Def function. If you frequently use lengthy code that you'd like to abbreviate into a single word, you can do so by defining it as a function. Example 1 def bus_rate (age): if age > 65: print('Its Free') elif age > 20 : print ('Adult') else: print('youth') bus_rate(36) Example 2 def bus_rate (age): if age > 65: return 0 elif age > 20 : return 1200 else: return 750 m.. 2024. 3. 26.
3. IF & loop IF is one of the most commonly used functions as a conditional statement. Here, IF, Else, and spacing are very important. Example money = 3000 if money > 3800: print ('Take taxi!') else : print ('Can not take taxi') print ('what to take?') money = 5000 if money > 3800: print ('Take taxi!') else : print ('Can not take taxi') print ('what to take?') If there are not space money = 5000 if money > 3.. 2024. 3. 25.
2. List & dictionary List The order of values is important. Using the 'list' function allows you to utilize the order of values and the listed words or numbers to access the values. a_list = [1,5,6,3,2] a_list.append(99) a_list.append(992) a_list.append(919) a_list.append(399) print(a_list) a_list = [1,5,6,3,2] result = a_list[:3] print(result) Dictionary It stores values as key-value pairs. a_dict = {'name' : 'bob'.. 2024. 3. 25.
1. Variable declaration and data types When learning Python, the most important thing is not to memorize all the code and concepts, but to improve the ability to become familiar with and utilize them in order to make the desired results. Here's an example regarding the most basic aspect of Python, which is inputting values: a = 3 print(a) b = a print(b) a = 5 print(a, b) # 5 3 # input value name = "jun " age = "18" # print the value.. 2024. 3. 25.
WIL : Weekly I Learned 2024. 3. 23 WIL : Weekly I Learned 2024. 3. 23 FACTSDuring the past week, I began studying the basics of SQL. The first few lessons were easy to grasp, but as much as I learned, I found that learning wasn't that easy. The most challenging part was forgetting the codes I had learned as the query statements became more complex. Of course, I am gradually improving as I revisit them, but I'm making an effort to.. 2024. 3. 23.
7. Pivot, Window function (Rank & sum), Date Pivot Pivot is commonly used in Excel, and I've learned that it can also be applied in SQL. Through the following example, I was able to create the result values in a pivot table format. select restaurant_name, max(if(hh='15', cnt_order, 0)) "15", max(if(hh='16', cnt_order, 0)) "16", max(if(hh='17', cnt_order, 0)) "17", max(if(hh='18', cnt_order, 0)) "18", max(if(hh='19', cnt_order, 0)) "19", ma.. 2024. 3. 22.