# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Assignment 1

# +
# %%writefile prime_num

# A optimized school method based 
# Python3 program to check 
# if a number is prime 

def isPrime(n) :
    # Corner cases 
    if (n <= 1) : 
        return False
    if (n <= 3) : 
        return True
    # This is checked so that we can skip 
    # middle five numbers in below loop 
    if (n % 2 == 0 or n % 3 == 0) : 
        return False
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
    return True
# Driver Program 
if (isPrime(11)) : 
    print(" true") 
else : 
    print(" false") 
if(isPrime(15)) : 
    print(" true") 
else : 
    print(" false") 
# -

# !pip install pylint

# ! python -m pip install --upgrade pip

# ! pylint "prime_num"

# # Assignment 2

# Python program to check if the number provided by the user is an Armstrong number or not
# take input from the user
num = int(input("Enter a number: "))
# initialize sum
sum = 0
# find the sum of the cube of each digit
temp = num
while temp > 0:
    digit = temp % 10
    sum += digit ** 3
    temp //= 10
# display the result
if num == sum:
    print(num,"is an Armstrong number")
else:
    print(num,"is not an Armstrong number")

StarcoderdataJupyterScriptsDedupFiltered