





from __future__ import annotations

from typing import Generic, TypeVar

_lowerCAmelCase							:      Dict						=	TypeVar('''T''')


class 					__magic_name__  (							Generic[T]							):





     """simple docstring"""



     def __init__(							self       :List[Any]			,      snake_case       :T  ):





        '''simple docstring'''




        A_					:				int          =			data  # Assign data
        A_					:				Node[T] | None          =			None  # Initialize next as null
        A_					:				Node[T] | None          =			None  # Initialize prev as null




class 					__magic_name__  (							Generic[T]							):





     """simple docstring"""



     def __init__(							self       :Optional[int]  ):





        '''simple docstring'''




        A_					:				Node[T] | None          =			None



     def 						SCREAMING_SNAKE_CASE		(							self       :Tuple			,      snake_case       :T  ):





        '''simple docstring'''




        if self.head is None:
           A_					:				List[Any]          =			Node(snake_case  )
        else:
           A_					:				Tuple          =			Node(snake_case  )
           A_					:				Union[str, Any]          =			new_node
           A_					:				List[Any]          =			self.head
           A_					:				List[str]          =			None
           A_					:				List[str]          =			new_node



     def 						SCREAMING_SNAKE_CASE		(							self       :Optional[Any]  ):





        '''simple docstring'''




        if self.head is None:
           return None
        else:
           assert self.head is not None
           A_					:				Optional[Any]          =			self.head.data
           A_					:				Optional[Any]          =			self.head.next
           if self.head is not None:
              A_					:				Union[str, Any]          =			None
           return temp



     def 						SCREAMING_SNAKE_CASE		(							self       :Optional[int]  ):





        '''simple docstring'''




        return self.head.data if self.head is not None else None



     def __len__(							self       :List[Any]  ):





        '''simple docstring'''




        A_					:				int          =			self.head
        A_					:				List[Any]          =			0
        while temp is not None:
           count += 1
           A_					:				Any          =			temp.next
        return count



     def 						SCREAMING_SNAKE_CASE		(							self       :Any  ):





        '''simple docstring'''




        return self.head is None





     def 						SCREAMING_SNAKE_CASE		(							self       :Optional[Any]  ):





        '''simple docstring'''




        print("stack elements are:"  )
        A_					:				Dict          =			self.head
        while temp is not None:
           print(temp.data			,      end="->"  )
           A_					:				str          =			temp.next


# Code execution starts here
if __name__ == "__main__":
 # Start with the empty stack
 _lowerCAmelCase							:      Stack[int]						=	Stack()

 # Insert 4 at the beginning. So stack becomes 4->None
 print('''Stack operations using Doubly LinkedList''')
 stack.push(4)

 # Insert 5 at the beginning. So stack becomes 4->5->None
 stack.push(5)

 # Insert 6 at the beginning. So stack becomes 4->5->6->None
 stack.push(6)

 # Insert 7 at the beginning. So stack becomes 4->5->6->7->None
 stack.push(7)

 # Print the stack
 stack.print_stack()

 # Print the top element
 print('''\nTop element is ''', stack.top())

 # Print the stack size
 print('''Size of the stack is ''', len(stack))

 # pop the top element
 stack.pop()

 # pop the top element
 stack.pop()

 # two elements have now been popped off
 stack.print_stack()

 # Print True if the stack is empty else False
 print('''\nstack is empty:''', stack.is_empty())







def      __snake_case						(					_lowerCAmelCase : int				,				_lowerCAmelCase : int = 1000	) ->						str:
   if (not isinstance(_lowerCAmelCase				,				_lowerCAmelCase	)) or (digit_position <= 0):
      raise ValueError("Digit position must be a positive integer"	)
   elif (not isinstance(_lowerCAmelCase				,				_lowerCAmelCase	)) or (precision < 0):
      raise ValueError("Precision must be a nonnegative integer"	)

   # compute an approximation of (16 ** (n - 1)) * pi whose fractional part is mostly
   # accurate
   A_					:				List[str]          =			(
       4 * _subsum(_lowerCAmelCase				,				1				,				_lowerCAmelCase	)
       - 2 * _subsum(_lowerCAmelCase				,				4				,				_lowerCAmelCase	)
       - _subsum(_lowerCAmelCase				,				5				,				_lowerCAmelCase	)
       - _subsum(_lowerCAmelCase				,				6				,				_lowerCAmelCase	)
   )

   # return the first hex digit of the fractional part of the result
   return hex(int((sum_result % 1) * 16	)	)[2:]

def      __snake_case						(					_lowerCAmelCase : int				,				_lowerCAmelCase : int				,				_lowerCAmelCase : int	) ->						float:
   A_					:				int          =			0.0
   for sum_index in range(digit_pos_to_extract + precision	):
      A_					:				Optional[int]          =			8 * sum_index + denominator_addend
      if sum_index < digit_pos_to_extract:
         # if the exponential term is an integer and we mod it by the denominator
         # before dividing, only the integer part of the sum will change;
         # the fractional part will not
         A_					:				Optional[Any]          =			pow(
             16				,				digit_pos_to_extract - 1 - sum_index				,				_lowerCAmelCase	)
      else:
         A_					:				Tuple          =			pow(16				,				digit_pos_to_extract - 1 - sum_index	)
      total += exponential_term / denominator
   return total


if __name__ == "__main__":
 import doctest

 doctest.testmod()
