<jupyter_start><jupyter_text>https://www.w3resource.com/python-exercises/class-exercises/ Write a Python class to convert an integer to a roman numeral<jupyter_code>class solution:
    
    def int_to_Roman(self, num):
        val = [1000, 900, 500, 400, 100, 90, 50, 40,10, 9, 5, 4,1]
        syb = ["M", "CM", "D", "CD","C", "XC", "L", "XL","X", "IX", "V", "IV","I"]
        
        roman_num = ''
        i = 0
        
        while  num > 0:
            for x in range(num // val[i]):    # floor division 625 / 1 = 600
                roman_num += syb[i]
                num -= val[i]
            i += 1
        
        return roman_num

print(solution().int_to_Roman(1))
print(solution().int_to_Roman(398))
print(solution().int_to_Roman(600))<jupyter_output>I
CCCXCVIII
DC<jupyter_text>Write a Python class to get all possible unique subsets from a set of distinct integers.   - Input : [4, 5, 6]   - Output : [[], [6], [5], [5, 6], [4], [4, 6], [4, 5], [4, 5, 6]]<jupyter_code>class py_solution:
   
    def sub_sets(self, sset):
        return self.subsetsRecur([], sorted(sset))
    
    def subsetsRecur(self, current, sset):
        if sset:
            return self.subsetsRecur(current, sset[1:]) + self.subsetsRecur(current + [sset[0]], sset[1:])
        return [current]

print(py_solution().sub_sets([4,5,6]))
import itertools

t = [4,5,6]
l = (len(t))
u = []

for i in range (1,l+1):
    u.extend(itertools.combinations(t,i))
    
print(u)<jupyter_output>[(4,), (5,), (6,), (4, 5), (4, 6), (5, 6), (4, 5, 6)]<jupyter_text>Write a Python class to find a pair of elements (indices of the two numbers) from a given array whose sum equals a specific target number.   - Input: numbers= [10,20,10,40,50,60,70], target=50   - Output: 3, 4<jupyter_code>class solution:
    
    def sumoftwo(self, numbers, target):
        aaa = {}                                 # this only works if it is a disctionary
        for i, numbers in enumerate(numbers):    # this is to provide a count starting at i for each number
            if target - numbers in aaa:
                return (aaa[target-numbers],i)   
            
            aaa[numbers] = i                     # this is the loop increment in the enumerate function
            print(i,numbers)                     # this is just to see the content of enumerate 
                        
print("index1=%d, index2=%d" % solution().sumoftwo((10,20,10,40,50,60,70),50))<jupyter_output>0 10
1 20
2 10
index1=2, index2=3<jupyter_text>Write a Python class to find the three elements that sum to zero from a set of n real numbers.    - Input array : [-25, -10, -7, -3, 2, 4, 8, 10]    - Output : [[-10, 2, 8], [-7, -3, 10]] Write a Python class to implement pow(x, n)<jupyter_code>class solution:<jupyter_output><empty_output><jupyter_text>Write a Python class to reverse a string word by word.     - Input string : 'hello .py'    - Expected Output : '.py hello Write a Python class which has two methods get_String and print_String. get_String accept a string from the user and print_String print the string in upper case.<jupyter_code>class rectangle:
    
    def __init__(self, length, width):
        self.length = length
        self.width = width
        
    def area(self):
        area = self.length * self.width
        return area
        
aaa = rectangle(5,10)
print(aaa.area())<jupyter_output>50<jupyter_text>Write a Python class named Rectangle constructed by a length and width and a method which will compute the area of a rectangle<jupyter_code>class rectangle:
    
    def __init__(self, length, width):
        self.length = length
        self.width = width
        
    def area(self):
        area = self.length * self.width
        return area
        
aaa = rectangle(5,10)
print(aaa.area())<jupyter_output>50<jupyter_text>Write a Python class named Circle constructed by a radius and two methods which will compute the area and the perimeter of a circle<jupyter_code>class circle:
    
    def __init__(self, radius):
        self. radius = radius
    
    def area(self):
        return self.radius * self.radius * 3.14
    
    def perimeter(self):
        return 2 * self.radius * 3.14

mycircle = circle(5)
print(mycircle.area())
print(mycircle.perimeter())<jupyter_output>78.5
31.400000000000002
{'fraction_non_alphanumeric': 0.12278244631185807, 'fraction_numerical': 0.04435107376283847, 'mean_word_length': 2.646808510638298, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 24, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '596670', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 1548, 'n_tokens_neox': 1402, 'n_words': 445, 'path': 'Exercises - Other/Exercises OOP.ipynb', 'repo_name': 'k21k/Python-Notes', 'size': '4284'}