<jupyter_start><jupyter_text>LetsUpgrade_Day9_Assignment1  Q1.<jupyter_code>%%writefile primechecker.py
'''another comment for testing'''

def check_prime(num):
    ''' This function is for checking prime number'''
    if num > 1:
        for i in range(2, num):
            if (num % i) == 0:
                print(num, "is not a prime number")
            else:
                print(num, "is a prime number")

    else:
        print(num, "is not a prime number")
! pylint "primechecker.py"
%%writefile prime-checkr.py
import unittest

class primecheckr(unittest.TestCase):
    def check_prime(self,num):
        if num > 1:
            for i in range(2, num):
                if (num % i) == 0:
                    print(num, "is not a prime number")
                else:
                    print(num, "is a prime number")

        else:
            print(num, "is not a prime number")
        
    def abcdef(self):
        check_prime(2)
        result = "is a prime number"
        self.assertEquals(result,"is a prime number")
        

    
unittest.main(argv=['ignoring_first_arg'], exit=False)
! python prime-checkr.py<jupyter_output>----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK<jupyter_text>Q2.<jupyter_code>def checkarmstrong(num):

    sum = 0

    temp = num
    while temp > 0:
        digit = temp % 10
        sum += digit ** 3
        temp //= 10

    if num == sum:
        return num
checkarmstrong(371)
lst = list(range(1,1000))
def armstronggenerator(lst):
    for item in lst:
        sum = 0
        temp = item
        while temp > 0:
            digit = temp % 10
            sum += digit ** 3
            temp //= 10
        if item == sum:
            yield item
print(list(armstronggenerator(lst)))<jupyter_output>[1, 153, 370, 371, 407]
{'fraction_non_alphanumeric': 0.14528508771929824, 'fraction_numerical': 0.027960526315789474, 'mean_word_length': 1.6997041420118344, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '512938', 'license': 'Apache-2.0', 'n_tokens_mistral': 607, 'n_tokens_neox': 551, 'n_words': 165, 'path': 'Assignment6.ipynb', 'repo_name': 'onlinelovekesh/LetsUpgrade-Python-Essentials', 'size': '1824'}