Update battest.py

Add decorator test `@classmethod` and fixed spellings.
This commit is contained in:
Sarvesh MD 2021-07-25 18:41:44 +05:30 committed by David Peter
parent 2ea6348b85
commit f464b1ba39
2 changed files with 24 additions and 14 deletions

View File

@ -8,7 +8,7 @@
h2 = 4 # this is a comment h2 = 4 # this is a comment
"""this is also a comment""" """this is also a comment"""
# Import testt # Import test
# class test # class test
@ -16,14 +16,19 @@
class Hello: class Hello:
 def __init__(self, x):  def __init__(self, x):
 self.name = x  self.name = x
 
 def selfprint(self):  def selfprint(self):
 print("hello my name is ", self.name)  print("hello my name is ", self.name)
 def testprint(self):  def testprint(self):
 print(1*2, 2+3, 4 % 5, 8-4, 9/4, 23//4)  print(1*2, 2+3, 4 % 5, 8-4, 9/4, 23//4)
# Decorators test
class Decorators:
 @classmethod
 def decoratorsTest(self):
 pass
 
H1 = Hello("john") H1 = Hello("john")
H1.selfprint() H1.selfprint()
H1.testprint() H1.testprint()
@ -37,8 +42,8 @@
print(a[2]) print(a[2])
print(a[2:]) print(a[2:])
# dictioary test # dictionary test
# copied from w3school example # copied from w3schools example
myfamily = { myfamily = {
 "child1": {  "child1": {
@ -55,7 +60,7 @@
 }  }
} }
# touple test # tuple test
testTuple = ("one", 2, "3") testTuple = ("one", 2, "3")
print(testTuple) print(testTuple)
@ -70,7 +75,7 @@
formattest = "teststring is ={}".format(5) formattest = "teststring is ={}".format(5)
# lamda test # lambda test
def x2(n): def x2(n):

View File

@ -8,7 +8,7 @@ from time import *
h2 = 4 # this is a comment h2 = 4 # this is a comment
"""this is also a comment""" """this is also a comment"""
# Import testt # Import test
# class test # class test
@ -16,14 +16,19 @@ h2 = 4 # this is a comment
class Hello: class Hello:
def __init__(self, x): def __init__(self, x):
self.name = x self.name = x
def selfprint(self): def selfprint(self):
print("hello my name is ", self.name) print("hello my name is ", self.name)
def testprint(self): def testprint(self):
print(1*2, 2+3, 4 % 5, 8-4, 9/4, 23//4) print(1*2, 2+3, 4 % 5, 8-4, 9/4, 23//4)
# Decorators test
class Decorators:
@classmethod
def decoratorsTest(self):
pass
H1 = Hello("john") H1 = Hello("john")
H1.selfprint() H1.selfprint()
H1.testprint() H1.testprint()
@ -37,8 +42,8 @@ print(a[:4])
print(a[2]) print(a[2])
print(a[2:]) print(a[2:])
# dictioary test # dictionary test
# copied from w3school example # copied from w3schools example
myfamily = { myfamily = {
"child1": { "child1": {
@ -55,7 +60,7 @@ myfamily = {
} }
} }
# touple test # tuple test
testTuple = ("one", 2, "3") testTuple = ("one", 2, "3")
print(testTuple) print(testTuple)
@ -70,7 +75,7 @@ bye"""
formattest = "teststring is ={}".format(5) formattest = "teststring is ={}".format(5)
# lamda test # lambda test
def x2(n): def x2(n):