Jovian
⭐️
Sign In
In [5]:
n=int(input("enter a no"))
a=0
s=0
c=n
while(n>0):
    a=n%10
    s=s+pow(a,3)
    n=n//10
if(c==s):
    print("armstrong no")
else:
    print("not")
    
enter a no345 not
In [6]:
n=int(input("enter number:"))
for i in range(1,n+1):
    print(i*i)
enter number:5 1 4 9 16 25
In [8]:
summ=0
n=int(input("enter the no:"))
for i in range(1,n+1):
    
     summ=summ+(i*i)
print(summ)
 
enter the no:3 14
In [9]:
a=int(input("enter a number"))
for i in range(1,11):
    print(a,'x',i,'=',a*i)
enter a number2 2 x 1 = 2 2 x 2 = 4 2 x 3 = 6 2 x 4 = 8 2 x 5 = 10 2 x 6 = 12 2 x 7 = 14 2 x 8 = 16 2 x 9 = 18 2 x 10 = 20
In [11]:
num=int(input("enter a number"))
fact=1
for i in range(1,num+1):
    fact=fact*i
print(fact)
    
enter a number5 120
In [14]:
a=lambda v,x,y:v+x+y
print(a(2,3,4))
9
In [15]:
def ex(n):
    return lambda v:v*n
ex=ex(5)
print(ex(3))
15
In [20]:
def ex():
    global s
    print(s)
    s="python"
    print(s)
s="something"
print(s)
ex()
something something python
In [41]:
try:
    a=int(input("Enter a number"))
    div=a/0
except ValueError:
    print("Invalid input")
except :
    print("Invalid input default")
    
print("outside body")
Enter a number45 Invalid input default outside body
In [24]:
di={"one":1,
   "two":2,
   "three":3}
di
Out[24]:
{'one': 1, 'two': 2, 'three': 3}
In [28]:
di["two"]=4
In [29]:
di
Out[29]:
{'one': 1, 'two': 4, 'three': 3}
In [30]:
di.values()
Out[30]:
dict_values([1, 4, 3])
In [31]:
di.keys()
Out[31]:
dict_keys(['one', 'two', 'three'])
In [36]:
def ex(a,b):
    sm=a+b
    return sm
value=ex(2,4)
if(value%2==0):
    print("Even")
else:
    print("Odd")
Even
In [42]:
class varsha():
    x=4
obj=varsha()
print(obj.x)
4
In [46]:
class some():
    def __init__(de,name,email):
        de.sname=name
        de.semail=email
        phone=9090090909
obj=some("Appstone","varsha@gmail.com")
obj1=some("priyanka","priyanka@gmail.com")
print(obj.sname)
print(obj.semail)
print(obj1.sname)
print(obj1.semail)
Appstone varsha@gmail.com priyanka priyanka@gmail.com
In [53]:
class some():
    def __init__(self,a,b):
        self.a=a
        self.b=b
    def add(self):
        self.sum=self.a+self.b
        print(self.sum)
obj=some(int(input()),int(input()))
obj.add()

34 56 90
In [54]:
import jovian
In [ ]:
jovian.commit()
[jovian] Saving notebook..
In [ ]: