본문 바로가기

Category87

WIL : Weekly I Learned Fact It's been already two weeks since I started the data analysis course. This week, I learned about how to code in Python and practiced a lot. Python was more challenging compared to SQL. I repeated a lot to get familiar with Python, and it seems I'll need even more practice in the future. Especially while learning Python, I started to get confused with functions that are used similarly in SQL.. 2024. 3. 29.
9. Method vs Function / Dictionary vs List Method vs Function While studying Python, I try to organize the method of using . or. () through this post because I was confused about how to write . In Python, there are cases where you use a dot (.) when calling a function and cases where you don't. Here are the general rules: Method: When calling an object's method, you use a dot (.). For instance, when invoking the split() method of a strin.. 2024. 3. 28.
8. Function simplification Function simplification The reason for simplifying functions is to make the code more concise and readable. Simplified functions reduce redundant code, decrease unnecessary complexity, and enhance maintainability. Additionally, Simplified functions can improve performance and operate more efficiently. Here is an example of simplification Example 1 Before num = 3 if num % 2 == 0: result = 'even' .. 2024. 3. 27.
7. F-strings & Try Except F-strings f-strings provide a simple and intuitive way to format strings in Python, making it easier to read and maintain code. To use f-strings, simply prefix the string with 'f' or 'F' and place variable names or expressions inside curly braces {}. The contents within the curly braces are then replaced with the value of the respective variable or expression. F-strings allow variables to be ins.. 2024. 3. 27.
6. Set & tuples and list Set In Python, a set is a data type representing a collection of unique elements. Sets do not allow duplicate elements and are unordered. This makes sets useful for operations such as set union, intersection, and difference. Sets are defined using curly braces {}, with elements separated by commas. For example: my_set = {1, 2, 3, 4, 5} You can create a set from a list or tuple, removing any dupl.. 2024. 3. 27.
5. Uses of [] {} () In Python, `{}` curly braces are used to represent a dictionary. A dictionary is a data structure consisting of key-value pairs. Inside the curly braces, key-value pairs are listed, separated by commas. For example: my_dict = {'name': 'John', 'age': 30, 'city': 'New York'} Here, 'name', 'age', and 'city' are keys, while 'John', 30, and 'New York' are their corresponding values. `()` parentheses .. 2024. 3. 26.