ETF 초보 탈출기

  • 🪪 블로그 소개글

    안녕하세요, 슈퍼토미입니다.

    이 블로그는 ETF를 처음 시작한 초보의 기록용 공간입니다.
    공부하면서 알게 된 개념, 직접 투자하면서 느낀 점,
    실수했던 경험들을 남겨두려고 합니다.

    투자를 잘하는 사람도 아니고, 가르치려는 목적도 없습니다.
    그냥, 나의 ETF 성장 일기입니다.

    오늘보다 더 나은 투자자가 되기 위한 기록,
    천천히, 꾸준히 쌓아가보겠습니다.
    읽어주셔서 감사합니다.

  • Week 3-4: Data Structures * Day 5-7: List comprehensions and basic file handling

    Week 3: Data Structures (Continued)

    • Day 5: List Comprehensions
    • Introduction to List Comprehensions:
      • Explain list comprehensions as a concise way to create lists in Python.
      • Emphasize their readability and efficiency.
    • Basic Syntax:
      • Show the basic syntax of a list comprehension:
      new_list = [expression for item in iterable]
    • Examples:
      • Provide examples of list comprehensions for creating lists:
      squares = [x**2 for x in range(1, 6)] # [1, 4, 9, 16, 25] even_numbers = [x for x in range(1, 11) if x % 2 == 0] # [2, 4, 6, 8, 10]
    • Nested List Comprehensions:
      • Explain how to use nested list comprehensions for more complex data transformations.
      matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] flattened = [num for row in matrix for num in row] # [1, 2, 3, 4, 5, 6, 7, 8, 9]
    • Day 6: File Handling – Reading Files
    • Introduction to File Handling:
      • Explain the importance of working with files in programming.
      • Discuss different file modes (read, write, append).
    • Opening and Closing Files:
      • Show how to open and close files using the open() function:
      file = open("myfile.txt", "r") # Opens the file in read mode file.close() # Close the file when done
    • Reading Text Files:
      • Demonstrate how to read the contents of a text file:
      with open("myfile.txt", "r") as file: content = file.read()
    • Iterating Over Lines:
      • Explain how to iterate over lines in a text file:
      with open("myfile.txt", "r") as file: for line in file: print(line.strip()) # Strip removes newline characters
    • Day 7: File Handling – Writing and Appending Files
    • Writing to Text Files:
      • Show how to write data to a text file:
      with open("output.txt", "w") as file: file.write("Hello, World!\n")
    • Appending to Text Files:
      • Explain how to append data to an existing text file:
      with open("output.txt", "a") as file: file.write("This is an appended line.\n")
    • Error Handling in File Handling:
      • Discuss error handling when working with files, including exceptions like FileNotFoundError.
    • Practice Exercises:
      • Provide exercises and challenges that involve list comprehensions and basic file handling operations.

    By the end of Week 4, you’ll have a solid understanding of list comprehensions for concise list creation and basic file handling techniques for reading, writing, and appending text files. These skills are valuable for various data processing and file manipulation tasks in Python.