#print("Enter the first number")
a,b=input("Enter the numbers").split(",")
#b=int(input("Enter the second number/n"))
print(a*b)
Enter the numbers67,89
----------------------------------------------------------------------
-----
TypeError Traceback (most recent call
last)
<ipython-input-31-8706ea082470> in <cell line: 4>()
2 a,b=input("Enter the numbers").split(",")
3 #b=int(input("Enter the second number/n"))
----> 4 print(a*b)
TypeError: can't multiply sequence by non-int of type 'str'
print(int(a)*int(b))
5963
vaishnavi ibm singh
Hello World
print("Hello \n world")
Hello
world
a=input("Enter the number")
print("entered number is",a)
Enter the number9
entered number is9
a=input("Enter the number")
print("entered number is",a)
b=int(input("Enter the number"))
print("the adition is" *b)#,"\n""The subtraction is",a-b,"\n""The
multiplication is",a*b,"\n""The division is",a/b)
Enter the number8
entered number is 8
Enter the number3
the adition isthe adition isthe adition is
a,b=input("Enter two numbers").split(",")
a=int(a)
b=int(b)
print("entered number is",a)
print("entered number is",b)
print("The adition is",a+b)
Enter two numbers67,45
entered number is 67
entered number is 45
The adition is 112
a,b=input("Enter two numbers").split()
c=a
a=b
b=c
print("after swapping a is",a)
print("after swapping b is",b)
Enter two numbers56 32
after swapping a is 32
after swapping b is 56
a,b=input("Enter two numbers").split()
a=int(a)
b=int(b)
a=a+b
b=a-b
a=a-b
print("after swapping a is",a)
print("after swapping b is",b)
Enter two numbers8 9
after swapping a is 9
after swapping b is 8
print("your name 5 times",'aditya\n'*5)
your name 5 times aditya
aditya
aditya
aditya
aditya
a=int(input("enter the number for table"))
for i in range(1,11,2):
print(a,"*",i,"=",(a*i))
print("end")
enter the number for table67
67 * 1 = 67
67 * 3 = 201
67 * 5 = 335
67 * 7 = 469
67 * 9 = 603
end
name=input("enter the name ")
print(len(name))
for i in range(len(name)):
print(-1*i-1,name[-1*i-1])
enter the name vaishnavi
9
-1 i
-2 v
-3 a
-4 n
-5 h
-6 s
-7 i
-8 a
-9 v
name=input("enter a name ")
if len(name)%2!=0:
print(name[len(name)//2])
else:
print(name[len(name)//2-1],name[len(name)//2])
enter a name vaishnav
s h
num = int(input("Enter a number: "))
limit = int(input("Enter the limit: "))
for i in range(6):
result = num ** (i)
print(f"{i} is {result}")
#else:
print(limit-i)
Enter a number: 7
Enter the limit: 6
0 is 1
1 is 7
2 is 49
3 is 343
4 is 2401
5 is 16807
1
a=int(input())
b= int(input())
if a>b:
print("a is greater")
elif a==b:
print("equal")
else:
print("b is equal")
8
9
b is equal
a=9
b=7
c=6
if a>b:
if a>c:
if b>c:
print(a,b,c)
else:
print(a,c,b)
else:
print(c,a,b)
else:
if b>c:
if a>c:
print(b,a,c)
else:
print(b,c,a)
else:
print(c,b,a)
9 7 6
n=int(input("enter a number "))
for i in range(n):
print("@"*(n-i))
enter a number 7
@@@@@@@
@@@@@@
@@@@@
@@@@
@@@
@@
@
for i in range(5):
for j in range():
print(j,end="")
*
**
***
****
*****
for i in range(9):
print(i, end="")
012345678
a=int(input("enter the number"))
#for j in range(a):
for i in range(a):
print("@"*(a-i),"_"*(2*i+1),"@"*(a-i))
enter the number9
@@@@@@@@@ _ @@@@@@@@@
@@@@@@@@ ___ @@@@@@@@
@@@@@@@ _____ @@@@@@@
@@@@@@ _______ @@@@@@
@@@@@ _________ @@@@@
@@@@ ___________ @@@@
@@@ _____________ @@@
@@ _______________ @@
@ _________________ @
lucky=8
for i in range(5):
num=int(input("enter your number: "))
if num==lucky:
print("you won the lottery")
break
else:
if num>lucky:
print("the number is greater")
else:
print("this number is smaller")
enter your number: 6
this number is smaller
enter your number: 7
this number is smaller
enter your number: 3
this number is smaller
enter your number: 2
this number is smaller
enter your number: 10
the number is greater
num1, num2 =input("enter").split(",")
print(num1, " ", num2)
num1=int(num1)
num2=int(num2)
print(num1+num2)
enter78,76
78 76
154
num1=["nam","mob"]
num2=["aditya","123456"]
for i,j in zip(num1,num2):
print( i,"=", j)
nam = aditya
mob = 123456
name=input("enter the name")
surname=input("enter the surname")
for i in (name,surname):
print(i)
enter the namevaishnavi
enter the surnamesingh
vaishnavi
singh
name=["Vaishnavi","Singh","vaishnavi.crafteak@co"]
Slicing
name.remove(name[1])
print(name)
#print(name[::2])
['Vaishnavi', 'vaishnavi.crafteak@co']
ls=[]
for i in range(2):
ls.append(input("enter the name"))
print(ls)
enter the namevaishnavi
enter the nameapurva
['vaishnavi', 'apurva']
ls1=[]
ls2=[]
for i in range(4):
ls1.append(input("enter value for list 1"))
ls2.append(input("enter value for list 2"))
print(ls1+ls2)
enter value for list 1vaishnavi
enter value for list 2apurva
enter value for list 1singh
enter value for list 2chouhan
enter value for list 1ibm
enter value for list 2peeyo
enter value for list 1SME
enter value for list 2HR
['vaishnavi', 'singh', 'ibm', 'SME', 'apurva', 'chouhan', 'peeyo',
'HR']
print(ls1,ls2)
['vaishnavi', 'singh', 'ibm', 'SME'] ['apurva', 'chouhan', 'peeyo',
'HR']
ls1.extend(ls2)
print(ls1)
['vaishnavi', 'singh', 'ibm', 'SME', ['apurva', 'chouhan', 'peeyo',
'HR'], 'apurva', 'chouhan', 'peeyo', 'HR']
ls1.count("vaishnavi")
print(len(ls1))
ls3="smile"
ls1.extend(ls3)
print(ls3,ls1)
smile ['vaishnavi', 'singh', 'ibm', 'SME', ['apurva', 'chouhan',
'peeyo', 'HR'], 'apurva', 'chouhan', 'peeyo', 'HR', 'smile', 's', 'm',
'i', 'l', 'e']
ls1.pop(5)
print(ls1)
['vaishnavi', 'singh', 'ibm', 'SME', ['apurva', 'chouhan', 'peeyo',
'HR'], 'chouhan', 'peeyo', 'HR', 'smile', 's', 'm', 'i', 'l', 'e']
ls2.append("ihbji")
for i,j in zip(ls1,ls2):
print(i,j)
vaishnavi apurva
singh chouhan
ibm peeyo
SME HR
ls=["Vaishnavi"]
print(ls)
['Vaishnavi']
ls.append(input("enter the name"))
print(ls)
enter the nameSingh
['chouhan', 'Singh']
ls.pop()
print(ls)
----------------------------------------------------------------------
-----
IndexError Traceback (most recent call
last)
<ipython-input-14-1126cc92aef0> in <cell line: 1>()
----> 1 ls.pop()
2 print(ls)
IndexError: pop from empty list
print(ls1.index("vaishnavi"))
ls1.insert(1,"Vaishnavi")
print(ls1)
['vaishnavi', 'Vaishnavi', 'Vaishnavi', 'singh', 'ibm', 'SME',
['apurva', 'chouhan', 'peeyo', 'HR'], 'chouhan', 'peeyo', 'HR',
'smile', 's', 'm', 'i', 'l', 'e']
name[0]="anurag"
print(name)
['anurag', 'vaishnavi.crafteak@co']
ls1=[]
ls2=[]
for i in range(3):
ls1.append(input("value for 1st list"))
ls2.append(input("value for 2nd list"))
print(ls1,ls2)
value for 1st listkumkum
value for 2nd listrahul
value for 1st listkale
value for 2nd listpatil
value for 1st [email protected]
value for 2nd [email protected]
['kumkum', 'kale', '[email protected]'] ['rahul', 'patil',
'[email protected]']
for i in (ls1,ls2):
i.insert(2,input("enter the fon number"))
enter the fon number6789000
enter the fon number345678
print(ls1,ls2)
['kumkum', 'kale', '[email protected]'] ['rahul', 'patil',
'
[email protected]']
print(ls1+ls2)
['kumkum', 'kale', '[email protected]', 'rahul', 'patil',
'
[email protected]']
ls1.append(ls2)
ls1
['kumkum',
'kale',
'[email protected]',
'Kumkum',
'rahul',
'patil',
'[email protected]',
['rahul', 'patil', '[email protected]']]
for i in range(len(ls2)):
print(ls1[i],",",ls2[i])
kumkum , rahul
kale , patil
[email protected] , [email protected]
ls=["vaishnavi","singh","vaishnavi"]
print(ls.index("vaishnavi"))
ls=["vaishnavi","singh","vaishnavi"]
ls2=["muskan","chouhan"]
ls.extend(ls2)
print("extend",ls)
ls.append(ls2)
print("append",ls)
extend ['vaishnavi', 'singh', 'vaishnavi', 'muskan', 'chouhan']
append ['vaishnavi', 'singh', 'vaishnavi', 'muskan', 'chouhan',
['muskan', 'chouhan']]
ls3="zaid"
ls.append(ls3)
print(ls)
['vaishnavi', 'singh', 'vaishnavi', 'muskan', 'chouhan', ['muskan',
'chouhan'], 'zaid']
print(ls.index('muskan'))
ls[ls.index('muskan')]="muskan1"
print(ls)
['vaishnavi', 'singh', 'vaishnavi', 'muskan1', 'chouhan', ['muskan',
'chouhan'], 'zaid']
print(ls[3])
muskan2
ls=["sumit","krushna","karan","sumit","sumit"]
occ=int(input("enter the name"))
for i in range(occ):
x=ls.index("sumit")
ls[x]="sumit"+str(x)
print(ls.index("sumit"+str(x)))
enter the name3
4
a=4
b=5
print(a+b)
def add(x):
global a
a=x
b=30
print(a+b)
add(60)
print(a+b)
add(60)
9
90
65
90
a="vaishnavi"
print(a[2:7:2])
iha
ls=("sumit","krushna","karan","sumit","sumit")
for i in range(len(ls)):
print(i,"-",ls[:i*-1-1])
0 - ('sumit', 'krushna', 'karan', 'sumit')
1 - ('sumit', 'krushna', 'karan')
2 - ('sumit', 'krushna')
3 - ('sumit',)
4 - ()
a=list(ls)
a.append("sumit")
print(tuple(a))
('sumit', 'krushna', 'karan', 'sumit', 'sumit', 'sumit')
print(8+9)
17
import keras
a=("Vaishnavi")
b=(8,9,"Vaishnavi")
print(b)
#a=[10]
#print(a+b)
#print(a)
(8, 9, 'Vaishnavi')
a,b=input("enter your number").split("/")
#b=int(input("enter second number"))
print(a,"-",b)
enter your number67/98
67 - 98
a=int(input("enter the first number"))
b=int(input("enter the second number"))
c=int(input("enter the third number"))
if a>b:
if a>c:
if b>c:
print(a,b,c)
else:
print(a,c,b)
else:
print(c,a,b)
else:
if b>c:
if a>c:
print(b,a,c)
else:
print(b,c,a)
else:
print(c,b,a)
enter the first number9
enter the second number23
enter the third number78
78 23 9
a=int(input("enter the number"))
if a%2!=0 or a%5!=0:
print("true")
else:
print("false")
enter the number20
false