Skip to content

Commit a13c0cd

Browse files
committed
Some more demos
1 parent 6c82dc2 commit a13c0cd

File tree

4 files changed

+106
-0
lines changed

4 files changed

+106
-0
lines changed

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.pythonPath": "/usr/bin/python3"
3+
}

ClassesAndObjects.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class MyClass:
2+
a = 0
3+
# def __init__(self):
4+
# print("init")
5+
6+
def __init__(self, a):
7+
self.a = a
8+
9+
def display(self, b):
10+
print("Codekul - {} {}".format(self.a,b))
11+
12+
13+
obj = MyClass(10)
14+
obj.display(40)
15+
16+
class MyAnotherClass:
17+
def __init__(self):
18+
print("init")
19+
20+
21+
obj1 = MyAnotherClass()
22+

DataTypes.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
a = 10
2+
b = 20.90
3+
4+
c = a + b
5+
6+
print(c)
7+
8+
res = a < b
9+
10+
print(res)
11+
12+
c1 = complex(10, 20)
13+
14+
c2 = complex(5, 10)
15+
16+
print(c1)
17+
print(c2)
18+
19+
print(c1 + c2)
20+
print(c1 - c2)
21+
22+
print(c1*c2)
23+
print(c1/c2)

Functions.py

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
def display():
2+
print("codekul")
3+
4+
display()
5+
6+
def displayWithParam(param1, param2=10):
7+
print(param1)
8+
print(param2)
9+
10+
displayWithParam("Codekul", 30)
11+
12+
13+
def changeThis(myList):
14+
myList = [10,20,30,40,50]
15+
print(myList)
16+
17+
myList = [1,2,3,4,5]
18+
changeThis(myList)
19+
print(myList)
20+
21+
def functionWithReturning():
22+
print("This function will return string")
23+
return "Codekul"
24+
25+
print(functionWithReturning())
26+
27+
def mutiplication(a,b,c=0):
28+
c += (a*b)
29+
30+
c = 0
31+
mutiplication(10,20,c)
32+
print(c)
33+
34+
def myFunc(str, int = 10):
35+
print("str: ",str)
36+
print("int", int)
37+
38+
myFunc(int = 30, str = "Codekul")
39+
40+
square = lambda a: a**2
41+
42+
print(square(15))
43+
44+
sum = lambda a,b,c,d,e: a + b + c + d + e
45+
46+
print(sum(10, 20, 30, 40, 50))
47+
48+
49+
def function1(a, b):
50+
print(a)
51+
print(b)
52+
53+
def function2(function1, t):
54+
function1(*t)
55+
56+
function2(function1,(10,20))
57+
58+

0 commit comments

Comments
 (0)