Jovian
⭐️
Sign In
In [2]:
n=int(input("Enter a number"))
for i in range(1,n+1):
    print(i*i)
Enter a number6 1 4 9 16 25 36
In [3]:
n=int(input("Enter a number"))
sum=0
for i in range(1,n+1):
    b=i**2
    print(b)
    sum=sum+b
print("summation: ",sum)
Enter a number3 1 4 9 summation: 14
In [4]:
n=int(input("enter how many terms"))
a=0
b=1
count=0
while count<n:
    print(a)
    c=a+b
    a=b
    b=c
    count=count+1
enter how many terms5 0 1 1 2 3
In [15]:
n=int(input("enter how many terms"))
a=0
b=1
sum=0

for i in range(0,n):
    if i==0:
        print(a)
    elif i==1:
        print(a)
        
    sum=a+b
    print(sum)
    a=b
    b=sum

enter how many terms1 0 1
In [7]:
n=int(input("enter how many terms"))
a=0
b=1
count=0
sum=0
while count<n:
    print(a)
    sum=sum+a
    c=a+b
    a=b
    b=c
    count=count+1
print("summation:",sum)
enter how many terms3 0 1 1 summation: 2
In [18]:
a=(1,2,3,4)
print(a)
print(type(a))
(1, 2, 3, 4) <class 'tuple'>
In [19]:
a=(1,2,3,4,[12,3,4])
print(a)
(1, 2, 3, 4, [12, 3, 4])
In [20]:
a[4].append(2)
a
Out[20]:
(1, 2, 3, 4, [12, 3, 4, 2])
In [21]:
a[4].pop()
Out[21]:
2
In [22]:
a
Out[22]:
(1, 2, 3, 4, [12, 3, 4])
In [23]:
a[4][0]=34
In [24]:
a
Out[24]:
(1, 2, 3, 4, [34, 3, 4])
In [26]:
a=[1,2,(1,45,5)]
In [27]:
a
Out[27]:
[1, 2, (1, 45, 5)]
In [28]:
a[2]=45
In [29]:
a
Out[29]:
[1, 2, 45]
In [34]:
def som(a,b):
    c=a+b
    return c
add=som(1,2)
print(add)
3
In [35]:
a=lambda v:v+12
print(a(3))
15
In [40]:
samir=lambda r:r+r
print(samir(int(input())))
5 10
In [43]:
a=[12,34,56,78]
for i in "samir":
    print(i)
s a m i r
In [45]:
a=[]
for i in range(1,6):
    b=int(input("Enter a number"))
    a.append(b)
a
Enter a number45 Enter a number45 Enter a number34 Enter a number78 Enter a number23
Out[45]:
[45, 45, 34, 78, 23]
In [49]:
class samir():
    x=4
    c="samier"
obj=samir()
print(obj.c,"",obj.x)
samier 4
In [64]:
class aditi():
    x=4
    add=0
    def __init__(self,name,email):
        self.sname=name
        self.semail=email
    def add(self,v,x):
        self.add=v+x
        return self.add
obj=aditi(1,"bahubali@gmail.com")
print(obj.x)
print(obj.add(1,3))

        
1 bahubali@gmail.com 4 4
In [72]:
class aditi():
    x=0
    def __init__(self,a,b):
        self.a1=a
        self.a2=b
         global x=a
    def add(self):
        self.add=self.a1+self.a2
        return self.add
ob1=aditi(2,3)
ob2=aditi(4,5)
print(ob1.a1)
print(ob1.x)

File "<ipython-input-72-d074522d4e23>", line 6 global x=a ^ IndentationError: unexpected indent
In [ ]: