DS5B-2028 All Ques - HTML
DS5B-2028 All Ques - HTML
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
n=int(input("Enter last digit of roll no. "))
print(factorial(n))
num=[]
for i in range(1312, 3121):
if (i%7==0) and (1%5!=0):
num.append(str(i))
print(','. join(num))
1316,1323,1330,1337,1344,1351,1358,1365,1372,1379,1386,1393,1400,1407,1
414,1421,1428,1435,1442,1449,1456,1463,1470,1477,1484,1491,1498,1505,15
12,1519,1526,1533,1540,1547,1554,1561,1568,1575,1582,1589,1596,1603,161
0,1617,1624,1631,1638,1645,1652,1659,1666,1673,1680,1687,1694,1701,170
8,1715,1722,1729,1736,1743,1750,1757,1764,1771,1778,1785,1792,1799,180
6,1813,1820,1827,1834,1841,1848,1855,1862,1869,1876,1883,1890,1897,190
4,1911,1918,1925,1932,1939,1946,1953,1960,1967,1974,1981,1988,1995,200
2,2009,2016,2023,2030,2037,2044,2051,2058,2065,2072,2079,2086,2093,210
0,2107,2114,2121,2128,2135,2142,2149,2156,2163,2170,2177,2184,2191,219
8,2205,2212,2219,2226,2233,2240,2247,2254,2261,2268,2275,2282,2289,229
6,2303,2310,2317,2324,2331,2338,2345,2352,2359,2366,2373,2380,2387,239
4,2401,2408,2415,2422,2429,2436,2443,2450,2457,2464,2471,2478,2485,249
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
2,2499,2506,2513,2520,2527,2534,2541,2548,2555,2562,2569,2576,2583,259
0,2597,2604,2611,2618,2625,2632,2639,2646,2653,2660,2667,2674,2681,268
8,2695,2702,2709,2716,2723,2730,2737,2744,2751,2758,2765,2772,2779,278
6,2793,2800,2807,2814,2821,2828,2835,2842,2849,2856,2863,2870,2877,288
4,2891,2898,2905,2912,2919,2926,2933,2940,2947,2954,2961,2968,2975,298
2,2989,2996,3003,3010,3017,3024,3031,3038,3045,3052,3059,3066,3073,308
0,3087,3094,3101,3108,3115
if val==1:
def areaCircle(r):
return (3.14*r*r)
print('Area of Circle is ',areaCircle(4))
elif val==2:
def cicumCircle(r):
return((2*3.14*r))
print('Cicumference of Circle is ',circumCircle(4))
elif val==3:
def areaSquare(a):
return(a*a)
print('Area of Square is ',areaSquare(4))
else:
def perSquare(a):
return (4*a)
print('Perimeter of Square is ',periSquare(4))
dict1=dict()
roll_num=int(input("Enter the last number of your roll number"))
for i in range(1,5+1):
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
dict1[i]=i*i
print(dict1)
array1= np.array([80,70,80,60,50,75,88,90,35,79,100,95,85,75,65,66,65,8
0,94,91])
print(array1)
[ 80 70 80 60 50 75 88 90 35 79 100 95 85 75 65 66 65 8
0
94 91]
In [9]: array1[1:5]
In [10]: array1.ndim
Out[10]: 1
In [11]: np.append(array1,100)
Out[11]: array([ 80, 70, 80, 60, 50, 75, 88, 90, 35, 79, 100, 95, 85,
75, 65, 66, 65, 80, 94, 91, 100])
In [12]: np.insert(array1,5,100)
Out[12]: array([ 80, 70, 80, 60, 50, 100, 75, 88, 90, 35, 79, 100, 95,
85, 75, 65, 66, 65, 80, 94, 91])
In [13]: np.delete(array1,4)
Out[13]: array([ 80, 70, 80, 60, 75, 88, 90, 35, 79, 100, 95, 85, 75,
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
65, 66, 65, 80, 94, 91])
In [16]: array1.sort()
print(array1)
[ 35 50 60 65 65 66 70 75 75 79 80 80 80 85 88 90 91 9
4
95 100]
multi_array=np.array([[1,2,3,4],[5,6,7,8],[15,16,17,18],[25,26,27,28]])
print(multi_array)
[[ 1 2 3 4]
[ 5 6 7 8]
[15 16 17 18]
[25 26 27 28]]
In [19]: multi_array.transpose()
In [20]: numpy.diagonal(multi_array)
In [21]: multi_array.shape
Out[21]: (4, 4)
In [22]: np.random.rand(4,5)
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
[0.96041816, 0.76179807, 0.24483973, 0.24427745, 0.89085102],
[0.23436003, 0.69970021, 0.49276341, 0.63298998, 0.32312401]])
#FOR LIST
emplist=["Harry","Rohan","Riya"]
print(emplist)
In [27]: print(emplist[1])
Rohan
In [28]: print(emplist[1:])
['Rohan', 'Riya']
In [29]: emplist[1]="Shreyans"
print(emplist)
In [30]: emplist[1:2]=["Shreyansh","Ana"]
print(emplist)
In [31]: emplist.append("Sunita")
print(emplist)
In [32]: emplist.insert(1,"Sam")
print(emplist)
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
['Harry', 'Sam', 'Shreyansh', 'Ana', 'Riya', 'Sunita']
In [34]: print(emptuple[-1])
Sunita
-----------------------------------------------------------------------
----
AttributeError Traceback (most recent call l
ast)
<ipython-input-36-e64053f518fb> in <module>
----> 1 emptuple.append("Shreyans")
2 print(emptuple)
empdict={"Harry":"Management","Sam":"Admin","Shreyans":"Developer"}
In [44]: x=empdict.get("Shreyans")
print(x)
Developer
In [45]: empdict.update({"Sunita":"Admin"})
print(empdict)
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
{'Harry': 'Management', 'Sam': 'Admin', 'Shreyans': 'Developer', 'Sunit
a': 'Admin'}
#class India
class India:
def indplace(self):
print("Taj Mahal is a famous place in India")
#class Bangladesh
class Bangladesh:
def banplace(self):
print("Lal Bagh Fort is a famous place in Bangladesh")
In [25]: asian_place=Asia()
#Displaying Asian Famous Places
asian_place.dispplace()
asian_place.indplace()
asian_place.banplace()
Asian Places
Taj Mahal is a famous place in India
Lal Bagh Fort is a famous place in Bangladesh
custTrans = [100,800,400,200,600]
disc_10=[]
disc_5 = []
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
for i in custTrans:
if i>=500:
temp= (i*10)/100
disc_10.append(i)
else:
temp1=(i*5)/100
disc_5.append(i)
print(disc_10)
print(disc_5)
disc_val=disc_10+disc_5
print('Total Discount Value: ',disc_val)
def sum(num):
total = 0
for x in num:
total += x
return total
print('Total Discount Value in Rs.: ',sum(disc_val))
[800, 600]
[100, 400, 200]
Total Discount Value: [800, 600, 100, 400, 200]
Total Discount Value in Rs.: 2100
class Student:
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
print("Marks2 : ", ob.m2)
print("\n")
else:
print(" Student Found, ")
s = obj.search(2)
obj.display(ls[s])
Operations used,
1.Display Student Details
2.Search Details of a Student
Enter choice:2
Student Found,
-----------------------------------------------------------------------
----
AttributeError Traceback (most recent call l
ast)
<ipython-input-62-94ab35c6a229> in <module>
24 else:
25 print(" Student Found, ")
---> 26 s = obj.search(2)
27 obj.display(ls[s])
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
AttributeError: 'Student' object has no attribute 'search'
In [ ]:
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD