
    gb	                         d Z d Z	 d Z	 d Zy)z
Problem 1: Raise to Power
Write a function raise_to_power(n) that takes an integer n and returns a function that takes a number x and raises it to the nth power. For example, if n is 5, the returned function should return x**5.
c                       fd}|S )a  
    Returns a function that raises a given number to the nth power.
    
    Parameters:
    n (int or float): The exponent to which numbers will be raised.
    
    Returns:
    function: A function that takes a number and raises it to the power of n.
    c                     | z  S )z
        Raises x to the power of n.
        
        Parameters:
        x (int or float): The base number.
        
        Returns:
        int or float: The result of x raised to the power of n.
         )xns    @c:\WORK\www\ai.huynhdous.com\UCI\Inter_Python\week_4_homework.pypowerzraise_to_power.<locals>.power   s     Av    r   )r   r   s   ` r   raise_to_powerr
      s    
 Lr	   c                       fd}|S )a  
    Returns a function that writes a given string to the specified file.
    
    Parameters:
    filepath (str): The path of the file where text will be written.
    
    Returns:
    function: A function that takes a string and appends it to the file.
    c                 p    t        d      5 }|j                  | dz          ddd       y# 1 sw Y   yxY w)z
        Appends text to the file at filepath.
        
        Parameters:
        text (str): The text to write to the file.
        a
N)openwrite)textmy_filefilepaths     r   write_to_filez"file_writer.<locals>.write_to_file.   s6     (C  	'GMM$+&	' 	' 	's   ,5r   )r   r   s   ` r   file_writerr   #   s    ' r	   c                       fd}|S )z
    Returns a generator function that reads a file line by line and yields the nth word of each line.

    :param n: The position of the word to return (1-based index).
    :return: A generator function that takes a filepath argument.
    c              3      K   t        | dd      5 }|D ]:  }|j                         j                         }t        |      k\  r|dz
     nd  < 	 d d d        y # 1 sw Y   y xY ww)Nrzutf-8)encoding   )r   stripsplitlen)r   filelinewordsr   s       r   	generatorz&word_n_of_each_line.<locals>.generatorD   sl     (C'2 	@d @

**,&)%jAoeAEl4?@	@ 	@ 	@s   A(A A	A(A%!A(r   )r   r!   s   ` r   word_n_of_each_liner"   =   s    @ r	   N)__doc__r
   r   r"   r   r	   r   <module>r$      s#   4.r	   