a=1
def do(x):
return(x+a)
print(do(1))
class Points(object):
def __init__(self,x,y):
self.x=x
self.y=y
def print_point(self):
print('x=',self.x,' y=',self.y)
p2=Points(1,2)
p2.x=2
p2.print_point()
print("*****************")
x=5
while(x!=2):
print(x)
x=x-1
print("*****************")
class Points(object):
def __init__(self,x,y):
self.x=x
self.y=y
def print_point(self):
print('x=',self.x,' y=',self.y)
p1=Points("A","B")
p1.print_point()
print("*****************")
for i,x in enumerate(['A','B','C']):
print(i+1,x)
A = ((11, 12), [21, 21])
print(A[1])
L = []
print(L.append(['a','b']))
B = ["hard rock", 1, 1.2]
del(B[1])
print(B)
C = (("desco",10))
print(len(C))
D = {"a", "b"}
D.add("c")
print(D)
i=6
print(i<5)
print("a"=="A")
print (True or False)
for x in range(0,3):
print(x)
for Y in ["A", "B", "C"]:
print(Y + "A")
for i, x in enumerate(["A", "B", "C"]):
print(i,x)
def square(num):
return num ** 2
print (square(2))
print(lambda num: num * 2)
map_list = [1,2,3,4,5]
print(list(map(square, map_list)))
print(list(map(lambda num: num ** 2, [1,2,3,4,5])))
a = [1,2,3,4]
b = [17,12,11,10]
c = [-1,-4,5,9]
print(list(map(lambda x, y, z: x + y + z, a, b, c)))
print("*******************")
letters_list = [letters for letters in 'Hello world']
print(letters_list)
print("*******************")
numbers_list = [numbers for numbers in list(range(10))]
print(numbers_list)
print("*******************")
print(range(5))
print(list(range(5)))
print("*******************")
my_list = [1,2,3,4,5,6,7]
for item in my_list:
print(item)
print("*******************")
i = 1
while i <= 5:
print("the value of i is {}".format(i))
i = i +1
print("*******************")
j = 1
while j < 5:
print("the value of j is {}".format(j))
j = j +1
else:
print("exiting the loop")
print("*******************")
print((1 + 2) * (3 + 4))
print(1 + 2 * 3 + 4)
print("*******************")
# Creating a class
class class_name:
def __init__(self .optional_parameter_1, optional_parameter_2):
self.attribute_1 = optional_parameter_1
self.attribute_2 = optional_parameter_2
def method_name(self, optional_parameter_1):
# Code to execute
return optional_output
# Create an instance of a class
object = class_name(parameter_1, parameter_2)
# Calling an object method
object.method_name(parameter_3)
To embed this project on your website, copy the following code and paste it into your website's HTML: